diff --git a/changes.md b/changes.md index c2f8369d30e..0900bdd1775 100644 --- a/changes.md +++ b/changes.md @@ -1,3 +1,39 @@ +**Api changes** + +
+Added Resource(s) + +- added resource `/{projectKey}/in-store/key={storeKey}/business-units` +- added resource `/{projectKey}/in-store/key={storeKey}/business-units/key={key}` +- added resource `/{projectKey}/in-store/key={storeKey}/business-units/{ID}` +
+ + +
+Added Method(s) + +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->get()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->head()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->post()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withKey()->get()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withKey()->head()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withKey()->post()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withKey()->delete()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withId()->get()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withId()->head()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withId()->post()` +- added method `$apiRoot->withProjectKey()->inStoreKeyWithStoreKeyValue()->businessUnits()->withId()->delete()` +
+ + +
+Added Property(s) + +- added property `inheritedStores` to type `BusinessUnit` +- added property `inheritedStores` to type `Company` +- added property `inheritedStores` to type `Division` +
+ **History changes**
diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDTest.php new file mode 100644 index 00000000000..0191bd02597 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDTest.php @@ -0,0 +1,674 @@ +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 [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->withId('test_ID') + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units/test_ID?expand=expand', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withId("test_ID") + ->get(); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units/test_ID', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withId("test_ID") + ->head(); + }, + 'head', + 'test_projectKey/in-store/key=test_storeKey/business-units/test_ID', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->withId('test_ID') + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/in-store/key=test_storeKey/business-units/test_ID?expand=expand', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withId("test_ID") + ->post(null); + }, + 'post', + 'test_projectKey/in-store/key=test_storeKey/business-units/test_ID', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_withVersion' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->withId('test_ID') + ->delete() + ->withVersion('version'); + }, + 'delete', + 'test_projectKey/in-store/key=test_storeKey/business-units/test_ID?version=version', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->withId('test_ID') + ->delete() + ->withExpand('expand'); + }, + 'delete', + 'test_projectKey/in-store/key=test_storeKey/business-units/test_ID?expand=expand', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withId("test_ID") + ->delete(); + }, + 'delete', + 'test_projectKey/in-store/key=test_storeKey/business-units/test_ID', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + } + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + } + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + } + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); + }, + 599 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); + }, + 599 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 409 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); + }, + 599 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 409 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyTest.php new file mode 100644 index 00000000000..d29a69ec136 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyTest.php @@ -0,0 +1,674 @@ +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 [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->withKey('test_key') + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units/key=test_key?expand=expand', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withKey("test_key") + ->get(); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units/key=test_key', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withKey("test_key") + ->head(); + }, + 'head', + 'test_projectKey/in-store/key=test_storeKey/business-units/key=test_key', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->withKey('test_key') + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/in-store/key=test_storeKey/business-units/key=test_key?expand=expand', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withKey("test_key") + ->post(null); + }, + 'post', + 'test_projectKey/in-store/key=test_storeKey/business-units/key=test_key', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_withVersion' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->withKey('test_key') + ->delete() + ->withVersion('version'); + }, + 'delete', + 'test_projectKey/in-store/key=test_storeKey/business-units/key=test_key?version=version', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->withKey('test_key') + ->delete() + ->withExpand('expand'); + }, + 'delete', + 'test_projectKey/in-store/key=test_storeKey/business-units/key=test_key?expand=expand', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withKey("test_key") + ->delete(); + }, + 'delete', + 'test_projectKey/in-store/key=test_storeKey/business-units/key=test_key', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + } + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + } + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + } + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); + }, + 599 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); + }, + 599 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 409 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); + }, + 599 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 409 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsTest.php new file mode 100644 index 00000000000..548d4768a62 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsTest.php @@ -0,0 +1,588 @@ +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 [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->get() + ->withExpand('expand'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units?expand=expand', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_withSort' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->get() + ->withSort('sort'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units?sort=sort', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_withLimit' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->get() + ->withLimit('limit'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units?limit=limit', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_withOffset' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->get() + ->withOffset('offset'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units?offset=offset', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_withWithTotal' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->get() + ->withWithTotal('withTotal'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units?withTotal=withTotal', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_withWhere' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->get() + ->withWhere('where'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units?where=where', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_withPredicateVar' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->get() + ->withPredicateVar('varName', 'var.varName'); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units?var.varName=var.varName', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->get(); + }, + 'get', + 'test_projectKey/in-store/key=test_storeKey/business-units', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_withWhere' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->head() + ->withWhere('where'); + }, + 'head', + 'test_projectKey/in-store/key=test_storeKey/business-units?where=where', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->head(); + }, + 'head', + 'test_projectKey/in-store/key=test_storeKey/business-units', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_withExpand' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey('test_projectKey') + ->inStoreKeyWithStoreKeyValue('test_storeKey') + ->businessUnits() + ->post(null) + ->withExpand('expand'); + }, + 'post', + 'test_projectKey/in-store/key=test_storeKey/business-units?expand=expand', + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->post(null); + }, + 'post', + 'test_projectKey/in-store/key=test_storeKey/business-units', + ] + ]; + } + + public function getResources() + { + return [ + 'ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKey' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKey { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withKey("test_key"); + }, + ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKey::class, + ['projectKey' => 'test_projectKey', 'storeKey' => 'test_storeKey', 'key' => 'test_key'], + '/{projectKey}/in-store/key={storeKey}/business-units/key={key}' + ], + 'ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByID' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByID { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits() + ->withId("test_ID"); + }, + ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByID::class, + ['projectKey' => 'test_projectKey', 'storeKey' => 'test_storeKey', 'ID' => 'test_ID'], + '/{projectKey}/in-store/key={storeKey}/business-units/{ID}' + ] + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + } + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + } + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); + }, + 599 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 200 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); + }, + 599 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_201' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 201 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 400 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 401 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 403 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 404 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 500 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 502 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 503 + ], + 'ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyTest.php index 7e82e3464ad..e6cb5943300 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyTest.php @@ -9,6 +9,7 @@ namespace Commercetools\Api\Test\Client\Resource; use Commercetools\Api\Client\ApiRequestBuilder; +use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits; use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyCartDiscounts; use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyCarts; use Commercetools\Api\Client\Resource\ResourceByProjectKeyInStoreKeyByStoreKeyCustomers; @@ -230,6 +231,17 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyInStoreKeyByStoreKeyQ ResourceByProjectKeyInStoreKeyByStoreKeyQuotes::class, ['projectKey' => 'test_projectKey', 'storeKey' => 'test_storeKey'], '/{projectKey}/in-store/key={storeKey}/quotes' + ], + 'ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits { + return $builder + ->withProjectKey("test_projectKey") + ->inStoreKeyWithStoreKeyValue("test_storeKey") + ->businessUnits(); + }, + ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits::class, + ['projectKey' => 'test_projectKey', 'storeKey' => 'test_storeKey'], + '/{projectKey}/in-store/key={storeKey}/business-units' ] ]; } diff --git a/lib/commercetools-api/docs/RequestBuilder.md b/lib/commercetools-api/docs/RequestBuilder.md index 4e509688ee7..84ed2aeeee7 100644 --- a/lib/commercetools-api/docs/RequestBuilder.md +++ b/lib/commercetools-api/docs/RequestBuilder.md @@ -3402,6 +3402,179 @@ $request = $builder ->customers() ->post(null); ``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->get()` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->get(); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->head()` + +Checks if a BusinessUnit exists for a given Query Predicate. Returns a `200 OK` status if any BusinessUnits match the Query Predicate or a `404 Not Found` otherwise. + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->head(); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->post(null)` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->post(null); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->withId("ID")->get()` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->get(); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->withId("ID")->head()` + +Checks if a BusinessUnit exists for a given `id`. Returns a `200 OK` status if the BusinessUnit exists or a `404 Not Found` otherwise. + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->head(); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->withId("ID")->post(null)` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->post(null); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->withId("ID")->delete()` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withId("ID") + ->delete(); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->withKey("key")->get()` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->get(); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->withKey("key")->head()` + +Checks if a BusinessUnit exists for a given `key`. Returns a `200 OK` status if the BusinessUnit exists or a `404 Not Found` otherwise. + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->head(); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->withKey("key")->post(null)` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->post(null); +``` +## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->businessUnits()->withKey("key")->delete()` + +null + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->inStoreKeyWithStoreKeyValue("storeKey") + ->businessUnits() + ->withKey("key") + ->delete(); +``` ## `withProjectKey("projectKey")->inStoreKeyWithStoreKeyValue("storeKey")->cartDiscounts()->get()` null diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete.php new file mode 100644 index 00000000000..4cd204898e5 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete.php @@ -0,0 +1,170 @@ + + * @template-implements Conflicting + * @template-implements Expandable + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete extends ApiRequest implements Versioned, Conflicting, Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $ID, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{ID}'], [$projectKey, $storeKey, $ID], '{projectKey}/in-store/key={storeKey}/business-units/{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 BusinessUnit|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 '200': + $resultType = BusinessUnitModel::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|BusinessUnit|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[] $version + */ + public function withVersion($version): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete + { + return $this->withQueryParam('version', $version); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet.php new file mode 100644 index 00000000000..649b6b037ca --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet.php @@ -0,0 +1,155 @@ + + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet extends ApiRequest implements Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $ID, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{ID}'], [$projectKey, $storeKey, $ID], '{projectKey}/in-store/key={storeKey}/business-units/{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 BusinessUnit|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 '200': + $resultType = BusinessUnitModel::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|BusinessUnit|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[] $expand + */ + public function withExpand($expand): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead.php new file mode 100644 index 00000000000..c00110de788 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $ID, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{ID}'], [$projectKey, $storeKey, $ID], '{projectKey}/in-store/key={storeKey}/business-units/{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/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost.php new file mode 100644 index 00000000000..68f77f5fc1d --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable200 + * @template-implements Errorable + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost extends ApiRequest implements Conflicting, Expandable, Deprecatable200, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $ID, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{ID}'], [$projectKey, $storeKey, $ID], '{projectKey}/in-store/key={storeKey}/business-units/{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 BusinessUnit|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 '200': + $resultType = BusinessUnitModel::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|BusinessUnit|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[] $expand + */ + public function withExpand($expand): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet.php new file mode 100644 index 00000000000..51ae1ae03ee --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet.php @@ -0,0 +1,212 @@ + + * @template-implements Sortable + * @template-implements Paging + * @template-implements Query + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet extends ApiRequest implements Expandable, Sortable, Paging, Query, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}'], [$projectKey, $storeKey], '{projectKey}/in-store/key={storeKey}/business-units'); + 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 BusinessUnitPagedQueryResponse|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 '200': + $resultType = BusinessUnitPagedQueryResponseModel::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|BusinessUnitPagedQueryResponse|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[] $expand + */ + public function withExpand($expand): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet + { + return $this->withQueryParam('expand', $expand); + } + + /** + * + * @psalm-param scalar|scalar[] $sort + */ + public function withSort($sort): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet + { + return $this->withQueryParam('sort', $sort); + } + + /** + * + * @psalm-param scalar|scalar[] $limit + */ + public function withLimit($limit): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet + { + return $this->withQueryParam('limit', $limit); + } + + /** + * + * @psalm-param scalar|scalar[] $offset + */ + public function withOffset($offset): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet + { + return $this->withQueryParam('offset', $offset); + } + + /** + * + * @psalm-param scalar|scalar[] $withTotal + */ + public function withWithTotal($withTotal): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet + { + return $this->withQueryParam('withTotal', $withTotal); + } + + /** + * + * @psalm-param scalar|scalar[] $where + */ + public function withWhere($where): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet + { + return $this->withQueryParam('where', $where); + } + + /** + * @psalm-param string $varName + * @psalm-param scalar|scalar[] $predicateVar + */ + public function withPredicateVar(string $varName, $predicateVar): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet + { + return $this->withQueryParam(sprintf('var.%s', $varName), $predicateVar); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead.php new file mode 100644 index 00000000000..5df76def2a0 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead.php @@ -0,0 +1,148 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}'], [$projectKey, $storeKey], '{projectKey}/in-store/key={storeKey}/business-units'); + 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): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead + { + return $this->withQueryParam('where', $where); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete.php new file mode 100644 index 00000000000..8ff2ae9782e --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete.php @@ -0,0 +1,170 @@ + + * @template-implements Conflicting + * @template-implements Expandable + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete extends ApiRequest implements Versioned, Conflicting, Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $key, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{key}'], [$projectKey, $storeKey, $key], '{projectKey}/in-store/key={storeKey}/business-units/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 BusinessUnit|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 '200': + $resultType = BusinessUnitModel::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|BusinessUnit|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[] $version + */ + public function withVersion($version): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete + { + return $this->withQueryParam('version', $version); + } + + /** + * + * @psalm-param scalar|scalar[] $expand + */ + public function withExpand($expand): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet.php new file mode 100644 index 00000000000..5fe9db25e5b --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet.php @@ -0,0 +1,155 @@ + + * @template-implements Errorable + * @template-implements Deprecatable200 + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet extends ApiRequest implements Expandable, Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $key, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{key}'], [$projectKey, $storeKey, $key], '{projectKey}/in-store/key={storeKey}/business-units/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 BusinessUnit|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 '200': + $resultType = BusinessUnitModel::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|BusinessUnit|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[] $expand + */ + public function withExpand($expand): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead.php new file mode 100644 index 00000000000..5116a4384ef --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $key, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{key}'], [$projectKey, $storeKey, $key], '{projectKey}/in-store/key={storeKey}/business-units/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/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost.php new file mode 100644 index 00000000000..85b413c3f86 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost.php @@ -0,0 +1,160 @@ + + * @template-implements Expandable + * @template-implements Deprecatable200 + * @template-implements Errorable + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost extends ApiRequest implements Conflicting, Expandable, Deprecatable200, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, string $key, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}', '{key}'], [$projectKey, $storeKey, $key], '{projectKey}/in-store/key={storeKey}/business-units/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 BusinessUnit|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 '200': + $resultType = BusinessUnitModel::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|BusinessUnit|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[] $expand + */ + public function withExpand($expand): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost.php new file mode 100644 index 00000000000..0ac91f816fd --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost.php @@ -0,0 +1,155 @@ + + * @template-implements Deprecatable201 + * @template-implements Errorable + */ +class ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost extends ApiRequest implements Expandable, Deprecatable201, Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, string $storeKey, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}', '{storeKey}'], [$projectKey, $storeKey], '{projectKey}/in-store/key={storeKey}/business-units'); + 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 BusinessUnit|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 '201': + $resultType = BusinessUnitModel::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|BusinessUnit|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[] $expand + */ + public function withExpand($expand): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost + { + return $this->withQueryParam('expand', $expand); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKey.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKey.php index a40bd5e4d0f..a90de2a4eb6 100644 --- a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKey.php +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKey.php @@ -145,4 +145,12 @@ public function quotes(): ResourceByProjectKeyInStoreKeyByStoreKeyQuotes return new ResourceByProjectKeyInStoreKeyByStoreKeyQuotes($args, $this->getClient()); } + /** + */ + public function businessUnits(): ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits + { + $args = $this->getArgs(); + + return new ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits($args, $this->getClient()); + } } diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits.php new file mode 100644 index 00000000000..c52804108c7 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnits.php @@ -0,0 +1,82 @@ + $args + */ + public function __construct(array $args = [], ClientInterface $client = null) + { + parent::__construct('/{projectKey}/in-store/key={storeKey}/business-units', $args, $client); + } + + /** + */ + public function withKey(string $key = null): ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKey + { + $args = $this->getArgs(); + if (!is_null($key)) { + $args['key'] = $key; + } + + return new ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKey($args, $this->getClient()); + } + /** + */ + public function withId(string $ID = null): ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByID + { + $args = $this->getArgs(); + if (!is_null($ID)) { + $args['ID'] = $ID; + } + + return new ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByID($args, $this->getClient()); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsGet($args['projectKey'], $args['storeKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsHead($args['projectKey'], $args['storeKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?BusinessUnitDraft $body + * @psalm-param array $headers + */ + public function post(?BusinessUnitDraft $body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsPost($args['projectKey'], $args['storeKey'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByID.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByID.php new file mode 100644 index 00000000000..2b9c291cd23 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByID.php @@ -0,0 +1,69 @@ + $args + */ + public function __construct(array $args = [], ClientInterface $client = null) + { + parent::__construct('/{projectKey}/in-store/key={storeKey}/business-units/{ID}', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDGet($args['projectKey'], $args['storeKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDHead($args['projectKey'], $args['storeKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?BusinessUnitUpdate $body + * @psalm-param array $headers + */ + public function post(?BusinessUnitUpdate $body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDPost($args['projectKey'], $args['storeKey'], $args['ID'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function delete($body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsByIDDelete($args['projectKey'], $args['storeKey'], $args['ID'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKey.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKey.php new file mode 100644 index 00000000000..5d86f0d4129 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKey.php @@ -0,0 +1,69 @@ + $args + */ + public function __construct(array $args = [], ClientInterface $client = null) + { + parent::__construct('/{projectKey}/in-store/key={storeKey}/business-units/key={key}', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyGet($args['projectKey'], $args['storeKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyHead($args['projectKey'], $args['storeKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?BusinessUnitUpdate $body + * @psalm-param array $headers + */ + public function post(?BusinessUnitUpdate $body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyPost($args['projectKey'], $args['storeKey'], $args['key'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function delete($body = null, array $headers = []): ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete + { + $args = $this->getArgs(); + + return new ByProjectKeyInStoreKeyByStoreKeyBusinessUnitsKeyByKeyDelete($args['projectKey'], $args['storeKey'], $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 4708ee63f1a..7d30f83cdb5 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnit.php @@ -26,6 +26,7 @@ interface BusinessUnit extends BaseResource public const FIELD_KEY = 'key'; public const FIELD_STATUS = 'status'; public const FIELD_STORES = 'stores'; + public const FIELD_INHERITED_STORES = 'inheritedStores'; public const FIELD_STORE_MODE = 'storeMode'; public const FIELD_UNIT_TYPE = 'unitType'; public const FIELD_NAME = 'name'; @@ -117,6 +118,14 @@ public function getStatus(); */ public function getStores(); + /** + *

