| @@ 23-66 (lines=44) @@ | ||
| 20 | * @link https://dev.commercetools.com/http-api-projects-carts.html#get-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#get-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#get-shippingmethods-for-a-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 | ||
| @@ 23-58 (lines=36) @@ | ||
| 20 | * |
|
| 21 | * @method JsonObject mapResponse(ApiResponseInterface $response) |
|
| 22 | */ |
|
| 23 | class GraphQLQueryRequest extends AbstractApiRequest |
|
| 24 | { |
|
| 25 | /** |
|
| 26 | * @param Context $context |
|
| 27 | */ |
|
| 28 | public function __construct(Context $context = null) |
|
| 29 | { |
|
| 30 | parent::__construct(GraphQLEndpoint::endpoint(), $context); |
|
| 31 | } |
|
| 32 | ||
| 33 | public function buildResponse(ResponseInterface $response) |
|
| 34 | { |
|
| 35 | return new ResourceResponse($response, $this, $this->getContext()); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function httpRequest() |
|
| 39 | { |
|
| 40 | return new HttpRequest(HttpMethod::GET, $this->getPath()); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @param $query |
|
| 45 | * @return $this |
|
| 46 | */ |
|
| 47 | public function query($query) |
|
| 48 | { |
|
| 49 | $this->addParam('query', $query); |
|
| 50 | ||
| 51 | return $this; |
|
| 52 | } |
|
| 53 | ||
| 54 | public static function of(Context $context = null) |
|
| 55 | { |
|
| 56 | return new static($context); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||
| @@ 22-61 (lines=40) @@ | ||
| 19 | * @link https://dev.commercetools.com/http-api-projects-me-profile.html#get-customer |
|
| 20 | * @method Customer mapResponse(ApiResponseInterface $response) |
|
| 21 | */ |
|
| 22 | class MeGetRequest extends AbstractApiRequest |
|
| 23 | { |
|
| 24 | protected $resultClass = '\Commercetools\Core\Model\Customer\Customer'; |
|
| 25 | ||
| 26 | /** |
|
| 27 | * @param Context $context |
|
| 28 | */ |
|
| 29 | public function __construct(Context $context = null) |
|
| 30 | { |
|
| 31 | parent::__construct(MeEndpoint::endpoint(), $context); |
|
| 32 | } |
|
| 33 | ||
| 34 | /** |
|
| 35 | * @param Context $context |
|
| 36 | * @return static |
|
| 37 | */ |
|
| 38 | public static function of(Context $context = null) |
|
| 39 | { |
|
| 40 | return new static($context); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @return HttpRequest |
|
| 45 | * @internal |
|
| 46 | */ |
|
| 47 | public function httpRequest() |
|
| 48 | { |
|
| 49 | return new HttpRequest(HttpMethod::GET, $this->getPath()); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * @param ResponseInterface $response |
|
| 54 | * @return ResourceResponse |
|
| 55 | * @internal |
|
| 56 | */ |
|
| 57 | public function buildResponse(ResponseInterface $response) |
|
| 58 | { |
|
| 59 | return new ResourceResponse($response, $this, $this->getContext()); |
|
| 60 | } |
|
| 61 | } |
|
| 62 | ||
| @@ 23-71 (lines=49) @@ | ||
| 20 | * @link https://dev.commercetools.com/http-api-projects-me-carts.html#get-active-cart |
|
| 21 | * @method Cart mapResponse(ApiResponseInterface $response) |
|
| 22 | */ |
|
| 23 | class MeActiveCartRequest extends AbstractApiRequest |
|
| 24 | { |
|
| 25 | protected $resultClass = '\Commercetools\Core\Model\Cart\Cart'; |
|
| 26 | ||
| 27 | /** |
|
| 28 | * @param Context $context |
|
| 29 | */ |
|
| 30 | public function __construct(Context $context = null) |
|
| 31 | { |
|
| 32 | parent::__construct(MeEndpoint::endpoint(), $context); |
|
| 33 | } |
|
| 34 | ||
| 35 | /** |
|
| 36 | * @param Context $context |
|
| 37 | * @return static |
|
| 38 | */ |
|
| 39 | public static function of(Context $context = null) |
|
| 40 | { |
|
| 41 | return new static($context); |
|
| 42 | } |
|
| 43 | ||
| 44 | /** |
|
| 45 | * @return string |
|
| 46 | * @internal |
|
| 47 | */ |
|
| 48 | protected function getPath() |
|
| 49 | { |
|
| 50 | return (string)$this->getEndpoint() . '/active-cart' . $this->getParamString(); |
|
| 51 | } |
|
| 52 | ||
| 53 | /** |
|
| 54 | * @return HttpRequest |
|
| 55 | * @internal |
|
| 56 | */ |
|
| 57 | public function httpRequest() |
|
| 58 | { |
|
| 59 | return new HttpRequest(HttpMethod::GET, $this->getPath()); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| 63 | * @param ResponseInterface $response |
|
| 64 | * @return ResourceResponse |
|
| 65 | * @internal |
|
| 66 | */ |
|
| 67 | public function buildResponse(ResponseInterface $response) |
|
| 68 | { |
|
| 69 | return new ResourceResponse($response, $this, $this->getContext()); |
|
| 70 | } |
|
| 71 | } |
|
| 72 | ||