#
# Module services
#
# Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
# See https://www.x-cart.com/license-agreement.html for license details.

framework:
  messenger:
    routing:
      'XC\MailChimp\Messenger\Message\MailChimpRequest': async

services:
  _defaults:
    autowire: true

  XC\MailChimp\Core\OAuth:
    public: true
    arguments:
      $clientId: '371104556554'
      $clientSecret: '39bbf84b9cbae6799294a581f95cad619a926cea538e64a07d'
      $oauthProxyUrl: 'https://mc-end-auth.qtmsoft.com/oauth.php'

  XC\MailChimp\Core\Task\UpdateLists:
    tags:
      - {name: kernel.event_listener, event: xcart.cronjob, method: handleTask}

  XC\MailChimp\Messenger\Handler\MailChimpRequestHandler:
    tags:
      - {name: messenger.message_handler, transport: async}

  XC\MailChimp\EntityCallback\ProductCallback:
    tags:
      - {name: doctrine.orm.entity_listener, event: preUpdate, entity: XLite\Model\Product}
      - {name: doctrine.orm.entity_listener, event: postPersist, entity: XLite\Model\Product}
      - {name: doctrine.orm.entity_listener, event: preRemove, entity: XLite\Model\Product}

  XC\MailChimp\EntityCallback\CouponCallback:
    tags:
      - {name: doctrine.orm.entity_listener, event: preUpdate, entity: CDev\Coupons\Model\Coupon}
      - {name: doctrine.orm.entity_listener, event: postPersist, entity: CDev\Coupons\Model\Coupon}
      - {name: doctrine.orm.entity_listener, event: preRemove, entity: CDev\Coupons\Model\Coupon}

  XC\MailChimp\EntityCallback\CartCallback:
    tags:
      - {name: doctrine.orm.entity_listener, event: prePersist, entity: XLite\Model\Cart}
      - {name: doctrine.orm.entity_listener, event: preUpdate, entity: XLite\Model\Cart}

  XC\MailChimp\EntityCallback\OrderCallback:
    tags:
      - {name: doctrine.orm.entity_listener, event: postPersist, entity: XLite\Model\Order}
      - {name: doctrine.orm.entity_listener, event: postUpdate, entity: XLite\Model\Order}

  XC\MailChimp\EntityCallback\ProductVariantCallback:
    tags:
      - {name: doctrine.orm.entity_listener, event: postPersist, entity: XC\ProductVariants\Model\ProductVariant}
      - {name: doctrine.orm.entity_listener, event: preUpdate, entity: XC\ProductVariants\Model\ProductVariant}
      - {name: doctrine.orm.entity_listener, event: preRemove, entity: XC\ProductVariants\Model\ProductVariant}