Stores that are inherited from a parent Business Unit. The value of this field is eventually consistent and is only present when the storeMode is set to FromParent.

+ * + + * @return null|StoreKeyReferenceCollection + */ + public function getInheritedStores(); + /** *

Defines whether the Stores of the Business Unit are set directly on the Business Unit or are inherited from a parent.

* @@ -291,6 +300,11 @@ public function setStatus(?string $status): void; */ public function setStores(?StoreKeyReferenceCollection $stores): void; + /** + * @param ?StoreKeyReferenceCollection $inheritedStores + */ + public function setInheritedStores(?StoreKeyReferenceCollection $inheritedStores): void; + /** * @param ?string $storeMode */ diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php index 90a546fd33a..f9cd0e4d831 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitBuilder.php @@ -85,6 +85,12 @@ final class BusinessUnitBuilder implements Builder */ private $stores; + /** + + * @var ?StoreKeyReferenceCollection + */ + private $inheritedStores; + /** * @var ?string @@ -276,6 +282,17 @@ public function getStores() return $this->stores; } + /** + *

Stores that are inherited from a parent Business Unit. The value of this field is eventually consistent and is only present when the storeMode is set to FromParent.

+ * + + * @return null|StoreKeyReferenceCollection + */ + public function getInheritedStores() + { + return $this->inheritedStores; + } + /** *

Defines whether the Stores of the Business Unit are set directly on the Business Unit or are inherited from a parent.

* @@ -541,6 +558,17 @@ public function withStores(?StoreKeyReferenceCollection $stores) return $this; } + /** + * @param ?StoreKeyReferenceCollection $inheritedStores + * @return $this + */ + public function withInheritedStores(?StoreKeyReferenceCollection $inheritedStores) + { + $this->inheritedStores = $inheritedStores; + + return $this; + } + /** * @param ?string $storeMode * @return $this @@ -773,6 +801,7 @@ public function build(): BusinessUnit $this->key, $this->status, $this->stores, + $this->inheritedStores, $this->storeMode, $this->name, $this->contactEmail, diff --git a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php index 5d243fc5444..174ec6b907a 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/BusinessUnitModel.php @@ -85,6 +85,12 @@ final class BusinessUnitModel extends JsonObjectModel implements BusinessUnit */ protected $stores; + /** + * + * @var ?StoreKeyReferenceCollection + */ + protected $inheritedStores; + /** * * @var ?string @@ -203,6 +209,7 @@ public function __construct( ?string $key = null, ?string $status = null, ?StoreKeyReferenceCollection $stores = null, + ?StoreKeyReferenceCollection $inheritedStores = null, ?string $storeMode = null, ?string $name = null, ?string $contactEmail = null, @@ -229,6 +236,7 @@ public function __construct( $this->key = $key; $this->status = $status; $this->stores = $stores; + $this->inheritedStores = $inheritedStores; $this->storeMode = $storeMode; $this->name = $name; $this->contactEmail = $contactEmail; @@ -439,6 +447,26 @@ public function getStores() return $this->stores; } + /** + *

Stores that are inherited from a parent Business Unit. The value of this field is eventually consistent and is only present when the storeMode is set to FromParent.

+ * + * + * @return null|StoreKeyReferenceCollection + */ + public function getInheritedStores() + { + if (is_null($this->inheritedStores)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_INHERITED_STORES); + if (is_null($data)) { + return null; + } + $this->inheritedStores = StoreKeyReferenceCollection::fromArray($data); + } + + return $this->inheritedStores; + } + /** *

Defines whether the Stores of the Business Unit are set directly on the Business Unit or are inherited from a parent.

* @@ -836,6 +864,14 @@ public function setStores(?StoreKeyReferenceCollection $stores): void $this->stores = $stores; } + /** + * @param ?StoreKeyReferenceCollection $inheritedStores + */ + public function setInheritedStores(?StoreKeyReferenceCollection $inheritedStores): void + { + $this->inheritedStores = $inheritedStores; + } + /** * @param ?string $storeMode */ diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php index 93d01a21f22..e10498468a3 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyBuilder.php @@ -83,6 +83,12 @@ final class CompanyBuilder implements Builder */ private $stores; + /** + + * @var ?StoreKeyReferenceCollection + */ + private $inheritedStores; + /** * @var ?string @@ -274,6 +280,17 @@ public function getStores() return $this->stores; } + /** + *

Stores that are inherited from a parent Business Unit. The value of this field is eventually consistent and is only present when the storeMode is set to FromParent.

+ * + + * @return null|StoreKeyReferenceCollection + */ + public function getInheritedStores() + { + return $this->inheritedStores; + } + /** *

The value of this field is always Explicit because a Company cannot have a parent Business Unit that Stores can be inherited from.

* @@ -538,6 +555,17 @@ public function withStores(?StoreKeyReferenceCollection $stores) return $this; } + /** + * @param ?StoreKeyReferenceCollection $inheritedStores + * @return $this + */ + public function withInheritedStores(?StoreKeyReferenceCollection $inheritedStores) + { + $this->inheritedStores = $inheritedStores; + + return $this; + } + /** * @param ?string $storeMode * @return $this @@ -770,6 +798,7 @@ public function build(): Company $this->key, $this->status, $this->stores, + $this->inheritedStores, $this->storeMode, $this->name, $this->contactEmail, diff --git a/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php b/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php index ae0df0b2100..87bfc546671 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/CompanyModel.php @@ -83,6 +83,12 @@ final class CompanyModel extends JsonObjectModel implements Company */ protected $stores; + /** + * + * @var ?StoreKeyReferenceCollection + */ + protected $inheritedStores; + /** * * @var ?string @@ -193,6 +199,7 @@ public function __construct( ?string $key = null, ?string $status = null, ?StoreKeyReferenceCollection $stores = null, + ?StoreKeyReferenceCollection $inheritedStores = null, ?string $storeMode = null, ?string $name = null, ?string $contactEmail = null, @@ -219,6 +226,7 @@ public function __construct( $this->key = $key; $this->status = $status; $this->stores = $stores; + $this->inheritedStores = $inheritedStores; $this->storeMode = $storeMode; $this->name = $name; $this->contactEmail = $contactEmail; @@ -429,6 +437,26 @@ public function getStores() return $this->stores; } + /** + *

Stores that are inherited from a parent Business Unit. The value of this field is eventually consistent and is only present when the storeMode is set to FromParent.

+ * + * + * @return null|StoreKeyReferenceCollection + */ + public function getInheritedStores() + { + if (is_null($this->inheritedStores)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_INHERITED_STORES); + if (is_null($data)) { + return null; + } + $this->inheritedStores = StoreKeyReferenceCollection::fromArray($data); + } + + return $this->inheritedStores; + } + /** *

The value of this field is always Explicit because a Company cannot have a parent Business Unit that Stores can be inherited from.

* @@ -825,6 +853,14 @@ public function setStores(?StoreKeyReferenceCollection $stores): void $this->stores = $stores; } + /** + * @param ?StoreKeyReferenceCollection $inheritedStores + */ + public function setInheritedStores(?StoreKeyReferenceCollection $inheritedStores): void + { + $this->inheritedStores = $inheritedStores; + } + /** * @param ?string $storeMode */ diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php index 40220aa9d7f..97b264e1397 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionBuilder.php @@ -83,6 +83,12 @@ final class DivisionBuilder implements Builder */ private $stores; + /** + + * @var ?StoreKeyReferenceCollection + */ + private $inheritedStores; + /** * @var ?string @@ -274,6 +280,17 @@ public function getStores() return $this->stores; } + /** + *

Stores that are inherited from a parent Business Unit. The value of this field is eventually consistent and is only present when the storeMode is set to FromParent.

+ * + + * @return null|StoreKeyReferenceCollection + */ + public function getInheritedStores() + { + return $this->inheritedStores; + } + /** *

Defines whether the Stores of the Division are set explicitly or inherited from a parent Business Unit.

* @@ -538,6 +555,17 @@ public function withStores(?StoreKeyReferenceCollection $stores) return $this; } + /** + * @param ?StoreKeyReferenceCollection $inheritedStores + * @return $this + */ + public function withInheritedStores(?StoreKeyReferenceCollection $inheritedStores) + { + $this->inheritedStores = $inheritedStores; + + return $this; + } + /** * @param ?string $storeMode * @return $this @@ -770,6 +798,7 @@ public function build(): Division $this->key, $this->status, $this->stores, + $this->inheritedStores, $this->storeMode, $this->name, $this->contactEmail, diff --git a/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php b/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php index 68892b378a8..f4d0ec684a1 100644 --- a/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php +++ b/lib/commercetools-api/src/Models/BusinessUnit/DivisionModel.php @@ -83,6 +83,12 @@ final class DivisionModel extends JsonObjectModel implements Division */ protected $stores; + /** + * + * @var ?StoreKeyReferenceCollection + */ + protected $inheritedStores; + /** * * @var ?string @@ -193,6 +199,7 @@ public function __construct( ?string $key = null, ?string $status = null, ?StoreKeyReferenceCollection $stores = null, + ?StoreKeyReferenceCollection $inheritedStores = null, ?string $storeMode = null, ?string $name = null, ?string $contactEmail = null, @@ -219,6 +226,7 @@ public function __construct( $this->key = $key; $this->status = $status; $this->stores = $stores; + $this->inheritedStores = $inheritedStores; $this->storeMode = $storeMode; $this->name = $name; $this->contactEmail = $contactEmail; @@ -429,6 +437,26 @@ public function getStores() return $this->stores; } + /** + *

Stores that are inherited from a parent Business Unit. The value of this field is eventually consistent and is only present when the storeMode is set to FromParent.

+ * + * + * @return null|StoreKeyReferenceCollection + */ + public function getInheritedStores() + { + if (is_null($this->inheritedStores)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_INHERITED_STORES); + if (is_null($data)) { + return null; + } + $this->inheritedStores = StoreKeyReferenceCollection::fromArray($data); + } + + return $this->inheritedStores; + } + /** *

Defines whether the Stores of the Division are set explicitly or inherited from a parent Business Unit.

* @@ -825,6 +853,14 @@ public function setStores(?StoreKeyReferenceCollection $stores): void $this->stores = $stores; } + /** + * @param ?StoreKeyReferenceCollection $inheritedStores + */ + public function setInheritedStores(?StoreKeyReferenceCollection $inheritedStores): void + { + $this->inheritedStores = $inheritedStores; + } + /** * @param ?string $storeMode */ diff --git a/references.txt b/references.txt index 14487299e26..c0c6878a285 100644 --- a/references.txt +++ b/references.txt @@ -346,3 +346,4 @@ e8f731a742ca2997342b1b5f98121d86c8189a3b 473d2c6f1a9e9da0d2a42408ccf11f27a838f8b5 b7b82f5a701908239fcf39781bcbfa80823c9fa0 cc1732f88ea3dc336358ff9f39cda9d5271cf7c2 +e3d5bc9cb69146c5d1dd755ed5e8cf2f54566b3a