<?php
namespace Prodigy\Includes\Frontend\Mappers;

use Prodigy\Includes\Content\Prodigy_Brands_Parser;

/**
 * Prodigy product brands data mapper
 *
 * @version    3.2.3
 * @package    Prodigy
 * @subpackage Prodigy/includes
 */
class Prodigy_Product_Brands_Data_Mapper extends Prodigy_Main_Data_Mapper {

	const WIDGET_TYPE = 'product';

	/** @var Prodigy_Brands_Parser  */
	private Prodigy_Brands_Parser $brands_parser;

	/**
	 * @param Prodigy_Brands_Parser $brands_parser
	 */
	public function __construct( Prodigy_Brands_Parser $brands_parser ) {
		parent::__construct();
		$this->brands_parser = $brands_parser;
	}

	/**
	 * @param array $options
	 *
	 * @return array
	 * @throws \Exception
	 */
	public function get_default_parameters( array $options ): array {
		$result = array();
		$brands = $this->request_maker->do_brands_list_request( $options['product_id'] );
		if ( ! empty( $brands['data'] ) ) {
			$data   = $this->brands_parser->get_brands_data( $brands );
			$result = compact( 'data' );
		}

		return $result;
	}
}
