diff --git a/changes.md b/changes.md index a38616b8dff..2103f996302 100644 --- a/changes.md +++ b/changes.md @@ -1,5 +1,19 @@ **Api changes** +
+Added Enum(s) + +- added enum `ViewMyShoppingLists` to type `Permission` +- added enum `ViewOthersShoppingLists` to type `Permission` +- added enum `UpdateMyShoppingLists` to type `Permission` +- added enum `UpdateOthersShoppingLists` to type `Permission` +- added enum `CreateMyShoppingLists` to type `Permission` +- added enum `CreateOthersShoppingLists` to type `Permission` +- added enum `DeleteMyShoppingLists` to type `Permission` +- added enum `DeleteOthersShoppingLists` to type `Permission` +
+ +
Required Property(s) @@ -66,6 +80,9 @@
Added Resource(s) +- added resource `/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists` +- added resource `/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/key={key}` +- added resource `/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}` - added resource `/{projectKey}/business-units/key={key}/associates/{associateId}` - added resource `/{projectKey}/business-units/{businessUnitId}/associates/{associateId}` - added resource `/{projectKey}/in-store/key={storeKey}/business-units` @@ -79,6 +96,17 @@
Added Method(s) +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->get()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->head()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->post()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withKey()->get()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withKey()->head()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withKey()->post()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withKey()->delete()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withId()->get()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withId()->head()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withId()->post()` +- added method `$apiRoot->withProjectKey()->asAssociate()->withAssociateIdValue()->inBusinessUnitKeyWithBusinessUnitKeyValue()->shoppingLists()->withId()->delete()` - added method `$apiRoot->withProjectKey()->businessUnits()->keyWithKeyValueAssociatesWithAssociateIdValue()->get()` - added method `$apiRoot->withProjectKey()->businessUnits()->withBusinessUnitIdValueAssociatesWithAssociateIdValue()->get()` - added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->get()` diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDTest.php new file mode 100644 index 00000000000..e587d6c6090 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDTest.php @@ -0,0 +1,789 @@ +assertSame(strtolower($method), strtolower($request->getMethod())); + $this->assertSame($relativeUri, (string) $request->getUri()); + if (!is_null($body)) { + $this->assertJsonStringEqualsJsonString($body, (string) $request->getBody()); + } else { + $this->assertSame("", (string) $request->getBody()); + } + } + + + + /** + * @dataProvider getRequestBuilderResponses() + */ + public function testMapFromResponse(callable $builderFunction, $statusCode) + { + $builder = new ApiRequestBuilder(); + $request = $builderFunction($builder); + $this->assertInstanceOf(ApiRequest::class, $request); + + $response = new Response($statusCode, [], "{}"); + $this->assertInstanceOf(JsonObject::class, $request->mapFromResponse($response)); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteClientException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ClientException("Oops!", $request, new Response(400))); + + $this->expectException(ApiClientException::class); + $request->execute(); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteServerException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ServerException("Oops!", $request, new Response(500))); + + $this->expectException(ApiServerException::class); + $request->execute(); + } + + public function getRequests() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withId('test_ID') + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID?expand=expand', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withId("test_ID") + ->get(); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withId("test_ID") + ->head(); + }, + 'head', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withId('test_ID') + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID?expand=expand', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withId("test_ID") + ->post(null); + }, + 'post', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withId('test_ID') + ->delete() + ->withExpand('expand'); + }, + 'delete', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID?expand=expand', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_withDataErasure' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withId('test_ID') + ->delete() + ->withDataErasure('dataErasure'); + }, + 'delete', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID?dataErasure=dataErasure', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_withVersion' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withId('test_ID') + ->delete() + ->withVersion('version'); + }, + 'delete', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID?version=version', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withId("test_ID") + ->delete(); + }, + 'delete', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/test_ID', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + } + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + } + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + } + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); + }, + 599 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); + }, + 599 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 409 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); + }, + 599 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 409 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyTest.php new file mode 100644 index 00000000000..bfb840a4ca5 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyTest.php @@ -0,0 +1,789 @@ +assertSame(strtolower($method), strtolower($request->getMethod())); + $this->assertSame($relativeUri, (string) $request->getUri()); + if (!is_null($body)) { + $this->assertJsonStringEqualsJsonString($body, (string) $request->getBody()); + } else { + $this->assertSame("", (string) $request->getBody()); + } + } + + + + /** + * @dataProvider getRequestBuilderResponses() + */ + public function testMapFromResponse(callable $builderFunction, $statusCode) + { + $builder = new ApiRequestBuilder(); + $request = $builderFunction($builder); + $this->assertInstanceOf(ApiRequest::class, $request); + + $response = new Response($statusCode, [], "{}"); + $this->assertInstanceOf(JsonObject::class, $request->mapFromResponse($response)); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteClientException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ClientException("Oops!", $request, new Response(400))); + + $this->expectException(ApiClientException::class); + $request->execute(); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteServerException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ServerException("Oops!", $request, new Response(500))); + + $this->expectException(ApiServerException::class); + $request->execute(); + } + + public function getRequests() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withKey('test_key') + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key?expand=expand', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withKey("test_key") + ->get(); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withKey("test_key") + ->head(); + }, + 'head', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withKey('test_key') + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key?expand=expand', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withKey("test_key") + ->post(null); + }, + 'post', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withKey('test_key') + ->delete() + ->withExpand('expand'); + }, + 'delete', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key?expand=expand', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_withDataErasure' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withKey('test_key') + ->delete() + ->withDataErasure('dataErasure'); + }, + 'delete', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key?dataErasure=dataErasure', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_withVersion' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->withKey('test_key') + ->delete() + ->withVersion('version'); + }, + 'delete', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key?version=version', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withKey("test_key") + ->delete(); + }, + 'delete', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists/key=test_key', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + } + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + } + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + } + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); + }, + 599 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); + }, + 599 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 409 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); + }, + 599 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 409 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsTest.php new file mode 100644 index 00000000000..9f89761d260 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsTest.php @@ -0,0 +1,676 @@ +assertSame(strtolower($method), strtolower($request->getMethod())); + $this->assertSame($relativeUri, (string) $request->getUri()); + if (!is_null($body)) { + $this->assertJsonStringEqualsJsonString($body, (string) $request->getBody()); + } else { + $this->assertSame("", (string) $request->getBody()); + } + } + + /** + * @dataProvider getResources() + */ + public function testResources(callable $builderFunction, string $class, array $expectedArgs) + { + $builder = new ApiRequestBuilder(); + $resource = $builderFunction($builder); + $this->assertInstanceOf($class, $resource); + $this->assertEquals($expectedArgs, $resource->getArgs()); + } + + /** + * @dataProvider getRequestBuilderResponses() + */ + public function testMapFromResponse(callable $builderFunction, $statusCode) + { + $builder = new ApiRequestBuilder(); + $request = $builderFunction($builder); + $this->assertInstanceOf(ApiRequest::class, $request); + + $response = new Response($statusCode, [], "{}"); + $this->assertInstanceOf(JsonObject::class, $request->mapFromResponse($response)); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteClientException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ClientException("Oops!", $request, new Response(400))); + + $this->expectException(ApiClientException::class); + $request->execute(); + } + + /** + * @dataProvider getRequestBuilders() + */ + public function testExecuteServerException(callable $builderFunction) + { + $client = $this->createMock(ClientInterface::class); + + $builder = new ApiRequestBuilder($client); + $request = $builderFunction($builder); + $client->method("send")->willThrowException(new ServerException("Oops!", $request, new Response(500))); + + $this->expectException(ApiServerException::class); + $request->execute(); + } + + public function getRequests() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?expand=expand', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_withSort' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->get() + ->withSort('sort'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?sort=sort', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_withLimit' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->get() + ->withLimit('limit'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?limit=limit', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_withOffset' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->get() + ->withOffset('offset'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?offset=offset', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_withWithTotal' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->get() + ->withWithTotal('withTotal'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?withTotal=withTotal', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_withWhere' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->get() + ->withWhere('where'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?where=where', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_withPredicateVar' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->get() + ->withPredicateVar('varName', 'var.varName'); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?var.varName=var.varName', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->get(); + }, + 'get', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_withWhere' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->head() + ->withWhere('where'); + }, + 'head', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?where=where', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->head(); + }, + 'head', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->asAssociate() + ->withAssociateIdValue('test_associateId') + ->inBusinessUnitKeyWithBusinessUnitKeyValue('test_businessUnitKey') + ->shoppingLists() + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists?expand=expand', + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 'post', + 'test_projectKey/as-associate/test_associateId/in-business-unit/key=test_businessUnitKey/shopping-lists', + ] + ]; + } + + public function getResources() + { + return [ + 'ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKey' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKey { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withKey("test_key"); + }, + ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKey::class, + ['projectKey' => 'test_projectKey', 'associateId' => 'test_associateId', 'businessUnitKey' => 'test_businessUnitKey', 'key' => 'test_key'], + '/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/key={key}' + ], + 'ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByID' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByID { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists() + ->withId("test_ID"); + }, + ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByID::class, + ['projectKey' => 'test_projectKey', 'associateId' => 'test_associateId', 'businessUnitKey' => 'test_businessUnitKey', 'ID' => 'test_ID'], + '/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}' + ] + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + } + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + } + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); + }, + 599 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 200 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); + }, + 599 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_201' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 201 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 400 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 401 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 403 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 404 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 500 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 502 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 503 + ], + 'ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyTest.php index 8cbd06dff41..1b841083bf2 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyTest.php @@ -15,6 +15,7 @@ use Commercetools\Api\Client\Resource\ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrders; use Commercetools\Api\Client\Resource\ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuoteRequests; use Commercetools\Api\Client\Resource\ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyQuotes; +use Commercetools\Api\Client\Resource\ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists; use Commercetools\Base\JsonObject; use Commercetools\Client\ApiRequest; use Commercetools\Exception\ApiClientException; @@ -96,6 +97,19 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyAsAssociateByAssociat ['projectKey' => 'test_projectKey', 'associateId' => 'test_associateId', 'businessUnitKey' => 'test_businessUnitKey'], '/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/carts' ], + 'ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists { + return $builder + ->withProjectKey("test_projectKey") + ->asAssociate() + ->withAssociateIdValue("test_associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("test_businessUnitKey") + ->shoppingLists(); + }, + ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists::class, + ['projectKey' => 'test_projectKey', 'associateId' => 'test_associateId', 'businessUnitKey' => 'test_businessUnitKey'], + '/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists' + ], 'ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrders' => [ function (ApiRequestBuilder $builder): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrders { return $builder diff --git a/lib/commercetools-api/docs/RequestBuilder.md b/lib/commercetools-api/docs/RequestBuilder.md index f68e360f383..59188ce1b83 100644 --- a/lib/commercetools-api/docs/RequestBuilder.md +++ b/lib/commercetools-api/docs/RequestBuilder.md @@ -1193,6 +1193,211 @@ $request = $builder ->withKey("key") ->post(null); ``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->get()` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->get(); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->head()` + +Checks if a ShoppingList exists for a given Query Predicate. Returns a `200 OK` if any ShoppingLists match the Query Predicate; otherwise, returns a [ResourceNotFound](ctp:api:type:ResourceNotFoundError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->head(); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->post(null)` + +Creates a ShoppingList in the [BusinessUnit](ctp:api:type:BusinessUnit) referenced by `businessUnitKey`. As such, the `businessUnit` field on [ShoppingListDraft](ctp:api:type:ShoppingListDraft) is ignored for this request. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->post(null); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->withId("ID")->get()` + +If the ShoppingList exists in the Project but does not reference the requested [BusinessUnit](ctp:api:type:BusinessUnit), this method returns an [InvalidOperation](ctp:api:type:InvalidOperationError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->get(); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->withId("ID")->head()` + +Checks if a ShoppingList exists for a given `id`. Returns a `200 OK` if the ShoppingList exists; otherwise, returns a [ResourceNotFound](ctp:api:type:ResourceNotFoundError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->head(); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->withId("ID")->post(null)` + +If the ShoppingList exists in the Project but does not reference the requested [BusinessUnit](ctp:api:type:BusinessUnit), this method returns an [InvalidOperation](ctp:api:type:InvalidOperationError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->post(null); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->withId("ID")->delete()` + +If the ShoppingList exists in the Project but does not reference the requested [BusinessUnit](ctp:api:type:BusinessUnit), this method returns an [InvalidOperation](ctp:api:type:InvalidOperationError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withId("ID") + ->delete(); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->withKey("key")->get()` + +If the ShoppingList exists in the Project but does not reference the requested [BusinessUnit](ctp:api:type:BusinessUnit), this method returns an [InvalidOperation](ctp:api:type:InvalidOperationError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->get(); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->withKey("key")->head()` + +Checks if a ShoppingList exists for a given `key`. Returns a `200 OK` if the ShoppingList exists; otherwise, returns a [ResourceNotFound](ctp:api:type:ResourceNotFoundError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->head(); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->withKey("key")->post(null)` + +If the Shopping List exists in the [Project](ctp:api:type:Project) but does not reference the requested [BusinessUnit](ctp:api:type:BusinessUnit), this method returns an [InvalidOperation](ctp:api:type:InvalidOperationError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->post(null); +``` +## `withProjectKey("projectKey")->asAssociate()->withAssociateIdValue("associateId")->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey")->shoppingLists()->withKey("key")->delete()` + +If the ShoppingList exists in the Project but does not reference the requested [BusinessUnit](ctp:api:type:BusinessUnit), this method returns an [InvalidOperation](ctp:api:type:InvalidOperationError) error. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->asAssociate() + ->withAssociateIdValue("associateId") + ->inBusinessUnitKeyWithBusinessUnitKeyValue("businessUnitKey") + ->shoppingLists() + ->withKey("key") + ->delete(); +``` ## `withProjectKey("projectKey")->associateRoles()->get()` null diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete.php new file mode 100644 index 00000000000..1af6aec8c11 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete.php @@ -0,0 +1,180 @@ + + * @template-implements Versioned + * @template-implements Conflicting + * @template-implements Expandable + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete extends ApiRequest implements DataErasure, Versioned, Conflicting, Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}', '{ID}'], [$projectKey, $associateId, $businessUnitKey, $ID], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}'); + parent::__construct($client, 'DELETE', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|ShoppingList|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = ShoppingListModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject|ShoppingList + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete + { + return $this->withQueryParam('expand', $expand); + } + + /** + * + * @psalm-param scalar|scalar[] $dataErasure + */ + public function withDataErasure($dataErasure): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete + { + return $this->withQueryParam('dataErasure', $dataErasure); + } + + /** + * + * @psalm-param scalar|scalar[] $version + */ + public function withVersion($version): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete + { + return $this->withQueryParam('version', $version); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet.php new file mode 100644 index 00000000000..7314285f3eb --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet.php @@ -0,0 +1,155 @@ + + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet extends ApiRequest implements Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}', '{ID}'], [$projectKey, $associateId, $businessUnitKey, $ID], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|ShoppingList|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = ShoppingListModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject|ShoppingList + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead.php new file mode 100644 index 00000000000..499a3c89d2f --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}', '{ID}'], [$projectKey, $associateId, $businessUnitKey, $ID], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost.php new file mode 100644 index 00000000000..324bc1ace90 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable200 + * @template-implements Errorable + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost extends ApiRequest implements Conflicting, Expandable, Deprecatable200, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, string $ID, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}', '{ID}'], [$projectKey, $associateId, $businessUnitKey, $ID], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}'); + parent::__construct($client, 'POST', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|ShoppingList|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = ShoppingListModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject|ShoppingList + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet.php new file mode 100644 index 00000000000..dd3493f2781 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet.php @@ -0,0 +1,212 @@ + + * @template-implements Sortable + * @template-implements Paging + * @template-implements Query + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet extends ApiRequest implements Expandable, Sortable, Paging, Query, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}'], [$projectKey, $associateId, $businessUnitKey], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|ShoppingListPagedQueryResponse|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = ShoppingListPagedQueryResponseModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject|ShoppingListPagedQueryResponse + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet + { + return $this->withQueryParam('expand', $expand); + } + + /** + * + * @psalm-param scalar|scalar[] $sort + */ + public function withSort($sort): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet + { + return $this->withQueryParam('sort', $sort); + } + + /** + * + * @psalm-param scalar|scalar[] $limit + */ + public function withLimit($limit): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet + { + return $this->withQueryParam('limit', $limit); + } + + /** + * + * @psalm-param scalar|scalar[] $offset + */ + public function withOffset($offset): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet + { + return $this->withQueryParam('offset', $offset); + } + + /** + * + * @psalm-param scalar|scalar[] $withTotal + */ + public function withWithTotal($withTotal): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet + { + return $this->withQueryParam('withTotal', $withTotal); + } + + /** + * + * @psalm-param scalar|scalar[] $where + */ + public function withWhere($where): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet + { + return $this->withQueryParam('where', $where); + } + + /** + * @psalm-param string $varName + * @psalm-param scalar|scalar[] $predicateVar + */ + public function withPredicateVar(string $varName, $predicateVar): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet + { + return $this->withQueryParam(sprintf('var.%s', $varName), $predicateVar); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead.php new file mode 100644 index 00000000000..e4081d3c292 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead.php @@ -0,0 +1,148 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}'], [$projectKey, $associateId, $businessUnitKey], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $where + */ + public function withWhere($where): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead + { + return $this->withQueryParam('where', $where); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete.php new file mode 100644 index 00000000000..4d7404d4138 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete.php @@ -0,0 +1,180 @@ + + * @template-implements Versioned + * @template-implements Conflicting + * @template-implements Expandable + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete extends ApiRequest implements DataErasure, Versioned, Conflicting, Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}', '{key}'], [$projectKey, $associateId, $businessUnitKey, $key], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/key={key}'); + parent::__construct($client, 'DELETE', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|ShoppingList|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = ShoppingListModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject|ShoppingList + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete + { + return $this->withQueryParam('expand', $expand); + } + + /** + * + * @psalm-param scalar|scalar[] $dataErasure + */ + public function withDataErasure($dataErasure): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete + { + return $this->withQueryParam('dataErasure', $dataErasure); + } + + /** + * + * @psalm-param scalar|scalar[] $version + */ + public function withVersion($version): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete + { + return $this->withQueryParam('version', $version); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet.php new file mode 100644 index 00000000000..616c52a454b --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet.php @@ -0,0 +1,155 @@ + + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet extends ApiRequest implements Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}', '{key}'], [$projectKey, $associateId, $businessUnitKey, $key], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/key={key}'); + parent::__construct($client, 'GET', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|ShoppingList|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = ShoppingListModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject|ShoppingList + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead.php new file mode 100644 index 00000000000..e210cfb6bec --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}', '{key}'], [$projectKey, $associateId, $businessUnitKey, $key], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/key={key}'); + parent::__construct($client, 'HEAD', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost.php new file mode 100644 index 00000000000..ba363e518da --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable200 + * @template-implements Errorable + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost extends ApiRequest implements Conflicting, Expandable, Deprecatable200, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, string $key, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}', '{key}'], [$projectKey, $associateId, $businessUnitKey, $key], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/key={key}'); + parent::__construct($client, 'POST', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|ShoppingList|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '200': + $resultType = ShoppingListModel::class; + + break; + case '409': + $resultType = ErrorResponseModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject|ShoppingList + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost.php new file mode 100644 index 00000000000..f81bb422aec --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost.php @@ -0,0 +1,155 @@ + + * @template-implements Deprecatable201 + * @template-implements Errorable + */ +class ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost extends ApiRequest implements Expandable, Deprecatable201, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $associateId, string $businessUnitKey, $body = null, array $headers = [], ?ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{associateId}', '{businessUnitKey}'], [$projectKey, $associateId, $businessUnitKey], '{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists'); + parent::__construct($client, 'POST', $uri, $headers, is_object($body) || is_array($body) ? json_encode($body) : $body); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * @return ErrorResponse|JsonObject|ShoppingList|T|null + */ + public function mapFromResponse(?ResponseInterface $response, ?string $resultType = null) + { + if (is_null($response)) { + return null; + } + if (is_null($resultType)) { + switch ($response->getStatusCode()) { + case '201': + $resultType = ShoppingListModel::class; + + break; + case '400': + $resultType = ErrorResponseModel::class; + + break; + case '401': + $resultType = ErrorResponseModel::class; + + break; + case '403': + $resultType = ErrorResponseModel::class; + + break; + case '500': + $resultType = ErrorResponseModel::class; + + break; + case '502': + $resultType = ErrorResponseModel::class; + + break; + case '503': + $resultType = ErrorResponseModel::class; + + break; + default: + $resultType = JsonObjectModel::class; + + break; + } + } + + return $resultType::of($this->responseData($response)); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return null|T|ErrorResponse|JsonObject|ShoppingList + */ + public function execute(array $options = [], ?string $resultType = null) + { + try { + $response = $this->send($options); + } catch (ServerException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } catch (ClientException $e) { + $response = $e->getResponse(); + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + throw $e; + } + + return $this->mapFromResponse($response, $resultType); + } + + /** + * @template T of JsonObject + * @psalm-param ?class-string $resultType + * + * @return PromiseInterface + */ + public function executeAsync(array $options = [], ?string $resultType = null) + { + return $this->sendAsync($options)->then( + function (ResponseInterface $response) use ($resultType) { + return $this->mapFromResponse($response, $resultType); + }, + function (RequestException $e) use ($resultType) { + $response = $e->getResponse(); + if ($e instanceof ServerException) { + $e = ExceptionFactory::createServerException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + if ($e instanceof ClientException) { + $e = ExceptionFactory::createClientException($e, $this, $response, $this->mapFromResponse($response, $resultType)); + } + throw $e; + } + ); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKey.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKey.php index a256a159d83..5d38f5d4c72 100644 --- a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKey.php +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKey.php @@ -49,6 +49,14 @@ public function carts(): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessU return new ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyCarts($args, $this->getClient()); } + /** + */ + public function shoppingLists(): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists + { + $args = $this->getArgs(); + + return new ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists($args, $this->getClient()); + } /** */ public function orders(): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyOrders diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists.php new file mode 100644 index 00000000000..615600e103c --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingLists.php @@ -0,0 +1,82 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists', $args, $client); + } + + /** + */ + public function withKey(?string $key = null): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKey + { + $args = $this->getArgs(); + if (!is_null($key)) { + $args['key'] = $key; + } + + return new ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKey($args, $this->getClient()); + } + /** + */ + public function withId(?string $ID = null): ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByID + { + $args = $this->getArgs(); + if (!is_null($ID)) { + $args['ID'] = $ID; + } + + return new ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByID($args, $this->getClient()); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsGet($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsHead($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?ShoppingListDraft $body + * @psalm-param array $headers + */ + public function post(?ShoppingListDraft $body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsPost($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByID.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByID.php new file mode 100644 index 00000000000..4a0dd0fe790 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByID.php @@ -0,0 +1,69 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/{ID}', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDGet($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDHead($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?ShoppingListUpdate $body + * @psalm-param array $headers + */ + public function post(?ShoppingListUpdate $body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDPost($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function delete($body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsByIDDelete($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $args['ID'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKey.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKey.php new file mode 100644 index 00000000000..b2612d5b5f5 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKey.php @@ -0,0 +1,69 @@ + $args + */ + public function __construct(array $args = [], ?ClientInterface $client = null) + { + parent::__construct('/{projectKey}/as-associate/{associateId}/in-business-unit/key={businessUnitKey}/shopping-lists/key={key}', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyGet($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyHead($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?ShoppingListUpdate $body + * @psalm-param array $headers + */ + public function post(?ShoppingListUpdate $body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyPost($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function delete($body = null, array $headers = []): ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete + { + $args = $this->getArgs(); + + return new ByProjectKeyAsAssociateByAssociateIdInBusinessUnitKeyByBusinessUnitKeyShoppingListsKeyByKeyDelete($args['projectKey'], $args['associateId'], $args['businessUnitKey'], $args['key'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php index 7d30f83cdb5..0610c407fac 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php @@ -110,8 +110,8 @@ public function getStatus(); /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php index f9cd0e4d831..c1d7f7083be 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php @@ -271,8 +271,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraft.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraft.php index 24372e3d667..b67d7916966 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraft.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraft.php @@ -53,8 +53,8 @@ public function getStatus(); /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftBuilder.php index c9ac1f4eaca..f4435c8a34c 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftBuilder.php @@ -139,8 +139,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftModel.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftModel.php index 94ab77f886a..1c6f0c23e1b 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitDraftModel.php @@ -211,8 +211,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php index 174ec6b907a..3cc8a5f51a1 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php @@ -427,8 +427,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php index e10498468a3..db9212c9783 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php @@ -269,8 +269,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftBuilder.php index 8ff870fec10..d89c9c0cf63 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftBuilder.php @@ -139,8 +139,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftModel.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftModel.php index 6b2647ebe17..a9ed29b3795 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyDraftModel.php @@ -203,8 +203,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php index 87bfc546671..a2eb8f41946 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php @@ -417,8 +417,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php index 97b264e1397..8b16e9e21f3 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php @@ -269,8 +269,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreKeyReferenceCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftBuilder.php index c444a1f0b80..a8f852be33b 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftBuilder.php @@ -145,8 +145,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftModel.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftModel.php index 2165c4c4409..9d13cbbbb52 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionDraftModel.php @@ -211,8 +211,8 @@ public function getStatus() /** *

Sets the Stores the Business Unit is associated with. Can only be set when storeMode is Explicit. * Defaults to empty for Companies and not set for Divisions.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreResourceIdentifierCollection diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php index f4d0ec684a1..3d5ae6781e1 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php @@ -417,8 +417,8 @@ public function getStatus() /** *

References to Stores the Business Unit is associated with. Only present when storeMode is Explicit.

- *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, or Quote Requests must belong to one of the Business Unit's Stores.

- *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, or Quote Requests must not belong to any Store.

+ *

If the Business Unit has Stores defined, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must belong to one of the Business Unit's Stores.

+ *

If the Business Unit has no Stores, then all of its Carts, Orders, Quotes, Quote Requests, or Shopping Lists must not belong to any Store.

* * * @return null|StoreKeyReferenceCollection diff --git a/references.txt b/references.txt index 0083b0ff912..8eea0bef1d6 100644 --- a/references.txt +++ b/references.txt @@ -373,3 +373,4 @@ be04b8a13c612b3eed8290dd00b81c2ebe16e5ed 1d236d1f41e836083ad6ac1aa381b61f70f50074 e2594613d04733e91fe77848b55c73f255fac743 d6a0c240644648d19c9880bc8eb48f961165dfec +020bd279b2cc54072bf692d0654c883d73ade338