From 07f90e7c5dc14344072a6321a7dffd36fe0aa856 Mon Sep 17 00:00:00 2001 From: "ct-sdks[bot]" <153784748+ct-sdks[bot]@users.noreply.github.com> Date: Fri, 20 Dec 2024 09:34:17 +0000 Subject: [PATCH] build(codegen): updating SDK --- changes.md | 14 + ...yBusinessUnitsSearchIndexingStatusTest.php | 223 ++++++++++++ ...rceByProjectKeyBusinessUnitsSearchTest.php | 344 ++++++++++++++++++ .../ResourceByProjectKeyBusinessUnitsTest.php | 24 ++ lib/commercetools-api/docs/RequestBuilder.md | 49 +++ .../ByProjectKeyBusinessUnitsSearchHead.php | 139 +++++++ ...eyBusinessUnitsSearchIndexingStatusGet.php | 145 ++++++++ .../ByProjectKeyBusinessUnitsSearchPost.php | 144 ++++++++ .../ResourceByProjectKeyBusinessUnits.php | 16 + ...esourceByProjectKeyBusinessUnitsSearch.php | 49 +++ ...ctKeyBusinessUnitsSearchIndexingStatus.php | 38 ++ .../BusinessUnitIndexingProgress.php | 58 +++ .../BusinessUnitIndexingProgressBuilder.php | 121 ++++++ ...BusinessUnitIndexingProgressCollection.php | 56 +++ .../BusinessUnitIndexingProgressModel.php | 138 +++++++ .../BusinessUnitPagedSearchResponse.php | 72 ++++ ...BusinessUnitPagedSearchResponseBuilder.php | 150 ++++++++ ...inessUnitPagedSearchResponseCollection.php | 56 +++ .../BusinessUnitPagedSearchResponseModel.php | 174 +++++++++ ...sinessUnitSearchIndexingStatusResponse.php | 87 +++++ ...nitSearchIndexingStatusResponseBuilder.php | 190 ++++++++++ ...SearchIndexingStatusResponseCollection.php | 56 +++ ...sUnitSearchIndexingStatusResponseModel.php | 235 ++++++++++++ .../BusinessUnitSearchRequest.php | 74 ++++ .../BusinessUnitSearchRequestBuilder.php | 163 +++++++++ .../BusinessUnitSearchRequestCollection.php | 56 +++ .../BusinessUnitSearchRequestModel.php | 178 +++++++++ .../BusinessUnitSearchResult.php | 44 +++ .../BusinessUnitSearchResultBuilder.php | 92 +++++ .../BusinessUnitSearchResultCollection.php | 56 +++ .../BusinessUnitSearchResultModel.php | 102 ++++++ ...ctChangeBusinessUnitSearchStatusAction.php | 30 ++ ...eBusinessUnitSearchStatusActionBuilder.php | 63 ++++ ...sinessUnitSearchStatusActionCollection.php | 56 +++ ...ngeBusinessUnitSearchStatusActionModel.php | 93 +++++ .../Project/ProjectUpdateActionModel.php | 1 + .../Project/SearchIndexingConfiguration.php | 14 + .../SearchIndexingConfigurationBuilder.php | 42 ++- .../SearchIndexingConfigurationModel.php | 39 +- references.txt | 1 + 40 files changed, 3680 insertions(+), 2 deletions(-) create mode 100644 lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchIndexingStatusTest.php create mode 100644 lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchTest.php create mode 100644 lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchHead.php create mode 100644 lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchIndexingStatusGet.php create mode 100644 lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchPost.php create mode 100644 lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnitsSearch.php create mode 100644 lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchIndexingStatus.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgress.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressBuilder.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressCollection.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressModel.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponse.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseBuilder.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseCollection.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseModel.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponse.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseBuilder.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseCollection.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseModel.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequest.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestBuilder.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestCollection.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestModel.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResult.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultBuilder.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultCollection.php create mode 100644 lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultModel.php create mode 100644 lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusAction.php create mode 100644 lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionBuilder.php create mode 100644 lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionCollection.php create mode 100644 lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionModel.php diff --git a/changes.md b/changes.md index f5a06a8e53f..709e4fdf328 100644 --- a/changes.md +++ b/changes.md @@ -3,6 +3,8 @@
Added Resource(s) +- added resource `/{projectKey}/business-units/search` +- added resource `/{projectKey}/business-units/search/indexing-status` - added resource `/{projectKey}/channels/key={key}`
@@ -10,6 +12,9 @@
Added Method(s) +- added method `$apiRoot->withProjectKey()->businessUnits()->search()->post()` +- added method `$apiRoot->withProjectKey()->businessUnits()->search()->head()` +- added method `$apiRoot->withProjectKey()->businessUnits()->searchIndexingStatus()->get()` - added method `$apiRoot->withProjectKey()->channels()->withKey()->get()` - added method `$apiRoot->withProjectKey()->channels()->withKey()->head()` - added method `$apiRoot->withProjectKey()->channels()->withKey()->post()` @@ -20,6 +25,12 @@
Added Type(s) +- added type `BusinessUnitIndexingProgress` +- added type `BusinessUnitIndexingStatus` +- added type `BusinessUnitPagedSearchResponse` +- added type `BusinessUnitSearchIndexingStatusResponse` +- added type `BusinessUnitSearchRequest` +- added type `BusinessUnitSearchResult` - added type `CartDiscountPatternTarget` - added type `CountOnCustomLineItemUnits` - added type `CountOnLineItemUnits` @@ -30,6 +41,8 @@ - added type `ShoppingListLineItemAddedMessagePayload` - added type `ShoppingListLineItemRemovedMessagePayload` - added type `ShoppingListMessagePayload` +- added type `BusinessUnitSearchStatus` +- added type `ProjectChangeBusinessUnitSearchStatusAction`
@@ -49,6 +62,7 @@ - added property `custom` to type `CartSetCustomShippingMethodAction` - added property `custom` to type `StagedOrderSetCustomShippingMethodAction` - added property `custom` to type `StagedOrderSetShippingAddressAndCustomShippingMethodAction` +- added property `businessUnits` to type `SearchIndexingConfiguration`
**History changes** diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchIndexingStatusTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchIndexingStatusTest.php new file mode 100644 index 00000000000..475a5ae66cc --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchIndexingStatusTest.php @@ -0,0 +1,223 @@ +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 [ + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 'get', + 'test_projectKey/business-units/search/indexing-status', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 200 + ], + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 400 + ], + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 401 + ], + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 403 + ], + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 404 + ], + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 500 + ], + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 502 + ], + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 503 + ], + 'ByProjectKeyBusinessUnitsSearchIndexingStatusGet_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchTest.php new file mode 100644 index 00000000000..69bc0441285 --- /dev/null +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchTest.php @@ -0,0 +1,344 @@ +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 [ + 'ByProjectKeyBusinessUnitsSearchPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 'post', + 'test_projectKey/business-units/search', + ], + 'ByProjectKeyBusinessUnitsSearchHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("test_projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 'head', + 'test_projectKey/business-units/search', + ] + ]; + } + + public function getResources() + { + return [ + ]; + } + + public function getRequestBuilders() + { + return [ + 'ByProjectKeyBusinessUnitsSearchPost' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + } + ], + 'ByProjectKeyBusinessUnitsSearchHead' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + } + ] + ]; + } + + public function getRequestBuilderResponses() + { + return [ + 'ByProjectKeyBusinessUnitsSearchPost_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 200 + ], + 'ByProjectKeyBusinessUnitsSearchPost_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 400 + ], + 'ByProjectKeyBusinessUnitsSearchPost_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 401 + ], + 'ByProjectKeyBusinessUnitsSearchPost_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 403 + ], + 'ByProjectKeyBusinessUnitsSearchPost_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 404 + ], + 'ByProjectKeyBusinessUnitsSearchPost_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 500 + ], + 'ByProjectKeyBusinessUnitsSearchPost_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 502 + ], + 'ByProjectKeyBusinessUnitsSearchPost_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 503 + ], + 'ByProjectKeyBusinessUnitsSearchPost_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); + }, + 599 + ], + 'ByProjectKeyBusinessUnitsSearchHead_200' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 200 + ], + 'ByProjectKeyBusinessUnitsSearchHead_409' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 409 + ], + 'ByProjectKeyBusinessUnitsSearchHead_400' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 400 + ], + 'ByProjectKeyBusinessUnitsSearchHead_401' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 401 + ], + 'ByProjectKeyBusinessUnitsSearchHead_403' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 403 + ], + 'ByProjectKeyBusinessUnitsSearchHead_404' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 404 + ], + 'ByProjectKeyBusinessUnitsSearchHead_500' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 500 + ], + 'ByProjectKeyBusinessUnitsSearchHead_502' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 502 + ], + 'ByProjectKeyBusinessUnitsSearchHead_503' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 503 + ], + 'ByProjectKeyBusinessUnitsSearchHead_599' => [ + function (ApiRequestBuilder $builder): RequestInterface { + return $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); + }, + 599 + ] + ]; + } +} diff --git a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsTest.php b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsTest.php index 4a38f82cd06..58ae42a850a 100644 --- a/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsTest.php +++ b/lib/commercetools-api-tests/test/unit/Client/Resource/ResourceByProjectKeyBusinessUnitsTest.php @@ -11,6 +11,8 @@ use Commercetools\Api\Client\ApiRequestBuilder; use Commercetools\Api\Client\Resource\ResourceByProjectKeyBusinessUnitsByID; use Commercetools\Api\Client\Resource\ResourceByProjectKeyBusinessUnitsKeyByKey; +use Commercetools\Api\Client\Resource\ResourceByProjectKeyBusinessUnitsSearch; +use Commercetools\Api\Client\Resource\ResourceByProjectKeyBusinessUnitsSearchIndexingStatus; use Commercetools\Base\JsonObject; use Commercetools\Client\ApiRequest; use Commercetools\Exception\ApiClientException; @@ -259,6 +261,28 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyBusinessUnitsByID { ResourceByProjectKeyBusinessUnitsByID::class, ['projectKey' => 'test_projectKey', 'ID' => 'test_ID'], '/{projectKey}/business-units/{ID}' + ], + 'ResourceByProjectKeyBusinessUnitsSearch' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyBusinessUnitsSearch { + return $builder + ->withProjectKey("test_projectKey") + ->businessUnits() + ->search(); + }, + ResourceByProjectKeyBusinessUnitsSearch::class, + ['projectKey' => 'test_projectKey'], + '/{projectKey}/business-units/search' + ], + 'ResourceByProjectKeyBusinessUnitsSearchIndexingStatus' => [ + function (ApiRequestBuilder $builder): ResourceByProjectKeyBusinessUnitsSearchIndexingStatus { + return $builder + ->withProjectKey("test_projectKey") + ->businessUnits() + ->searchIndexingStatus(); + }, + ResourceByProjectKeyBusinessUnitsSearchIndexingStatus::class, + ['projectKey' => 'test_projectKey'], + '/{projectKey}/business-units/search/indexing-status' ] ]; } diff --git a/lib/commercetools-api/docs/RequestBuilder.md b/lib/commercetools-api/docs/RequestBuilder.md index 0d417b0b356..4e509688ee7 100644 --- a/lib/commercetools-api/docs/RequestBuilder.md +++ b/lib/commercetools-api/docs/RequestBuilder.md @@ -1679,6 +1679,55 @@ $request = $builder ->withKey("key") ->delete(); ``` +## `withProjectKey("projectKey")->businessUnits()->search()->post(null)` + +If the initial indexing is in progress or the feature is inactive, A [SearchNotReady](ctp:api:type:SearchNotReadyError) error is returned. If inactive, you can [reactivate](/../api/projects/business-unit-search#reactivate) it. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->post(null); +``` +## `withProjectKey("projectKey")->businessUnits()->search()->head()` + +Checks whether a search index of Business Units exists for a Project. +Returns a `200 OK` if an index exists; otherwise, returns a `409 Conflict`. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->search() + ->head(); +``` +## `withProjectKey("projectKey")->businessUnits()->searchIndexingStatus()->get()` + +Returns the indexing status of the Business Unit Search for a Project. + + +### Example +```php +use Commercetools\Api\Client\ApiRequestBuilder; + +$builder = new ApiRequestBuilder(); +$request = $builder + ->withProjectKey("projectKey") + ->businessUnits() + ->searchIndexingStatus() + ->get(); +``` ## `withProjectKey("projectKey")->cartDiscounts()->get()` null diff --git a/lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchHead.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchHead.php new file mode 100644 index 00000000000..4fab00443e3 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchHead.php @@ -0,0 +1,139 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyBusinessUnitsSearchHead extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/business-units/search'); + 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/ByProjectKeyBusinessUnitsSearchIndexingStatusGet.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchIndexingStatusGet.php new file mode 100644 index 00000000000..8651fe9e3ef --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchIndexingStatusGet.php @@ -0,0 +1,145 @@ + + * @template-implements Deprecatable200 + */ +class ByProjectKeyBusinessUnitsSearchIndexingStatusGet extends ApiRequest implements Errorable, Deprecatable200 +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/business-units/search/indexing-status'); + 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 BusinessUnitSearchIndexingStatusResponse|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 = BusinessUnitSearchIndexingStatusResponseModel::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|BusinessUnitSearchIndexingStatusResponse|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/ByProjectKeyBusinessUnitsSearchPost.php b/lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchPost.php new file mode 100644 index 00000000000..88baf432e04 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ByProjectKeyBusinessUnitsSearchPost.php @@ -0,0 +1,144 @@ + + */ +class ByProjectKeyBusinessUnitsSearchPost extends ApiRequest implements Errorable +{ + /** + * @param ?object|array|string $body + * @psalm-param array $headers + */ + public function __construct(string $projectKey, $body = null, array $headers = [], ClientInterface $client = null) + { + $uri = str_replace(['{projectKey}'], [$projectKey], '{projectKey}/business-units/search'); + 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 BusinessUnitPagedSearchResponse|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 = BusinessUnitPagedSearchResponseModel::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|BusinessUnitPagedSearchResponse|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/ResourceByProjectKeyBusinessUnits.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnits.php index 7320e5f0d62..534b2989598 100644 --- a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnits.php +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnits.php @@ -48,6 +48,22 @@ public function withId(string $ID = null): ResourceByProjectKeyBusinessUnitsByID return new ResourceByProjectKeyBusinessUnitsByID($args, $this->getClient()); } + /** + */ + public function search(): ResourceByProjectKeyBusinessUnitsSearch + { + $args = $this->getArgs(); + + return new ResourceByProjectKeyBusinessUnitsSearch($args, $this->getClient()); + } + /** + */ + public function searchIndexingStatus(): ResourceByProjectKeyBusinessUnitsSearchIndexingStatus + { + $args = $this->getArgs(); + + return new ResourceByProjectKeyBusinessUnitsSearchIndexingStatus($args, $this->getClient()); + } /** * @psalm-param ?object|array|string $body diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnitsSearch.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnitsSearch.php new file mode 100644 index 00000000000..79259abc3ac --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnitsSearch.php @@ -0,0 +1,49 @@ + $args + */ + public function __construct(array $args = [], ClientInterface $client = null) + { + parent::__construct('/{projectKey}/business-units/search', $args, $client); + } + + /** + * @psalm-param ?BusinessUnitSearchRequest $body + * @psalm-param array $headers + */ + public function post(?BusinessUnitSearchRequest $body = null, array $headers = []): ByProjectKeyBusinessUnitsSearchPost + { + $args = $this->getArgs(); + + return new ByProjectKeyBusinessUnitsSearchPost($args['projectKey'], $body, $headers, $this->getClient()); + } + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function head($body = null, array $headers = []): ByProjectKeyBusinessUnitsSearchHead + { + $args = $this->getArgs(); + + return new ByProjectKeyBusinessUnitsSearchHead($args['projectKey'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchIndexingStatus.php b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchIndexingStatus.php new file mode 100644 index 00000000000..a8900aefeb9 --- /dev/null +++ b/lib/commercetools-api/src/Client/Resource/ResourceByProjectKeyBusinessUnitsSearchIndexingStatus.php @@ -0,0 +1,38 @@ + $args + */ + public function __construct(array $args = [], ClientInterface $client = null) + { + parent::__construct('/{projectKey}/business-units/search/indexing-status', $args, $client); + } + + /** + * @psalm-param ?object|array|string $body + * @psalm-param array $headers + */ + public function get($body = null, array $headers = []): ByProjectKeyBusinessUnitsSearchIndexingStatusGet + { + $args = $this->getArgs(); + + return new ByProjectKeyBusinessUnitsSearchIndexingStatusGet($args['projectKey'], $body, $headers, $this->getClient()); + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgress.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgress.php new file mode 100644 index 00000000000..14b995119c2 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgress.php @@ -0,0 +1,58 @@ +The number of Business Units successfully indexed.

