| @@ 23-66 (lines=44) @@ | ||
| 20 | * @link https://dev.commercetools.com/http-api-projects-carts.html#cart-by-customer-id |
|
| 21 | * @method Cart mapResponse(ApiResponseInterface $response) |
|
| 22 | */ |
|
| 23 | class CartByCustomerIdGetRequest extends AbstractApiRequest |
|
| 24 | { |
|
| 25 | use CustomerIdTrait; |
|
| 26 | ||
| 27 | protected $resultClass = '\Commercetools\Core\Model\Cart\Cart'; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @param string $customerId |
|
| 31 | * @param Context $context |
|
| 32 | */ |
|
| 33 | public function __construct($customerId, Context $context = null) |
|
| 34 | { |
|
| 35 | parent::__construct(CartsEndpoint::endpoint(), $context); |
|
| 36 | $this->byCustomerId($customerId); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @param string $customerId |
|
| 41 | * @param Context $context |
|
| 42 | * @return static |
|
| 43 | */ |
|
| 44 | public static function ofCustomerId($customerId, Context $context = null) |
|
| 45 | { |
|
| 46 | return new static($customerId, $context); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * @return HttpRequest |
|
| 51 | * @internal |
|
| 52 | */ |
|
| 53 | public function httpRequest() |
|
| 54 | { |
|
| 55 | return new HttpRequest(HttpMethod::GET, $this->getPath()); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * @param ResponseInterface $response |
|
| 60 | * @return ResourceResponse |
|
| 61 | */ |
|
| 62 | public function buildResponse(ResponseInterface $response) |
|
| 63 | { |
|
| 64 | return new ResourceResponse($response, $this, $this->getContext()); |
|
| 65 | } |
|
| 66 | } |
|
| 67 | ||
| @@ 23-67 (lines=45) @@ | ||
| 20 | * @link https://dev.commercetools.com/http-api-projects-customers.html#customer-by-password-token |
|
| 21 | * @method Customer mapResponse(ApiResponseInterface $response) |
|
| 22 | */ |
|
| 23 | class CustomerByTokenGetRequest extends AbstractApiRequest |
|
| 24 | { |
|
| 25 | const TOKEN = 'token'; |
|
| 26 | ||
| 27 | protected $resultClass = '\Commercetools\Core\Model\Customer\Customer'; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * @param string $token |
|
| 31 | * @param Context $context |
|
| 32 | */ |
|
| 33 | public function __construct($token, Context $context = null) |
|
| 34 | { |
|
| 35 | parent::__construct(CustomersEndpoint::endpoint(), $context); |
|
| 36 | $this->addParam(static::TOKEN, $token); |
|
| 37 | } |
|
| 38 | ||
| 39 | /** |
|
| 40 | * @param string $token |
|
| 41 | * @param Context $context |
|
| 42 | * @return static |
|
| 43 | */ |
|
| 44 | public static function ofToken($token, Context $context = null) |
|
| 45 | { |
|
| 46 | return new static($token, $context); |
|
| 47 | } |
|
| 48 | ||
| 49 | /** |
|
| 50 | * @return HttpRequest |
|
| 51 | * @internal |
|
| 52 | */ |
|
| 53 | public function httpRequest() |
|
| 54 | { |
|
| 55 | return new HttpRequest(HttpMethod::GET, $this->getPath()); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * @param ResponseInterface $response |
|
| 60 | * @return ResourceResponse |
|
| 61 | * @internal |
|
| 62 | */ |
|
| 63 | public function buildResponse(ResponseInterface $response) |
|
| 64 | { |
|
| 65 | return new ResourceResponse($response, $this, $this->getContext()); |
|
| 66 | } |
|
| 67 | } |
|
| 68 | ||
| @@ 22-77 (lines=56) @@ | ||
| 19 | * @link https://dev.commercetools.com/http-api-projects-shippingMethods.html#shipping-methods-for-cart |
|
| 20 | * @method ShippingMethodCollection mapResponse(ApiResponseInterface $response) |
|
| 21 | */ |
|
| 22 | class ShippingMethodByCartIdGetRequest extends AbstractApiRequest |
|
| 23 | { |
|
| 24 | protected $resultClass = '\Commercetools\Core\Model\ShippingMethod\ShippingMethodCollection'; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @var string |
|
| 28 | */ |
|
| 29 | protected $cartId; |
|
| 30 | ||
| 31 | /** |
|
| 32 | * @param string $cartId |
|
| 33 | * @param Context $context |
|
| 34 | */ |
|
| 35 | public function __construct($cartId, Context $context = null) |
|
| 36 | { |
|
| 37 | parent::__construct(ShippingMethodsEndpoint::endpoint(), $context); |
|
| 38 | $this->withCartId($cartId); |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * @param string $cartId |
|
| 43 | * @return $this |
|
| 44 | */ |
|
| 45 | public function withCartId($cartId) |
|
| 46 | { |
|
| 47 | return $this->addParam('cartId', $cartId); |
|
| 48 | } |
|
| 49 | ||
| 50 | /** |
|
| 51 | * @param string $cartId |
|
| 52 | * @param Context $context |
|
| 53 | * @return static |
|
| 54 | */ |
|
| 55 | public static function ofCartId($cartId, Context $context = null) |
|
| 56 | { |
|
| 57 | return new static($cartId, $context); |
|
| 58 | } |
|
| 59 | ||
| 60 | /** |
|
| 61 | * @return HttpRequest |
|
| 62 | * @internal |
|
| 63 | */ |
|
| 64 | public function httpRequest() |
|
| 65 | { |
|
| 66 | return new HttpRequest(HttpMethod::GET, $this->getPath()); |
|
| 67 | } |
|
| 68 | ||
| 69 | /** |
|
| 70 | * @param ResponseInterface $response |
|
| 71 | * @return PagedQueryResponse |
|
| 72 | */ |
|
| 73 | public function buildResponse(ResponseInterface $response) |
|
| 74 | { |
|
| 75 | return new PagedQueryResponse($response, $this, $this->getContext()); |
|
| 76 | } |
|
| 77 | } |
|
| 78 | ||
| @@ 16-45 (lines=30) @@ | ||
| 13 | use Commercetools\Core\Response\ResourceResponse; |
|
| 14 | use Psr\Http\Message\ResponseInterface; |
|
| 15 | ||
| 16 | class GraphQLQueryRequest extends AbstractApiRequest |
|
| 17 | { |
|
| 18 | /** |
|
| 19 | * @param Context $context |
|
| 20 | */ |
|
| 21 | public function __construct(Context $context = null) |
|
| 22 | { |
|
| 23 | parent::__construct(GraphQLEndpoint::endpoint(), $context); |
|
| 24 | } |
|
| 25 | ||
| 26 | public function buildResponse(ResponseInterface $response) |
|
| 27 | { |
|
| 28 | return new ResourceResponse($response, $this, $this->getContext()); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function httpRequest() |
|
| 32 | { |
|
| 33 | return new HttpRequest(HttpMethod::GET, $this->getPath()); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function query($query) |
|
| 37 | { |
|
| 38 | $this->addParam('query', $query); |
|
| 39 | } |
|
| 40 | ||
| 41 | public static function of(Context $context = null) |
|
| 42 | { |
|
| 43 | return new static($context); |
|
| 44 | } |
|
| 45 | } |
|
| 46 | ||