Skip to content

Commit a87f7c3

Browse files
committed
build(codegen): updating SDK
1 parent e475de9 commit a87f7c3

17 files changed

+1391
-0
lines changed

changes.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
- added type `BusinessUnitSetUnitTypeAction`
88
- added type `CartDiscountSetDiscountGroupAction`
99
- added type `BestDeal`
10+
- added type `CartMergeMode`
1011
- added type `DiscountTypeCombination`
12+
- added type `MergeCartDraft`
1113
- added type `Stacking`
1214
- added type `CartChangePriceRoundingModeAction`
1315
- added type `CartSetCustomLineItemRecurrenceInfoAction`
@@ -525,6 +527,7 @@
525527
- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withId()->delete()`
526528
- added method `$apiRoot->withProjectKey()->businessUnits()->keyWithKeyValueAssociatesWithAssociateIdValue()->get()`
527529
- added method `$apiRoot->withProjectKey()->businessUnits()->withBusinessUnitIdValueAssociatesWithAssociateIdValue()->get()`
530+
- added method `$apiRoot->withProjectKey()->carts()->customerIdWithCustomerIdValueMerge()->post()`
528531
- added method `$apiRoot->withProjectKey()->discountGroups()->withKey()->get()`
529532
- added method `$apiRoot->withProjectKey()->discountGroups()->withKey()->head()`
530533
- added method `$apiRoot->withProjectKey()->discountGroups()->withKey()->post()`
@@ -570,6 +573,7 @@
570573
- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withId()->delete()`
571574
- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->keyWithKeyValueAssociatesWithAssociateIdValue()->get()`
572575
- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withBusinessUnitIdValueAssociatesWithAssociateIdValue()->get()`
576+
- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->carts()->customerIdWithCustomerIdValueMerge()->post()`
573577
</details>
574578

575579

@@ -585,6 +589,7 @@
585589
- added resource `/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}`
586590
- added resource `/{projectKey}/business-units/key={key}/associates/{associateId}`
587591
- added resource `/{projectKey}/business-units/{businessUnitId}/associates/{associateId}`
592+
- added resource `/{projectKey}/carts/customer-id={customerId}/merge`
588593
- added resource `/{projectKey}/discount-groups/key={key}`
589594
- added resource `/{projectKey}/discount-groups/{ID}`
590595
- added resource `/{projectKey}/payment-methods/key={key}`
@@ -598,6 +603,7 @@
598603
- added resource `/{projectKey}/in-store/key={storeKey}/business-units/{ID}`
599604
- added resource `/{projectKey}/in-store/key={storeKey}/business-units/key={key}/associates/{associateId}`
600605
- added resource `/{projectKey}/in-store/key={storeKey}/business-units/{businessUnitId}/associates/{associateId}`
606+
- added resource `/{projectKey}/in-store/key={storeKey}/carts/customer-id={customerId}/merge`
601607
</details>
602608

603609
**Import changes**
Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/**
5+
* This file has been auto generated
6+
* Do not change it.
7+
*/
8+
9+
namespace Commercetools\Api\Test\Client\Resource;
10+
11+
use Commercetools\Api\Client\ApiRequestBuilder;
12+
use Commercetools\Base\JsonObject;
13+
use Commercetools\Client\ApiRequest;
14+
use Commercetools\Exception\ApiClientException;
15+
use Commercetools\Exception\ApiServerException;
16+
use GuzzleHttp\ClientInterface;
17+
use GuzzleHttp\Exception\ClientException;
18+
use GuzzleHttp\Exception\ServerException;
19+
use GuzzleHttp\Psr7\Response;
20+
use PHPUnit\Framework\TestCase;
21+
use Psr\Http\Message\RequestInterface;
22+
23+
/**
24+
* @covers \Commercetools\Api\Client\Resource\ByProjectKeyCartsCustomerIdByCustomerIdMergePost
25+
* @covers \Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge
26+
*/
27+
class ResourceByProjectKeyCartsCustomerIdByCustomerIdMergeTest extends TestCase
28+
{
29+
/**
30+
* @dataProvider getRequests()
31+
*/
32+
public function testBuilder(callable $builderFunction, string $method, string $relativeUri, ?string $body = null)
33+
{
34+
$builder = new ApiRequestBuilder();
35+
$request = $builderFunction($builder);
36+
$this->assertSame(strtolower($method), strtolower($request->getMethod()));
37+
$this->assertSame($relativeUri, (string) $request->getUri());
38+
if (!is_null($body)) {
39+
$this->assertJsonStringEqualsJsonString($body, (string) $request->getBody());
40+
} else {
41+
$this->assertSame("", (string) $request->getBody());
42+
}
43+
}
44+
45+
46+
47+
/**
48+
* @dataProvider getRequestBuilderResponses()
49+
*/
50+
public function testMapFromResponse(callable $builderFunction, $statusCode)
51+
{
52+
$builder = new ApiRequestBuilder();
53+
$request = $builderFunction($builder);
54+
$this->assertInstanceOf(ApiRequest::class, $request);
55+
56+
$response = new Response($statusCode, [], "{}");
57+
$this->assertInstanceOf(JsonObject::class, $request->mapFromResponse($response));
58+
}
59+
60+
/**
61+
* @dataProvider getRequestBuilders()
62+
*/
63+
public function testExecuteClientException(callable $builderFunction)
64+
{
65+
$client = $this->createMock(ClientInterface::class);
66+
67+
$builder = new ApiRequestBuilder($client);
68+
$request = $builderFunction($builder);
69+
$client->method("send")->willThrowException(new ClientException("Oops!", $request, new Response(400)));
70+
71+
$this->expectException(ApiClientException::class);
72+
$request->execute();
73+
}
74+
75+
/**
76+
* @dataProvider getRequestBuilders()
77+
*/
78+
public function testExecuteServerException(callable $builderFunction)
79+
{
80+
$client = $this->createMock(ClientInterface::class);
81+
82+
$builder = new ApiRequestBuilder($client);
83+
$request = $builderFunction($builder);
84+
$client->method("send")->willThrowException(new ServerException("Oops!", $request, new Response(500)));
85+
86+
$this->expectException(ApiServerException::class);
87+
$request->execute();
88+
}
89+
90+
public function getRequests()
91+
{
92+
return [
93+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost' => [
94+
function (ApiRequestBuilder $builder): RequestInterface {
95+
return $builder
96+
->withProjectKey("test_projectKey")
97+
->carts()
98+
->customerIdWithCustomerIdValueMerge("test_customerId")
99+
->post(null);
100+
},
101+
'post',
102+
'test_projectKey/carts/customer-id=test_customerId/merge',
103+
]
104+
];
105+
}
106+
107+
public function getResources()
108+
{
109+
return [
110+
];
111+
}
112+
113+
public function getRequestBuilders()
114+
{
115+
return [
116+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost' => [
117+
function (ApiRequestBuilder $builder): RequestInterface {
118+
return $builder
119+
->withProjectKey("projectKey")
120+
->carts()
121+
->customerIdWithCustomerIdValueMerge("customerId")
122+
->post(null);
123+
}
124+
]
125+
];
126+
}
127+
128+
public function getRequestBuilderResponses()
129+
{
130+
return [
131+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_200' => [
132+
function (ApiRequestBuilder $builder): RequestInterface {
133+
return $builder
134+
->withProjectKey("projectKey")
135+
->carts()
136+
->customerIdWithCustomerIdValueMerge("customerId")
137+
->post(null);
138+
},
139+
200
140+
],
141+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_400' => [
142+
function (ApiRequestBuilder $builder): RequestInterface {
143+
return $builder
144+
->withProjectKey("projectKey")
145+
->carts()
146+
->customerIdWithCustomerIdValueMerge("customerId")
147+
->post(null);
148+
},
149+
400
150+
],
151+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_401' => [
152+
function (ApiRequestBuilder $builder): RequestInterface {
153+
return $builder
154+
->withProjectKey("projectKey")
155+
->carts()
156+
->customerIdWithCustomerIdValueMerge("customerId")
157+
->post(null);
158+
},
159+
401
160+
],
161+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_403' => [
162+
function (ApiRequestBuilder $builder): RequestInterface {
163+
return $builder
164+
->withProjectKey("projectKey")
165+
->carts()
166+
->customerIdWithCustomerIdValueMerge("customerId")
167+
->post(null);
168+
},
169+
403
170+
],
171+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_404' => [
172+
function (ApiRequestBuilder $builder): RequestInterface {
173+
return $builder
174+
->withProjectKey("projectKey")
175+
->carts()
176+
->customerIdWithCustomerIdValueMerge("customerId")
177+
->post(null);
178+
},
179+
404
180+
],
181+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_500' => [
182+
function (ApiRequestBuilder $builder): RequestInterface {
183+
return $builder
184+
->withProjectKey("projectKey")
185+
->carts()
186+
->customerIdWithCustomerIdValueMerge("customerId")
187+
->post(null);
188+
},
189+
500
190+
],
191+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_502' => [
192+
function (ApiRequestBuilder $builder): RequestInterface {
193+
return $builder
194+
->withProjectKey("projectKey")
195+
->carts()
196+
->customerIdWithCustomerIdValueMerge("customerId")
197+
->post(null);
198+
},
199+
502
200+
],
201+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_503' => [
202+
function (ApiRequestBuilder $builder): RequestInterface {
203+
return $builder
204+
->withProjectKey("projectKey")
205+
->carts()
206+
->customerIdWithCustomerIdValueMerge("customerId")
207+
->post(null);
208+
},
209+
503
210+
],
211+
'ByProjectKeyCartsCustomerIdByCustomerIdMergePost_599' => [
212+
function (ApiRequestBuilder $builder): RequestInterface {
213+
return $builder
214+
->withProjectKey("projectKey")
215+
->carts()
216+
->customerIdWithCustomerIdValueMerge("customerId")
217+
->post(null);
218+
},
219+
599
220+
]
221+
];
222+
}
223+
}

lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyCartsTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Commercetools\Api\Client\ApiRequestBuilder;
1212
use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsByID;
1313
use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsCustomerIdByCustomerId;
14+
use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge;
1415
use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsKeyByKey;
1516
use Commercetools\Api\Client\Resource\ResourceByProjectKeyCartsReplicate;
1617
use Commercetools\Base\JsonObject;
@@ -262,6 +263,17 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyCartsCustomerIdByCust
262263
['projectKey' => 'test_projectKey', 'customerId' => 'test_customerId'],
263264
'/{projectKey}/carts/customer-id={customerId}'
264265
],
266+
'ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge' => [
267+
function (ApiRequestBuilder $builder): ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge {
268+
return $builder
269+
->withProjectKey("test_projectKey")
270+
->carts()
271+
->customerIdWithCustomerIdValueMerge("test_customerId");
272+
},
273+
ResourceByProjectKeyCartsCustomerIdByCustomerIdMerge::class,
274+
['projectKey' => 'test_projectKey', 'customerId' => 'test_customerId'],
275+
'/{projectKey}/carts/customer-id={customerId}/merge'
276+
],
265277
'ResourceByProjectKeyCartsKeyByKey' => [
266278
function (ApiRequestBuilder $builder): ResourceByProjectKeyCartsKeyByKey {
267279
return $builder

0 commit comments

Comments
 (0)