services:
  _defaults:
    autowire: true
    autoconfigure: true

  # cart

  ## common
  XCart\API\EventSubscriber\Storefront\CartAccessValidationEventSubscriber:
    class: XCart\API\EventSubscriber\Storefront\CartAccessValidationEventSubscriber
    arguments:
      $cartRepository: '@xcart.repository.cart.read'
      $cartItemRepository: '@xcart.repository.orderitem.read'

  ## create one / update one
  XCart\API\Endpoint\Storefront\Cart\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\Cart\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator
    decorates: xcart.api.storefront.cart.data_persister.persister.request.assembler.create
    arguments:
      $inner: '@.inner'

  ## get one
  XCart\API\Endpoint\Storefront\Cart\DataProvider\Item\Assembler\RequestAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\Cart\DataProvider\Item\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.cart.data_provider.item.request.assembler
    arguments:
      $inner: '@.inner'

  ## delete one
  xcart.api.storefront.cart.data_persister.remover.request.assembler:
    class: XCart\API\Endpoint\Storefront\Cart\DataPersister\Remover\Assembler\IdBasedAssembler

  # cart item

  ## create one
  XCart\API\Endpoint\Storefront\CartItem\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator.create_one:
    class: XCart\API\Endpoint\Storefront\CartItem\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator
    decorates: xcart.api.storefront.cart.item.data_persister.persister.request.assembler.create
    arguments:
      $inner: '@.inner'

  ## update one
  XCart\API\Endpoint\Storefront\CartItem\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator.update_one:
    class: XCart\API\Endpoint\Storefront\CartItem\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator
    decorates: xcart.api.storefront.cart.item.data_persister.persister.request.assembler.update
    arguments:
      $inner: '@.inner'

  ## get one
  XCart\API\Endpoint\Storefront\CartItem\SubIriConverter\SubIriConverter:
    class: XCart\API\Endpoint\Storefront\CartItem\SubIriConverter\SubIriConverter
    tags:
      - xcart.api.sub_iri_from_item_converter
    arguments:
      $cartItemReadRepository: '@xcart.repository.orderitem.read'

  ## get list
  XCart\API\Endpoint\Storefront\CartItem\DataProvider\Collection\Assembler\RequestAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\CartItem\DataProvider\Collection\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.cart.item.data_provider.collection.request.assembler
    arguments:
      $inner: '@.inner'

  # cart merge
  XCart\API\Endpoint\Storefront\CartMerge\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\CartMerge\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator
    decorates: xcart.api.storefront.cart.mergerequest.data_persister.persister.request.assembler.create
    arguments:
      $inner: '@.inner'

  XCart\API\Endpoint\Storefront\CartMerge\SubIriConverter\SubIriConverter:
    class: XCart\API\Endpoint\Storefront\CartMerge\SubIriConverter\SubIriConverter
    tags:
      - xcart.api.sub_iri_from_item_converter

  # calculated shipping rates
  XCart\API\Endpoint\Storefront\Cart\CalculatedShippingRates\DataPersister\Assembler\RequestAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\Cart\CalculatedShippingRates\DataPersister\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.cart.calculatedshippingrates.data_persister.persister.request.assembler.create
    arguments:
      $inner: '@.inner'

  XCart\API\Endpoint\Storefront\Cart\CalculatedShippingRates\SubIriConverter\SubIriConverter:
    class: XCart\API\Endpoint\Storefront\Cart\CalculatedShippingRates\SubIriConverter\SubIriConverter
    tags:
      - xcart.api.sub_iri_from_item_converter

  XCart\API\Endpoint\Storefront\Cart\CalculatedShippingRates\DataPersister\Assembler\ResponseAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\Cart\CalculatedShippingRates\DataPersister\Assembler\ResponseAssemblerDecorator
    decorates: xcart.api.storefront.cart.calculatedshippingrates.data_persister.persister.response.assembler.create
    arguments:
      $inner: '@.inner'
      $cartReadRepository: '@xcart.repository.cart.read'

  # shipping method selection
  XCart\API\Endpoint\Storefront\ShippingMethodSelection\DataPersister\Persister\Assembler\RequestAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\ShippingMethodSelection\DataPersister\Persister\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.cart.shippingmethodselection.data_persister.persister.request.assembler.create
    arguments:
      $inner: '@.inner'

  XCart\API\Endpoint\Storefront\ShippingMethodSelection\DataPersister\Persister\Assembler\ResponseAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\ShippingMethodSelection\DataPersister\Persister\Assembler\ResponseAssemblerDecorator
    decorates: xcart.api.storefront.cart.shippingmethodselection.data_persister.persister.response.assembler.create
    arguments:
      $inner: '@.inner'
      $cartReadRepository: '@xcart.repository.cart.read'

  XCart\API\Endpoint\Storefront\ShippingMethodSelection\SubIriConverter\SubIriConverter:
    class: XCart\API\Endpoint\Storefront\ShippingMethodSelection\SubIriConverter\SubIriConverter
    tags:
      - xcart.api.sub_iri_from_item_converter

  # payment method selection
  XCart\API\Endpoint\Storefront\PaymentMethodSelection\DataPersister\Persister\Assembler\RequestAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\PaymentMethodSelection\DataPersister\Persister\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.cart.paymentmethodselection.data_persister.persister.request.assembler.create
    arguments:
      $inner: '@.inner'

  XCart\API\Endpoint\Storefront\PaymentMethodSelection\DataPersister\Persister\Assembler\ResponseAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\PaymentMethodSelection\DataPersister\Persister\Assembler\ResponseAssemblerDecorator
    decorates: xcart.api.storefront.cart.paymentmethodselection.data_persister.persister.response.assembler.create
    arguments:
      $inner: '@.inner'
      $cartReadRepository: '@xcart.repository.cart.read'

  XCart\API\Endpoint\Storefront\PaymentMethodSelection\SubIriConverter\SubIriConverter:
    class: XCart\API\Endpoint\Storefront\PaymentMethodSelection\SubIriConverter\SubIriConverter
    tags:
      - xcart.api.sub_iri_from_item_converter

  # payment method - get collection
  XCart\API\Endpoint\Storefront\PaymentMethod\DataProvider\GetCollection\Assembler\RequestAssemblerDecorator:
    class: \XCart\API\Endpoint\Storefront\PaymentMethod\DataProvider\GetCollection\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.cart.paymentmethod.data_provider.collection.request.assembler

  # payment method - get item
  XCart\API\Endpoint\Storefront\PaymentMethod\DataProvider\GetItem\Assembler\RequestAssemblerDecorator:
    class: \XCart\API\Endpoint\Storefront\PaymentMethod\DataProvider\GetItem\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.cart.paymentmethod.data_provider.item.request.assembler

  XCart\API\Endpoint\Storefront\PaymentMethod\SubIriConverter\SubIriConverter:
    class: XCart\API\Endpoint\Storefront\PaymentMethod\SubIriConverter\SubIriConverter
    tags:
      - xcart.api.sub_iri_from_item_converter

  # cart email change
  XCart\API\Endpoint\Storefront\CartEmailChanging\DataPersister\Persister\Assembler\RequestAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\CartEmailChanging\DataPersister\Persister\Assembler\RequestAssemblerDecorator
    decorates: xcart.api.storefront.cart.emailchanging.data_persister.persister.request.assembler.create
    arguments:
      $inner: '@.inner'

  XCart\API\Endpoint\Storefront\CartEmailChanging\DataPersister\Persister\Assembler\ResponseAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\CartEmailChanging\DataPersister\Persister\Assembler\ResponseAssemblerDecorator
    decorates: xcart.api.storefront.cart.emailchanging.data_persister.persister.response.assembler.create
    arguments:
      $inner: '@.inner'
      $cartReadRepository: '@xcart.repository.cart.read'

  XCart\API\Endpoint\Storefront\CartEmailChanging\SubIriConverter\SubIriConverter:
    class: XCart\API\Endpoint\Storefront\CartEmailChanging\SubIriConverter\SubIriConverter
    tags:
      - xcart.api.sub_iri_from_item_converter

  # order
  XCart\API\Endpoint\Storefront\Order\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator:
    class: XCart\API\Endpoint\Storefront\Order\DataPersister\Persister\Assembler\CreatePayloadAssemblerDecorator
    decorates: xcart.api.storefront.order.data_persister.persister.request.assembler.create
    arguments:
      $inner: '@.inner'

  XCart\API\Endpoint\Storefront\Order\SubIriConverter\SubIriConverter:
    class: XCart\API\Endpoint\Storefront\Order\SubIriConverter\SubIriConverter
    tags:
      - xcart.api.sub_iri_from_item_converter
