Code Duplication    Length = 36-56 lines in 5 locations

src/Request/Carts/CartByCustomerIdGetRequest.php 1 location

@@ 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

src/Request/Customers/CustomerByTokenGetRequest.php 1 location

@@ 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

src/Request/ShippingMethods/ShippingMethodByCartIdGetRequest.php 1 location

@@ 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

src/Request/GraphQL/GraphQLQueryRequest.php 1 location

@@ 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

src/Request/Me/MeGetRequest.php 1 location

@@ 21-60 (lines=40) @@
18
 * @package Commercetools\Core\Request\Me
19
 * @method Customer mapResponse(ApiResponseInterface $response)
20
 */
21
class MeGetRequest extends AbstractApiRequest
22
{
23
    protected $resultClass = '\Commercetools\Core\Model\Customer\Customer';
24
25
    /**
26
     * @param Context $context
27
     */
28
    public function __construct(Context $context = null)
29
    {
30
        parent::__construct(MeEndpoint::endpoint(), $context);
31
    }
32
33
    /**
34
     * @param Context $context
35
     * @return static
36
     */
37
    public static function of(Context $context = null)
38
    {
39
        return new static($context);
40
    }
41
42
    /**
43
     * @return HttpRequest
44
     * @internal
45
     */
46
    public function httpRequest()
47
    {
48
        return new HttpRequest(HttpMethod::GET, $this->getPath());
49
    }
50
51
    /**
52
     * @param ResponseInterface $response
53
     * @return ResourceResponse
54
     * @internal
55
     */
56
    public function buildResponse(ResponseInterface $response)
57
    {
58
        return new ResourceResponse($response, $this, $this->getContext());
59
    }
60
}
61