commerce_amws-8.x-1.x-dev/modules/order/src/Api/OrderClient.php

modules/order/src/Api/OrderClient.php
<?php

namespace Drupal\commerce_amws_order\Api;

use Drupal\commerce_amws\Api\ClientBase;
use Drupal\commerce_amws\Api\ListClientInterface;
use Drupal\commerce_amws\Api\ListClientTrait;
use Drupal\commerce_amws\Utilities;

use SellingPartnerApi\Api\OrdersApi;
use SellingPartnerApi\Model\ModelInterface;

/**
 * API client for getting orders from Amazon MWS.
 */
class OrderClient extends ClientBase implements ListClientInterface {

  use ListClientTrait {
    listValidateArguments as traitListValidateArguments;
  }

  /**
   * {@inheritdoc}
   */
  protected function clientClassName() {
    return OrdersApi::class;
  }

  /**
   * {@inheritdoc}
   */
  protected function listFetchList(array $options, array $query) {
    return $this->client()->getOrders(
      [$this->amwsStore->getMarketplaceId()],
      $query['created_after'] ?? NULL,
      $query['created_before'] ?? NULL,
      $query['last_updated_after'] ?? NULL,
      $query['last_updated_before'] ?? NULL,
      $query['statuses'] ?? [],
      $query['fulfillment_channels'] ?? [],
      NULL,
      NULL,
      NULL,
      $options['limit'] ?? NULL,
      NULL,
      $query['next_token'] ?? NULL,
      NULL,
      NULL,
      NULL,
      NULL,
      // Request the buyer info and the shipping address to be included,
      // otherwise the corresponding properties are returned empty.
      ['buyerInfo', 'shippingAddress']
    );
  }

  /**
   * {@inheritdoc}
   */
  protected function listGetItems(ModelInterface $list) {
    return $list->getOrders();
  }

  /**
   * {@inheritdoc}
   */
  protected function listValidateArguments(array $options, array $query) {
    $this->traitListValidateArguments($options, $query);

    Utilities::validateArrayKeysExactlyOneOf(
      $query,
      ['created_after', 'last_updated_after']
    );
  }

}

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

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