api_platform:
  resource_class_directories:
    - '%kernel.project_dir%/var/run/classes/CDev/Wholesale/Model'

dto_generator:
  entities:
    api:
      XCart\API\Entity\Storefront\Product\Compact:
        fields:
          minPurchaseQuantity:
            type: integer

      XCart\API\Entity\Storefront\Product\Detailed:
        fields:
          minPurchaseQuantity:
            type: integer
          applySaleToWholesale:
            type: boolean
          wholesalePrices:
            type: XCart\API\Entity\Storefront\WholesalePrice[]

    logic:
      XCart\Logic\Entity\Storefront\Product:
        fields:
          minPurchaseQuantity:
            type: integer
          applySaleToWholesale:
            type: boolean
          wholesalePrices:
            type: XCart\Logic\Entity\Storefront\WholesalePrice[]

    dto:
      XCart\API\Entity\Storefront\WholesalePrice:
        fields:
          quantityRangeBegin:
            type: integer
          quantityRangeEnd:
            type: integer
            nullable: true
          type:
            type: XCart\Enum\WholesalePriceType
          value:
            type: float
      XCart\Logic\Entity\Storefront\WholesalePrice:
        fields:
          quantityRangeBegin:
            type: integer
          quantityRangeEnd:
            type: integer
            nullable: true
          type:
            type: string
          value:
            type: float

  enumerations:
    XCart\Enum\WholesalePriceType:
      items:
        Price:
          value: price
        Percent:
          value: percent

services:
  _defaults:
    autowire: true
    autoconfigure: true
    public: true

  # /product/{product_id}/wholesale_prices
  CDev\Wholesale\API\Endpoint\ProductWholesalePrice\Transformer\OutputTransformerInterface: '@CDev\Wholesale\API\Endpoint\ProductWholesalePrice\Transformer\OutputTransformer'
  CDev\Wholesale\API\Endpoint\ProductWholesalePrice\Transformer\OutputTransformer: ~
  CDev\Wholesale\API\Endpoint\ProductWholesalePrice\Transformer\InputTransformerInterface: '@CDev\Wholesale\API\Endpoint\ProductWholesalePrice\Transformer\InputTransformer'
  CDev\Wholesale\API\Endpoint\ProductWholesalePrice\Transformer\InputTransformer: ~

  CDev\Wholesale\API\Endpoint\ProductWholesalePrice\SubIriConverter\SubIriConverter:
    tags: [!php/const XCart\Framework\ApiPlatform\Core\Bridge\Symfony\Routing\SubIriConverter\SubIriFromItemConverterInterface::SUB_IRI_FROM_ITEM_CONVERTER_TAG]

  CDev\Wholesale\API\Endpoint\ProductWholesalePrice\DataProvider\CollectionDataProvider:
    arguments:
      $inner: '@api_platform.doctrine.orm.default.collection_data_provider'
      $repository: '@xcart.repository.product'

  CDev\Wholesale\API\Endpoint\ProductWholesalePrice\DataProvider\ItemDataProvider:
    arguments:
      $inner: '@api_platform.doctrine.orm.default.item_data_provider'
      $repository: '@xcart.repository.product'

  xcart.api.cdev.wholesale.product_wholesale_price.controller:
    class: CDev\Wholesale\Controller\API\ProductWholesalePrice\Post
    arguments:
      $repository: '@xcart.repository.product'

  CDev\Wholesale\API\OpenApiTagsRepositoryDecorator:
    decorates: XLite\API\OpenApiTagsRepository

  xcart.api.cdev.wholesale.product_wholesale_price.sub_extension:
    class: CDev\Wholesale\API\Endpoint\ProductWholesalePrice\SubExtension\SubExtension
    tags: [!php/const XLite\API\Extension\CollectionSubExtension\CollectionSubExtensionInterface::COLLECTION_SUB_EXTENSION_TAG, !php/const XLite\API\Extension\ItemSubExtension\ItemSubExtensionInterface::ITEM_SUB_EXTENSION_TAG]

  # Storefront API
  xcart.logic.storefront.product.get_one_by_id.action.decorator.wholesale_prices:
    class: CDev\Wholesale\Logic\Action\Storefront\Product\GetOne\ActionDecorator
    decorates: xcart.logic.storefront.product.get_one_by_id.action
    decoration_priority: 40
    arguments:
      $inner: '@.inner'
      $queryBuilderAssembler: '@xcart.logic.storefront.product.get_one_by_id.assembler.query_builder'

  xcart.logic.storefront.product.get_one_by_clean_url.action.decorator.wholesale_prices:
    class: CDev\Wholesale\Logic\Action\Storefront\Product\GetOne\ActionDecorator
    decorates: xcart.logic.storefront.product.get_one_by_clean_url.action
    decoration_priority: 40
    arguments:
      $inner: '@.inner'
      $queryBuilderAssembler: '@xcart.logic.storefront.product.get_one_by_clean_url.assembler.query_builder'

  CDev\Wholesale\Transformer\CDev\Wholesale\Model\WholesalePrice\Logic\Entity\Storefront\WholesalePriceInterface: '@CDev\Wholesale\Transformer\CDev\Wholesale\Model\WholesalePrice\Logic\Entity\Storefront\WholesalePrice'

  CDev\Wholesale\Transformer\CDev\Wholesale\Model\WholesalePrice\Logic\Entity\Storefront\WholesalePrice:
    class: CDev\Wholesale\Transformer\CDev\Wholesale\Model\WholesalePrice\Logic\Entity\Storefront\WholesalePrice
