Skip to content
This repository was archived by the owner on Oct 24, 2023. It is now read-only.

Commit 93e9b3d

Browse files
committed
feat(Cart): update GetCartByCustomerIdRequest to use changed URI
1 parent b302b41 commit 93e9b3d

File tree

2 files changed

+23
-4
lines changed

2 files changed

+23
-4
lines changed

src/Core/Request/Carts/CartByCustomerIdGetRequest.php

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use Commercetools\Core\Client\HttpRequest;
1313
use Commercetools\Core\Model\Common\Context;
1414
use Commercetools\Core\Request\AbstractApiRequest;
15-
use Commercetools\Core\Request\CustomerIdTrait;
1615
use Commercetools\Core\Response\ResourceResponse;
1716
use Commercetools\Core\Model\Cart\Cart;
1817
use Commercetools\Core\Response\ApiResponseInterface;
@@ -27,19 +26,30 @@
2726
*/
2827
class CartByCustomerIdGetRequest extends AbstractApiRequest
2928
{
30-
use CustomerIdTrait;
3129
use InStoreTrait;
3230

3331
protected $resultClass = Cart::class;
3432

33+
/**
34+
* @var string
35+
*/
36+
protected $customerId;
37+
3538
/**
3639
* @param string $customerId
3740
* @param Context $context
3841
*/
3942
public function __construct($customerId, Context $context = null)
4043
{
4144
parent::__construct(CartsEndpoint::endpoint(), $context);
42-
$this->byCustomerId($customerId);
45+
$this->customerId = $customerId;
46+
}
47+
48+
public function byCustomerId($customerId)
49+
{
50+
$this->customerId = $customerId;
51+
52+
return $this;
4353
}
4454

4555
/**
@@ -52,6 +62,15 @@ public static function ofCustomerId($customerId, Context $context = null)
5262
return new static($customerId, $context);
5363
}
5464

65+
/**
66+
* @return string
67+
* @internal
68+
*/
69+
protected function getPath()
70+
{
71+
return (string)$this->getEndpoint() . '/customer-id=' . $this->customerId . $this->getParamString();
72+
}
73+
5574
/**
5675
* @return HttpRequest
5776
* @internal

tests/unit/Request/Carts/CartByCustomerIdGetRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function testHttpRequestPath()
3939
$request = CartByCustomerIdGetRequest::ofCustomerId('id');
4040
$httpRequest = $request->httpRequest();
4141

42-
$this->assertSame('carts?customerId=id', (string)$httpRequest->getUri());
42+
$this->assertSame('carts/customer-id=id', (string)$httpRequest->getUri());
4343
}
4444

4545
public function testHttpRequestObject()

0 commit comments

Comments
 (0)