+ * + + * @return null|int + */ + public function getIndexed(); + + /** + *

The number of Business Units that failed to be indexed.

+ * + + * @return null|int + */ + public function getFailed(); + + /** + *

The estimated total number of Business Units to be indexed.

+ * + + * @return null|int + */ + public function getEstimatedTotal(); + + /** + * @param ?int $indexed + */ + public function setIndexed(?int $indexed): void; + + /** + * @param ?int $failed + */ + public function setFailed(?int $failed): void; + + /** + * @param ?int $estimatedTotal + */ + public function setEstimatedTotal(?int $estimatedTotal): void; +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressBuilder.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressBuilder.php new file mode 100644 index 00000000000..eea6bf3d6f5 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressBuilder.php @@ -0,0 +1,121 @@ + + */ +final class BusinessUnitIndexingProgressBuilder implements Builder +{ + /** + + * @var ?int + */ + private $indexed; + + /** + + * @var ?int + */ + private $failed; + + /** + + * @var ?int + */ + private $estimatedTotal; + + /** + *

The number of Business Units successfully indexed.

+ * + + * @return null|int + */ + public function getIndexed() + { + return $this->indexed; + } + + /** + *

The number of Business Units that failed to be indexed.

+ * + + * @return null|int + */ + public function getFailed() + { + return $this->failed; + } + + /** + *

The estimated total number of Business Units to be indexed.

+ * + + * @return null|int + */ + public function getEstimatedTotal() + { + return $this->estimatedTotal; + } + + /** + * @param ?int $indexed + * @return $this + */ + public function withIndexed(?int $indexed) + { + $this->indexed = $indexed; + + return $this; + } + + /** + * @param ?int $failed + * @return $this + */ + public function withFailed(?int $failed) + { + $this->failed = $failed; + + return $this; + } + + /** + * @param ?int $estimatedTotal + * @return $this + */ + public function withEstimatedTotal(?int $estimatedTotal) + { + $this->estimatedTotal = $estimatedTotal; + + return $this; + } + + + public function build(): BusinessUnitIndexingProgress + { + return new BusinessUnitIndexingProgressModel( + $this->indexed, + $this->failed, + $this->estimatedTotal + ); + } + + public static function of(): BusinessUnitIndexingProgressBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressCollection.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressCollection.php new file mode 100644 index 00000000000..9afaea6ed10 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressCollection.php @@ -0,0 +1,56 @@ + + * @method BusinessUnitIndexingProgress current() + * @method BusinessUnitIndexingProgress end() + * @method BusinessUnitIndexingProgress at($offset) + */ +class BusinessUnitIndexingProgressCollection extends MapperSequence +{ + /** + * @psalm-assert BusinessUnitIndexingProgress $value + * @psalm-param BusinessUnitIndexingProgress|stdClass $value + * @throws InvalidArgumentException + * + * @return BusinessUnitIndexingProgressCollection + */ + public function add($value) + { + if (!$value instanceof BusinessUnitIndexingProgress) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?BusinessUnitIndexingProgress + */ + protected function mapper() + { + return function (?int $index): ?BusinessUnitIndexingProgress { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var BusinessUnitIndexingProgress $data */ + $data = BusinessUnitIndexingProgressModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressModel.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressModel.php new file mode 100644 index 00000000000..36db5428c2a --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitIndexingProgressModel.php @@ -0,0 +1,138 @@ +indexed = $indexed; + $this->failed = $failed; + $this->estimatedTotal = $estimatedTotal; + } + + /** + *

The number of Business Units successfully indexed.

+ * + * + * @return null|int + */ + public function getIndexed() + { + if (is_null($this->indexed)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_INDEXED); + if (is_null($data)) { + return null; + } + $this->indexed = (int) $data; + } + + return $this->indexed; + } + + /** + *

The number of Business Units that failed to be indexed.

+ * + * + * @return null|int + */ + public function getFailed() + { + if (is_null($this->failed)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_FAILED); + if (is_null($data)) { + return null; + } + $this->failed = (int) $data; + } + + return $this->failed; + } + + /** + *

The estimated total number of Business Units to be indexed.

+ * + * + * @return null|int + */ + public function getEstimatedTotal() + { + if (is_null($this->estimatedTotal)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_ESTIMATED_TOTAL); + if (is_null($data)) { + return null; + } + $this->estimatedTotal = (int) $data; + } + + return $this->estimatedTotal; + } + + + /** + * @param ?int $indexed + */ + public function setIndexed(?int $indexed): void + { + $this->indexed = $indexed; + } + + /** + * @param ?int $failed + */ + public function setFailed(?int $failed): void + { + $this->failed = $failed; + } + + /** + * @param ?int $estimatedTotal + */ + public function setEstimatedTotal(?int $estimatedTotal): void + { + $this->estimatedTotal = $estimatedTotal; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponse.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponse.php new file mode 100644 index 00000000000..c0008190fb8 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponse.php @@ -0,0 +1,72 @@ +Total number of results matching the query.

+ * + + * @return null|int + */ + public function getTotal(); + + /** + *

Number of results requested.

+ * + + * @return null|int + */ + public function getLimit(); + + /** + *

Number of elements skipped.

+ * + + * @return null|int + */ + public function getOffset(); + + /** + *

Search result containing the Business Units matching the search query.

+ * + + * @return null|BusinessUnitSearchResultCollection + */ + public function getResults(); + + /** + * @param ?int $total + */ + public function setTotal(?int $total): void; + + /** + * @param ?int $limit + */ + public function setLimit(?int $limit): void; + + /** + * @param ?int $offset + */ + public function setOffset(?int $offset): void; + + /** + * @param ?BusinessUnitSearchResultCollection $results + */ + public function setResults(?BusinessUnitSearchResultCollection $results): void; +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseBuilder.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseBuilder.php new file mode 100644 index 00000000000..f83467419f2 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseBuilder.php @@ -0,0 +1,150 @@ + + */ +final class BusinessUnitPagedSearchResponseBuilder implements Builder +{ + /** + + * @var ?int + */ + private $total; + + /** + + * @var ?int + */ + private $limit; + + /** + + * @var ?int + */ + private $offset; + + /** + + * @var ?BusinessUnitSearchResultCollection + */ + private $results; + + /** + *

Total number of results matching the query.

+ * + + * @return null|int + */ + public function getTotal() + { + return $this->total; + } + + /** + *

Number of results requested.

+ * + + * @return null|int + */ + public function getLimit() + { + return $this->limit; + } + + /** + *

Number of elements skipped.

+ * + + * @return null|int + */ + public function getOffset() + { + return $this->offset; + } + + /** + *

Search result containing the Business Units matching the search query.

+ * + + * @return null|BusinessUnitSearchResultCollection + */ + public function getResults() + { + return $this->results; + } + + /** + * @param ?int $total + * @return $this + */ + public function withTotal(?int $total) + { + $this->total = $total; + + return $this; + } + + /** + * @param ?int $limit + * @return $this + */ + public function withLimit(?int $limit) + { + $this->limit = $limit; + + return $this; + } + + /** + * @param ?int $offset + * @return $this + */ + public function withOffset(?int $offset) + { + $this->offset = $offset; + + return $this; + } + + /** + * @param ?BusinessUnitSearchResultCollection $results + * @return $this + */ + public function withResults(?BusinessUnitSearchResultCollection $results) + { + $this->results = $results; + + return $this; + } + + + public function build(): BusinessUnitPagedSearchResponse + { + return new BusinessUnitPagedSearchResponseModel( + $this->total, + $this->limit, + $this->offset, + $this->results + ); + } + + public static function of(): BusinessUnitPagedSearchResponseBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseCollection.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseCollection.php new file mode 100644 index 00000000000..ae48ef92bd9 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseCollection.php @@ -0,0 +1,56 @@ + + * @method BusinessUnitPagedSearchResponse current() + * @method BusinessUnitPagedSearchResponse end() + * @method BusinessUnitPagedSearchResponse at($offset) + */ +class BusinessUnitPagedSearchResponseCollection extends MapperSequence +{ + /** + * @psalm-assert BusinessUnitPagedSearchResponse $value + * @psalm-param BusinessUnitPagedSearchResponse|stdClass $value + * @throws InvalidArgumentException + * + * @return BusinessUnitPagedSearchResponseCollection + */ + public function add($value) + { + if (!$value instanceof BusinessUnitPagedSearchResponse) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?BusinessUnitPagedSearchResponse + */ + protected function mapper() + { + return function (?int $index): ?BusinessUnitPagedSearchResponse { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var BusinessUnitPagedSearchResponse $data */ + $data = BusinessUnitPagedSearchResponseModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseModel.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseModel.php new file mode 100644 index 00000000000..75150857277 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitPagedSearchResponseModel.php @@ -0,0 +1,174 @@ +total = $total; + $this->limit = $limit; + $this->offset = $offset; + $this->results = $results; + } + + /** + *

Total number of results matching the query.

+ * + * + * @return null|int + */ + public function getTotal() + { + if (is_null($this->total)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_TOTAL); + if (is_null($data)) { + return null; + } + $this->total = (int) $data; + } + + return $this->total; + } + + /** + *

Number of results requested.

+ * + * + * @return null|int + */ + public function getLimit() + { + if (is_null($this->limit)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_LIMIT); + if (is_null($data)) { + return null; + } + $this->limit = (int) $data; + } + + return $this->limit; + } + + /** + *

Number of elements skipped.

+ * + * + * @return null|int + */ + public function getOffset() + { + if (is_null($this->offset)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_OFFSET); + if (is_null($data)) { + return null; + } + $this->offset = (int) $data; + } + + return $this->offset; + } + + /** + *

Search result containing the Business Units matching the search query.

+ * + * + * @return null|BusinessUnitSearchResultCollection + */ + public function getResults() + { + if (is_null($this->results)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_RESULTS); + if (is_null($data)) { + return null; + } + $this->results = BusinessUnitSearchResultCollection::fromArray($data); + } + + return $this->results; + } + + + /** + * @param ?int $total + */ + public function setTotal(?int $total): void + { + $this->total = $total; + } + + /** + * @param ?int $limit + */ + public function setLimit(?int $limit): void + { + $this->limit = $limit; + } + + /** + * @param ?int $offset + */ + public function setOffset(?int $offset): void + { + $this->offset = $offset; + } + + /** + * @param ?BusinessUnitSearchResultCollection $results + */ + public function setResults(?BusinessUnitSearchResultCollection $results): void + { + $this->results = $results; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponse.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponse.php new file mode 100644 index 00000000000..02cb9ab96cf --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponse.php @@ -0,0 +1,87 @@ +Current status of indexing the Business Unit Search.

+ * + + * @return null|string + */ + public function getStatus(); + + /** + *

Progress of indexing. Only available when indexing is in progress.

+ * + + * @return null|BusinessUnitIndexingProgress + */ + public function getStates(); + + /** + *

Date and time (UTC) when the last indexing started.

+ * + + * @return null|DateTimeImmutable + */ + public function getStartedAt(); + + /** + *

Time when the status was last modified.

+ * + + * @return null|DateTimeImmutable + */ + public function getLastModifiedAt(); + + /** + *

Indicates how many times the system tried to start indexing after failed attempts. The counter is set to null after an indexing finished successfully.

+ * + + * @return null|int + */ + public function getRetryCount(); + + /** + * @param ?string $status + */ + public function setStatus(?string $status): void; + + /** + * @param ?BusinessUnitIndexingProgress $states + */ + public function setStates(?BusinessUnitIndexingProgress $states): void; + + /** + * @param ?DateTimeImmutable $startedAt + */ + public function setStartedAt(?DateTimeImmutable $startedAt): void; + + /** + * @param ?DateTimeImmutable $lastModifiedAt + */ + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void; + + /** + * @param ?int $retryCount + */ + public function setRetryCount(?int $retryCount): void; +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseBuilder.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseBuilder.php new file mode 100644 index 00000000000..5bfcc19e48c --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseBuilder.php @@ -0,0 +1,190 @@ + + */ +final class BusinessUnitSearchIndexingStatusResponseBuilder implements Builder +{ + /** + + * @var ?string + */ + private $status; + + /** + + * @var null|BusinessUnitIndexingProgress|BusinessUnitIndexingProgressBuilder + */ + private $states; + + /** + + * @var ?DateTimeImmutable + */ + private $startedAt; + + /** + + * @var ?DateTimeImmutable + */ + private $lastModifiedAt; + + /** + + * @var ?int + */ + private $retryCount; + + /** + *

Current status of indexing the Business Unit Search.

+ * + + * @return null|string + */ + public function getStatus() + { + return $this->status; + } + + /** + *

Progress of indexing. Only available when indexing is in progress.

+ * + + * @return null|BusinessUnitIndexingProgress + */ + public function getStates() + { + return $this->states instanceof BusinessUnitIndexingProgressBuilder ? $this->states->build() : $this->states; + } + + /** + *

Date and time (UTC) when the last indexing started.

+ * + + * @return null|DateTimeImmutable + */ + public function getStartedAt() + { + return $this->startedAt; + } + + /** + *

Time when the status was last modified.

+ * + + * @return null|DateTimeImmutable + */ + public function getLastModifiedAt() + { + return $this->lastModifiedAt; + } + + /** + *

Indicates how many times the system tried to start indexing after failed attempts. The counter is set to null after an indexing finished successfully.

+ * + + * @return null|int + */ + public function getRetryCount() + { + return $this->retryCount; + } + + /** + * @param ?string $status + * @return $this + */ + public function withStatus(?string $status) + { + $this->status = $status; + + return $this; + } + + /** + * @param ?BusinessUnitIndexingProgress $states + * @return $this + */ + public function withStates(?BusinessUnitIndexingProgress $states) + { + $this->states = $states; + + return $this; + } + + /** + * @param ?DateTimeImmutable $startedAt + * @return $this + */ + public function withStartedAt(?DateTimeImmutable $startedAt) + { + $this->startedAt = $startedAt; + + return $this; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + * @return $this + */ + public function withLastModifiedAt(?DateTimeImmutable $lastModifiedAt) + { + $this->lastModifiedAt = $lastModifiedAt; + + return $this; + } + + /** + * @param ?int $retryCount + * @return $this + */ + public function withRetryCount(?int $retryCount) + { + $this->retryCount = $retryCount; + + return $this; + } + + /** + * @deprecated use withStates() instead + * @return $this + */ + public function withStatesBuilder(?BusinessUnitIndexingProgressBuilder $states) + { + $this->states = $states; + + return $this; + } + + public function build(): BusinessUnitSearchIndexingStatusResponse + { + return new BusinessUnitSearchIndexingStatusResponseModel( + $this->status, + $this->states instanceof BusinessUnitIndexingProgressBuilder ? $this->states->build() : $this->states, + $this->startedAt, + $this->lastModifiedAt, + $this->retryCount + ); + } + + public static function of(): BusinessUnitSearchIndexingStatusResponseBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseCollection.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseCollection.php new file mode 100644 index 00000000000..b1bc496d4e2 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseCollection.php @@ -0,0 +1,56 @@ + + * @method BusinessUnitSearchIndexingStatusResponse current() + * @method BusinessUnitSearchIndexingStatusResponse end() + * @method BusinessUnitSearchIndexingStatusResponse at($offset) + */ +class BusinessUnitSearchIndexingStatusResponseCollection extends MapperSequence +{ + /** + * @psalm-assert BusinessUnitSearchIndexingStatusResponse $value + * @psalm-param BusinessUnitSearchIndexingStatusResponse|stdClass $value + * @throws InvalidArgumentException + * + * @return BusinessUnitSearchIndexingStatusResponseCollection + */ + public function add($value) + { + if (!$value instanceof BusinessUnitSearchIndexingStatusResponse) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?BusinessUnitSearchIndexingStatusResponse + */ + protected function mapper() + { + return function (?int $index): ?BusinessUnitSearchIndexingStatusResponse { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var BusinessUnitSearchIndexingStatusResponse $data */ + $data = BusinessUnitSearchIndexingStatusResponseModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseModel.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseModel.php new file mode 100644 index 00000000000..574144f7e8c --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchIndexingStatusResponseModel.php @@ -0,0 +1,235 @@ +status = $status; + $this->states = $states; + $this->startedAt = $startedAt; + $this->lastModifiedAt = $lastModifiedAt; + $this->retryCount = $retryCount; + } + + /** + *

Current status of indexing the Business Unit Search.

+ * + * + * @return null|string + */ + public function getStatus() + { + if (is_null($this->status)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_STATUS); + if (is_null($data)) { + return null; + } + $this->status = (string) $data; + } + + return $this->status; + } + + /** + *

Progress of indexing. Only available when indexing is in progress.

+ * + * + * @return null|BusinessUnitIndexingProgress + */ + public function getStates() + { + if (is_null($this->states)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_STATES); + if (is_null($data)) { + return null; + } + + $this->states = BusinessUnitIndexingProgressModel::of($data); + } + + return $this->states; + } + + /** + *

Date and time (UTC) when the last indexing started.

+ * + * + * @return null|DateTimeImmutable + */ + public function getStartedAt() + { + if (is_null($this->startedAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_STARTED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->startedAt = $data; + } + + return $this->startedAt; + } + + /** + *

Time when the status was last modified.

+ * + * + * @return null|DateTimeImmutable + */ + public function getLastModifiedAt() + { + if (is_null($this->lastModifiedAt)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_LAST_MODIFIED_AT); + if (is_null($data)) { + return null; + } + $data = DateTimeImmutable::createFromFormat(MapperFactory::DATETIME_FORMAT, $data); + if (false === $data) { + return null; + } + $this->lastModifiedAt = $data; + } + + return $this->lastModifiedAt; + } + + /** + *

Indicates how many times the system tried to start indexing after failed attempts. The counter is set to null after an indexing finished successfully.

+ * + * + * @return null|int + */ + public function getRetryCount() + { + if (is_null($this->retryCount)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_RETRY_COUNT); + if (is_null($data)) { + return null; + } + $this->retryCount = (int) $data; + } + + return $this->retryCount; + } + + + /** + * @param ?string $status + */ + public function setStatus(?string $status): void + { + $this->status = $status; + } + + /** + * @param ?BusinessUnitIndexingProgress $states + */ + public function setStates(?BusinessUnitIndexingProgress $states): void + { + $this->states = $states; + } + + /** + * @param ?DateTimeImmutable $startedAt + */ + public function setStartedAt(?DateTimeImmutable $startedAt): void + { + $this->startedAt = $startedAt; + } + + /** + * @param ?DateTimeImmutable $lastModifiedAt + */ + public function setLastModifiedAt(?DateTimeImmutable $lastModifiedAt): void + { + $this->lastModifiedAt = $lastModifiedAt; + } + + /** + * @param ?int $retryCount + */ + public function setRetryCount(?int $retryCount): void + { + $this->retryCount = $retryCount; + } + + + #[\ReturnTypeWillChange] + public function jsonSerialize() + { + $data = $this->toArray(); + if (isset($data[BusinessUnitSearchIndexingStatusResponse::FIELD_STARTED_AT]) && $data[BusinessUnitSearchIndexingStatusResponse::FIELD_STARTED_AT] instanceof \DateTimeImmutable) { + $data[BusinessUnitSearchIndexingStatusResponse::FIELD_STARTED_AT] = $data[BusinessUnitSearchIndexingStatusResponse::FIELD_STARTED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + + if (isset($data[BusinessUnitSearchIndexingStatusResponse::FIELD_LAST_MODIFIED_AT]) && $data[BusinessUnitSearchIndexingStatusResponse::FIELD_LAST_MODIFIED_AT] instanceof \DateTimeImmutable) { + $data[BusinessUnitSearchIndexingStatusResponse::FIELD_LAST_MODIFIED_AT] = $data[BusinessUnitSearchIndexingStatusResponse::FIELD_LAST_MODIFIED_AT]->setTimeZone(new \DateTimeZone('UTC'))->format('c'); + } + return (object) $data; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequest.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequest.php new file mode 100644 index 00000000000..d5b58ea5d7d --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequest.php @@ -0,0 +1,74 @@ +The Business Unit Search query.

+ * + + * @return null|SearchQuery + */ + public function getQuery(); + + /** + *

Controls how results to your query are sorted. If not provided, the results are sorted by relevance in descending order.

+ * + + * @return null|SearchSortingCollection + */ + public function getSort(); + + /** + *

The maximum number of search results to be returned.

+ * + + * @return null|int + */ + public function getLimit(); + + /** + *

The number of search results to be skipped in the response for pagination.

+ * + + * @return null|int + */ + public function getOffset(); + + /** + * @param ?SearchQuery $query + */ + public function setQuery(?SearchQuery $query): void; + + /** + * @param ?SearchSortingCollection $sort + */ + public function setSort(?SearchSortingCollection $sort): void; + + /** + * @param ?int $limit + */ + public function setLimit(?int $limit): void; + + /** + * @param ?int $offset + */ + public function setOffset(?int $offset): void; +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestBuilder.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestBuilder.php new file mode 100644 index 00000000000..3ec3a4be554 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestBuilder.php @@ -0,0 +1,163 @@ + + */ +final class BusinessUnitSearchRequestBuilder implements Builder +{ + /** + + * @var null|SearchQuery|SearchQueryBuilder + */ + private $query; + + /** + + * @var ?SearchSortingCollection + */ + private $sort; + + /** + + * @var ?int + */ + private $limit; + + /** + + * @var ?int + */ + private $offset; + + /** + *

The Business Unit Search query.

+ * + + * @return null|SearchQuery + */ + public function getQuery() + { + return $this->query instanceof SearchQueryBuilder ? $this->query->build() : $this->query; + } + + /** + *

Controls how results to your query are sorted. If not provided, the results are sorted by relevance in descending order.

+ * + + * @return null|SearchSortingCollection + */ + public function getSort() + { + return $this->sort; + } + + /** + *

The maximum number of search results to be returned.

+ * + + * @return null|int + */ + public function getLimit() + { + return $this->limit; + } + + /** + *

The number of search results to be skipped in the response for pagination.

+ * + + * @return null|int + */ + public function getOffset() + { + return $this->offset; + } + + /** + * @param ?SearchQuery $query + * @return $this + */ + public function withQuery(?SearchQuery $query) + { + $this->query = $query; + + return $this; + } + + /** + * @param ?SearchSortingCollection $sort + * @return $this + */ + public function withSort(?SearchSortingCollection $sort) + { + $this->sort = $sort; + + return $this; + } + + /** + * @param ?int $limit + * @return $this + */ + public function withLimit(?int $limit) + { + $this->limit = $limit; + + return $this; + } + + /** + * @param ?int $offset + * @return $this + */ + public function withOffset(?int $offset) + { + $this->offset = $offset; + + return $this; + } + + /** + * @deprecated use withQuery() instead + * @return $this + */ + public function withQueryBuilder(?SearchQueryBuilder $query) + { + $this->query = $query; + + return $this; + } + + public function build(): BusinessUnitSearchRequest + { + return new BusinessUnitSearchRequestModel( + $this->query instanceof SearchQueryBuilder ? $this->query->build() : $this->query, + $this->sort, + $this->limit, + $this->offset + ); + } + + public static function of(): BusinessUnitSearchRequestBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestCollection.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestCollection.php new file mode 100644 index 00000000000..35755a36179 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestCollection.php @@ -0,0 +1,56 @@ + + * @method BusinessUnitSearchRequest current() + * @method BusinessUnitSearchRequest end() + * @method BusinessUnitSearchRequest at($offset) + */ +class BusinessUnitSearchRequestCollection extends MapperSequence +{ + /** + * @psalm-assert BusinessUnitSearchRequest $value + * @psalm-param BusinessUnitSearchRequest|stdClass $value + * @throws InvalidArgumentException + * + * @return BusinessUnitSearchRequestCollection + */ + public function add($value) + { + if (!$value instanceof BusinessUnitSearchRequest) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?BusinessUnitSearchRequest + */ + protected function mapper() + { + return function (?int $index): ?BusinessUnitSearchRequest { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var BusinessUnitSearchRequest $data */ + $data = BusinessUnitSearchRequestModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestModel.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestModel.php new file mode 100644 index 00000000000..bc75476d62d --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchRequestModel.php @@ -0,0 +1,178 @@ +query = $query; + $this->sort = $sort; + $this->limit = $limit; + $this->offset = $offset; + } + + /** + *

The Business Unit Search query.

+ * + * + * @return null|SearchQuery + */ + public function getQuery() + { + if (is_null($this->query)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_QUERY); + if (is_null($data)) { + return null; + } + + $this->query = SearchQueryModel::of($data); + } + + return $this->query; + } + + /** + *

Controls how results to your query are sorted. If not provided, the results are sorted by relevance in descending order.

+ * + * + * @return null|SearchSortingCollection + */ + public function getSort() + { + if (is_null($this->sort)) { + /** @psalm-var ?list $data */ + $data = $this->raw(self::FIELD_SORT); + if (is_null($data)) { + return null; + } + $this->sort = SearchSortingCollection::fromArray($data); + } + + return $this->sort; + } + + /** + *

The maximum number of search results to be returned.

+ * + * + * @return null|int + */ + public function getLimit() + { + if (is_null($this->limit)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_LIMIT); + if (is_null($data)) { + return null; + } + $this->limit = (int) $data; + } + + return $this->limit; + } + + /** + *

The number of search results to be skipped in the response for pagination.

+ * + * + * @return null|int + */ + public function getOffset() + { + if (is_null($this->offset)) { + /** @psalm-var ?int $data */ + $data = $this->raw(self::FIELD_OFFSET); + if (is_null($data)) { + return null; + } + $this->offset = (int) $data; + } + + return $this->offset; + } + + + /** + * @param ?SearchQuery $query + */ + public function setQuery(?SearchQuery $query): void + { + $this->query = $query; + } + + /** + * @param ?SearchSortingCollection $sort + */ + public function setSort(?SearchSortingCollection $sort): void + { + $this->sort = $sort; + } + + /** + * @param ?int $limit + */ + public function setLimit(?int $limit): void + { + $this->limit = $limit; + } + + /** + * @param ?int $offset + */ + public function setOffset(?int $offset): void + { + $this->offset = $offset; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResult.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResult.php new file mode 100644 index 00000000000..faf5a752154 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResult.php @@ -0,0 +1,44 @@ +id of the BusinessUnit matching the search query.

+ * + + * @return null|string + */ + public function getId(); + + /** + *

How closely this customer matches the search query.

+ * + + * @return null|float + */ + public function getRelevance(); + + /** + * @param ?string $id + */ + public function setId(?string $id): void; + + /** + * @param ?float $relevance + */ + public function setRelevance(?float $relevance): void; +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultBuilder.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultBuilder.php new file mode 100644 index 00000000000..7fdc7947b5f --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultBuilder.php @@ -0,0 +1,92 @@ + + */ +final class BusinessUnitSearchResultBuilder implements Builder +{ + /** + + * @var ?string + */ + private $id; + + /** + + * @var ?float + */ + private $relevance; + + /** + *

id of the BusinessUnit matching the search query.

+ * + + * @return null|string + */ + public function getId() + { + return $this->id; + } + + /** + *

How closely this customer matches the search query.

+ * + + * @return null|float + */ + public function getRelevance() + { + return $this->relevance; + } + + /** + * @param ?string $id + * @return $this + */ + public function withId(?string $id) + { + $this->id = $id; + + return $this; + } + + /** + * @param ?float $relevance + * @return $this + */ + public function withRelevance(?float $relevance) + { + $this->relevance = $relevance; + + return $this; + } + + + public function build(): BusinessUnitSearchResult + { + return new BusinessUnitSearchResultModel( + $this->id, + $this->relevance + ); + } + + public static function of(): BusinessUnitSearchResultBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultCollection.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultCollection.php new file mode 100644 index 00000000000..750a633fff0 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultCollection.php @@ -0,0 +1,56 @@ + + * @method BusinessUnitSearchResult current() + * @method BusinessUnitSearchResult end() + * @method BusinessUnitSearchResult at($offset) + */ +class BusinessUnitSearchResultCollection extends MapperSequence +{ + /** + * @psalm-assert BusinessUnitSearchResult $value + * @psalm-param BusinessUnitSearchResult|stdClass $value + * @throws InvalidArgumentException + * + * @return BusinessUnitSearchResultCollection + */ + public function add($value) + { + if (!$value instanceof BusinessUnitSearchResult) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?BusinessUnitSearchResult + */ + protected function mapper() + { + return function (?int $index): ?BusinessUnitSearchResult { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var BusinessUnitSearchResult $data */ + $data = BusinessUnitSearchResultModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultModel.php b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultModel.php new file mode 100644 index 00000000000..9aa1e7483d6 --- /dev/null +++ b/lib/commercetools-api/src/Models/BusinessUnitSearch/BusinessUnitSearchResultModel.php @@ -0,0 +1,102 @@ +id = $id; + $this->relevance = $relevance; + } + + /** + *

id of the BusinessUnit matching the search query.

+ * + * + * @return null|string + */ + public function getId() + { + if (is_null($this->id)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ID); + if (is_null($data)) { + return null; + } + $this->id = (string) $data; + } + + return $this->id; + } + + /** + *

How closely this customer matches the search query.

+ * + * + * @return null|float + */ + public function getRelevance() + { + if (is_null($this->relevance)) { + /** @psalm-var ?float $data */ + $data = $this->raw(self::FIELD_RELEVANCE); + if (is_null($data)) { + return null; + } + $this->relevance = (float) $data; + } + + return $this->relevance; + } + + + /** + * @param ?string $id + */ + public function setId(?string $id): void + { + $this->id = $id; + } + + /** + * @param ?float $relevance + */ + public function setRelevance(?float $relevance): void + { + $this->relevance = $relevance; + } +} diff --git a/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusAction.php b/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusAction.php new file mode 100644 index 00000000000..6e4b743377b --- /dev/null +++ b/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusAction.php @@ -0,0 +1,30 @@ +Activates or deactivates the Search Business Units feature. Activation will trigger building a search index for the Business Units in the Project.

+ * + + * @return null|string + */ + public function getStatus(); + + /** + * @param ?string $status + */ + public function setStatus(?string $status): void; +} diff --git a/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionBuilder.php b/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionBuilder.php new file mode 100644 index 00000000000..02a7451eb3e --- /dev/null +++ b/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionBuilder.php @@ -0,0 +1,63 @@ + + */ +final class ProjectChangeBusinessUnitSearchStatusActionBuilder implements Builder +{ + /** + + * @var ?string + */ + private $status; + + /** + *

Activates or deactivates the Search Business Units feature. Activation will trigger building a search index for the Business Units in the Project.

+ * + + * @return null|string + */ + public function getStatus() + { + return $this->status; + } + + /** + * @param ?string $status + * @return $this + */ + public function withStatus(?string $status) + { + $this->status = $status; + + return $this; + } + + + public function build(): ProjectChangeBusinessUnitSearchStatusAction + { + return new ProjectChangeBusinessUnitSearchStatusActionModel( + $this->status + ); + } + + public static function of(): ProjectChangeBusinessUnitSearchStatusActionBuilder + { + return new self(); + } +} diff --git a/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionCollection.php b/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionCollection.php new file mode 100644 index 00000000000..9ffb0337f62 --- /dev/null +++ b/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionCollection.php @@ -0,0 +1,56 @@ + + * @method ProjectChangeBusinessUnitSearchStatusAction current() + * @method ProjectChangeBusinessUnitSearchStatusAction end() + * @method ProjectChangeBusinessUnitSearchStatusAction at($offset) + */ +class ProjectChangeBusinessUnitSearchStatusActionCollection extends ProjectUpdateActionCollection +{ + /** + * @psalm-assert ProjectChangeBusinessUnitSearchStatusAction $value + * @psalm-param ProjectChangeBusinessUnitSearchStatusAction|stdClass $value + * @throws InvalidArgumentException + * + * @return ProjectChangeBusinessUnitSearchStatusActionCollection + */ + public function add($value) + { + if (!$value instanceof ProjectChangeBusinessUnitSearchStatusAction) { + throw new InvalidArgumentException(); + } + $this->store($value); + + return $this; + } + + /** + * @psalm-return callable(int):?ProjectChangeBusinessUnitSearchStatusAction + */ + protected function mapper() + { + return function (?int $index): ?ProjectChangeBusinessUnitSearchStatusAction { + $data = $this->get($index); + if ($data instanceof stdClass) { + /** @var ProjectChangeBusinessUnitSearchStatusAction $data */ + $data = ProjectChangeBusinessUnitSearchStatusActionModel::of($data); + $this->set($data, $index); + } + + return $data; + }; + } +} diff --git a/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionModel.php b/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionModel.php new file mode 100644 index 00000000000..234e3ef5c72 --- /dev/null +++ b/lib/commercetools-api/src/Models/Project/ProjectChangeBusinessUnitSearchStatusActionModel.php @@ -0,0 +1,93 @@ +status = $status; + $this->action = $action ?? self::DISCRIMINATOR_VALUE; + } + + /** + * + * @return null|string + */ + public function getAction() + { + if (is_null($this->action)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_ACTION); + if (is_null($data)) { + return null; + } + $this->action = (string) $data; + } + + return $this->action; + } + + /** + *

Activates or deactivates the Search Business Units feature. Activation will trigger building a search index for the Business Units in the Project.

+ * + * + * @return null|string + */ + public function getStatus() + { + if (is_null($this->status)) { + /** @psalm-var ?string $data */ + $data = $this->raw(self::FIELD_STATUS); + if (is_null($data)) { + return null; + } + $this->status = (string) $data; + } + + return $this->status; + } + + + /** + * @param ?string $status + */ + public function setStatus(?string $status): void + { + $this->status = $status; + } +} diff --git a/lib/commercetools-api/src/Models/Project/ProjectUpdateActionModel.php b/lib/commercetools-api/src/Models/Project/ProjectUpdateActionModel.php index 53cd41dd948..20bf969c027 100644 --- a/lib/commercetools-api/src/Models/Project/ProjectUpdateActionModel.php +++ b/lib/commercetools-api/src/Models/Project/ProjectUpdateActionModel.php @@ -31,6 +31,7 @@ final class ProjectUpdateActionModel extends JsonObjectModel implements ProjectU * */ private static $discriminatorClasses = [ + 'changeBusinessUnitSearchStatus' => ProjectChangeBusinessUnitSearchStatusActionModel::class, 'changeCartsConfiguration' => ProjectChangeCartsConfigurationActionModel::class, 'changeCountries' => ProjectChangeCountriesActionModel::class, 'changeCountryTaxRateFallbackEnabled' => ProjectChangeCountryTaxRateFallbackEnabledActionModel::class, diff --git a/lib/commercetools-api/src/Models/Project/SearchIndexingConfiguration.php b/lib/commercetools-api/src/Models/Project/SearchIndexingConfiguration.php index 79ef199a0fc..fe787594f74 100644 --- a/lib/commercetools-api/src/Models/Project/SearchIndexingConfiguration.php +++ b/lib/commercetools-api/src/Models/Project/SearchIndexingConfiguration.php @@ -17,6 +17,7 @@ interface SearchIndexingConfiguration extends JsonObject public const FIELD_PRODUCTS_SEARCH = 'productsSearch'; public const FIELD_ORDERS = 'orders'; public const FIELD_CUSTOMERS = 'customers'; + public const FIELD_BUSINESS_UNITS = 'businessUnits'; /** *

Configuration for the Product Projection Search and Product Suggestions endpoints.

@@ -50,6 +51,14 @@ public function getOrders(); */ public function getCustomers(); + /** + *

Configuration for the Business Unit Search feature.

+ * + + * @return null|SearchIndexingConfigurationValues + */ + public function getBusinessUnits(); + /** * @param ?SearchIndexingConfigurationValues $products */ @@ -69,4 +78,9 @@ public function setOrders(?SearchIndexingConfigurationValues $orders): void; * @param ?SearchIndexingConfigurationValues $customers */ public function setCustomers(?SearchIndexingConfigurationValues $customers): void; + + /** + * @param ?SearchIndexingConfigurationValues $businessUnits + */ + public function setBusinessUnits(?SearchIndexingConfigurationValues $businessUnits): void; } diff --git a/lib/commercetools-api/src/Models/Project/SearchIndexingConfigurationBuilder.php b/lib/commercetools-api/src/Models/Project/SearchIndexingConfigurationBuilder.php index c7d14b8322a..7f1f7f265cb 100644 --- a/lib/commercetools-api/src/Models/Project/SearchIndexingConfigurationBuilder.php +++ b/lib/commercetools-api/src/Models/Project/SearchIndexingConfigurationBuilder.php @@ -44,6 +44,12 @@ final class SearchIndexingConfigurationBuilder implements Builder */ private $customers; + /** + + * @var null|SearchIndexingConfigurationValues|SearchIndexingConfigurationValuesBuilder + */ + private $businessUnits; + /** *

Configuration for the Product Projection Search and Product Suggestions endpoints.

* @@ -88,6 +94,17 @@ public function getCustomers() return $this->customers instanceof SearchIndexingConfigurationValuesBuilder ? $this->customers->build() : $this->customers; } + /** + *

Configuration for the Business Unit Search feature.

+ * + + * @return null|SearchIndexingConfigurationValues + */ + public function getBusinessUnits() + { + return $this->businessUnits instanceof SearchIndexingConfigurationValuesBuilder ? $this->businessUnits->build() : $this->businessUnits; + } + /** * @param ?SearchIndexingConfigurationValues $products * @return $this @@ -132,6 +149,17 @@ public function withCustomers(?SearchIndexingConfigurationValues $customers) return $this; } + /** + * @param ?SearchIndexingConfigurationValues $businessUnits + * @return $this + */ + public function withBusinessUnits(?SearchIndexingConfigurationValues $businessUnits) + { + $this->businessUnits = $businessUnits; + + return $this; + } + /** * @deprecated use withProducts() instead * @return $this @@ -176,13 +204,25 @@ public function withCustomersBuilder(?SearchIndexingConfigurationValuesBuilder $ return $this; } + /** + * @deprecated use withBusinessUnits() instead + * @return $this + */ + public function withBusinessUnitsBuilder(?SearchIndexingConfigurationValuesBuilder $businessUnits) + { + $this->businessUnits = $businessUnits; + + return $this; + } + public function build(): SearchIndexingConfiguration { return new SearchIndexingConfigurationModel( $this->products instanceof SearchIndexingConfigurationValuesBuilder ? $this->products->build() : $this->products, $this->productsSearch instanceof SearchIndexingConfigurationValuesBuilder ? $this->productsSearch->build() : $this->productsSearch, $this->orders instanceof SearchIndexingConfigurationValuesBuilder ? $this->orders->build() : $this->orders, - $this->customers instanceof SearchIndexingConfigurationValuesBuilder ? $this->customers->build() : $this->customers + $this->customers instanceof SearchIndexingConfigurationValuesBuilder ? $this->customers->build() : $this->customers, + $this->businessUnits instanceof SearchIndexingConfigurationValuesBuilder ? $this->businessUnits->build() : $this->businessUnits ); } diff --git a/lib/commercetools-api/src/Models/Project/SearchIndexingConfigurationModel.php b/lib/commercetools-api/src/Models/Project/SearchIndexingConfigurationModel.php index d8405925d0c..5958fa720ec 100644 --- a/lib/commercetools-api/src/Models/Project/SearchIndexingConfigurationModel.php +++ b/lib/commercetools-api/src/Models/Project/SearchIndexingConfigurationModel.php @@ -43,6 +43,12 @@ final class SearchIndexingConfigurationModel extends JsonObjectModel implements */ protected $customers; + /** + * + * @var ?SearchIndexingConfigurationValues + */ + protected $businessUnits; + /** * @psalm-suppress MissingParamType @@ -51,12 +57,14 @@ public function __construct( ?SearchIndexingConfigurationValues $products = null, ?SearchIndexingConfigurationValues $productsSearch = null, ?SearchIndexingConfigurationValues $orders = null, - ?SearchIndexingConfigurationValues $customers = null + ?SearchIndexingConfigurationValues $customers = null, + ?SearchIndexingConfigurationValues $businessUnits = null ) { $this->products = $products; $this->productsSearch = $productsSearch; $this->orders = $orders; $this->customers = $customers; + $this->businessUnits = $businessUnits; } /** @@ -143,6 +151,27 @@ public function getCustomers() return $this->customers; } + /** + *

Configuration for the Business Unit Search feature.

+ * + * + * @return null|SearchIndexingConfigurationValues + */ + public function getBusinessUnits() + { + if (is_null($this->businessUnits)) { + /** @psalm-var stdClass|array|null $data */ + $data = $this->raw(self::FIELD_BUSINESS_UNITS); + if (is_null($data)) { + return null; + } + + $this->businessUnits = SearchIndexingConfigurationValuesModel::of($data); + } + + return $this->businessUnits; + } + /** * @param ?SearchIndexingConfigurationValues $products @@ -175,4 +204,12 @@ public function setCustomers(?SearchIndexingConfigurationValues $customers): voi { $this->customers = $customers; } + + /** + * @param ?SearchIndexingConfigurationValues $businessUnits + */ + public function setBusinessUnits(?SearchIndexingConfigurationValues $businessUnits): void + { + $this->businessUnits = $businessUnits; + } } diff --git a/references.txt b/references.txt index 290ad299e1a..55afd8f0daf 100644 --- a/references.txt +++ b/references.txt @@ -340,3 +340,4 @@ df53588d26d7953dfdf44166866ca03045f0a70b 4025ec42d633ae6b77320e24f6244d9dce608e6e 7abe530c4e76020a59ffb61623f20b87ae406e02 55ee33c4d18af345c4e89be226286c56c187a878 +e5666d7956fd6de53e41f965b052896d2a2ddd9b