commerce_amws-8.x-1.x-dev/modules/shipping/src/EntitySync/FeedPostOrderFulfillmentDataFactory.php

modules/shipping/src/EntitySync/FeedPostOrderFulfillmentDataFactory.php
<?php

namespace Drupal\commerce_amws_shipping\EntitySync;

use Drupal\commerce_amws_feed\Content\XmlBuilderInterface as FeedContentBuilderInterface;
use Drupal\entity_sync\Client\ProviderClientFactoryInterface;

use Drupal\Core\Entity\EntityTypeManagerInterface;

use SellingPartnerApi\Api\FeedsApi;
use SellingPartnerApi\Configuration;
use SellingPartnerApi\Endpoint;

/**
 * Factory for generating feed API clients.
 */
class FeedPostOrderFulfillmentDataFactory implements
  ProviderClientFactoryInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * The XML feed content builder.
   *
   * @var \Drupal\commerce_amws_feed\Content\XmlBuilderInterface
   */
  protected $feedContentBuilder;

  /**
   * Constructs a new FeedPostOrderFulfillmentDataFactory object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   * @param \Drupal\commerce_amws_feed\Content\XmlBuilderInterface $feed_content_builder
   *   The XML feed content builder.
   */
  public function __construct(
    EntityTypeManagerInterface $entity_type_manager,
    FeedContentBuilderInterface $feed_content_builder
  ) {
    $this->entityTypeManager = $entity_type_manager;
    $this->feedContentBuilder = $feed_content_builder;
  }

  /**
   * {@inheritdoc}
   */
  public function get($sync_id, array $parameters) {
    $amws_store = $parameters['amws_store'];
    $configuration = new Configuration([
      'lwaClientId' => $amws_store->getLwaClientId(),
      'lwaClientSecret' => $amws_store->getLwaClientSecret(),
      'lwaRefreshToken' => $amws_store->getLwaRefreshToken(),
      'awsAccessKeyId' => $amws_store->getAwsAccessKeyId(),
      'awsSecretAccessKey' => $amws_store->getAwsSecretAccessKey(),
      'endpoint' => Endpoint::getByMarketplaceId(
        $amws_store->getMarketplaceId()
      ),
    ]);

    return new FeedPostOrderFulfillmentDataClient(
      $this->entityTypeManager,
      $this->feedContentBuilder,
      new FeedsApi($configuration),
      $amws_store
    );
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc