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

modules/order/src/Api/OrderItemClient.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 SellingPartnerApi\Api\OrdersApi;
use SellingPartnerApi\Model\ModelInterface;

/**
 * API client for getting the order item details for an order from Amazon MWS.
 */
class OrderItemClient 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()->getOrderItems(
      $query['order_id'],
      $query['data_elements'] ?? []
    );
  }

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

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

    if (!isset($query['order_id'])) {
      throw new \InvalidArgumentException(
        'The ID of the Amazon MWS order is required to get the order items.'
      );
    }
  }

}

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

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