Skip to content

Commit

Permalink
build(codegen): updating SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
ct-sdks[bot] committed Jan 18, 2024
1 parent 04d3866 commit 43f34c1
Show file tree
Hide file tree
Showing 258 changed files with 20,058 additions and 653 deletions.
381 changes: 199 additions & 182 deletions changes.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,334 @@
<?php

declare(strict_types=1);
/**
* This file has been auto generated
* Do not change it.
*/

namespace Commercetools\Api\Test\Client\Resource;

use Commercetools\Api\Client\ApiRequestBuilder;
use Commercetools\Base\JsonObject;
use Commercetools\Client\ApiRequest;
use Commercetools\Exception\ApiClientException;
use Commercetools\Exception\ApiServerException;
use GuzzleHttp\ClientInterface;
use GuzzleHttp\Exception\ClientException;
use GuzzleHttp\Exception\ServerException;
use GuzzleHttp\Psr7\Response;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\RequestInterface;

/**
* @covers \Commercetools\Api\Client\Resource\ByProjectKeyProductsSearchPost
* @covers \Commercetools\Api\Client\Resource\ByProjectKeyProductsSearchHead
* @covers \Commercetools\Api\Client\Resource\ResourceByProjectKeyProductsSearch
*/
class ResourceByProjectKeyProductsSearchTest extends TestCase
{
/**
* @dataProvider getRequests()
*/
public function testBuilder(callable $builderFunction, string $method, string $relativeUri, string $body = null)
{
$builder = new ApiRequestBuilder();
$request = $builderFunction($builder);
$this->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 [
'ByProjectKeyProductsSearchPost' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("test_projectKey")
->products()
->search()
->post(null);
},
'post',
'test_projectKey/products/search',
],
'ByProjectKeyProductsSearchHead' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("test_projectKey")
->products()
->search()
->head();
},
'head',
'test_projectKey/products/search',
]
];
}

public function getResources()
{
return [
];
}

public function getRequestBuilders()
{
return [
'ByProjectKeyProductsSearchPost' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
}
],
'ByProjectKeyProductsSearchHead' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
}
]
];
}

public function getRequestBuilderResponses()
{
return [
'ByProjectKeyProductsSearchPost_200' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
200
],
'ByProjectKeyProductsSearchPost_400' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
400
],
'ByProjectKeyProductsSearchPost_401' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
401
],
'ByProjectKeyProductsSearchPost_403' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
403
],
'ByProjectKeyProductsSearchPost_404' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
404
],
'ByProjectKeyProductsSearchPost_500' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
500
],
'ByProjectKeyProductsSearchPost_502' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
502
],
'ByProjectKeyProductsSearchPost_503' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
503
],
'ByProjectKeyProductsSearchPost_599' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
},
599
],
'ByProjectKeyProductsSearchHead_200' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
200
],
'ByProjectKeyProductsSearchHead_404' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
404
],
'ByProjectKeyProductsSearchHead_400' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
400
],
'ByProjectKeyProductsSearchHead_401' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
401
],
'ByProjectKeyProductsSearchHead_403' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
403
],
'ByProjectKeyProductsSearchHead_500' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
500
],
'ByProjectKeyProductsSearchHead_502' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
502
],
'ByProjectKeyProductsSearchHead_503' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
503
],
'ByProjectKeyProductsSearchHead_599' => [
function (ApiRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
},
599
]
];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Commercetools\Api\Client\ApiRequestBuilder;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyProductsByID;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyProductsKeyByKey;
use Commercetools\Api\Client\Resource\ResourceByProjectKeyProductsSearch;
use Commercetools\Base\JsonObject;
use Commercetools\Client\ApiRequest;
use Commercetools\Exception\ApiClientException;
Expand Down Expand Up @@ -369,6 +370,17 @@ function (ApiRequestBuilder $builder): ResourceByProjectKeyProductsByID {
ResourceByProjectKeyProductsByID::class,
['projectKey' => 'test_projectKey', 'ID' => 'test_ID'],
'/{projectKey}/products/{ID}'
],
'ResourceByProjectKeyProductsSearch' => [
function (ApiRequestBuilder $builder): ResourceByProjectKeyProductsSearch {
return $builder
->withProjectKey("test_projectKey")
->products()
->search();
},
ResourceByProjectKeyProductsSearch::class,
['projectKey' => 'test_projectKey'],
'/{projectKey}/products/search'
]
];
}
Expand Down
30 changes: 30 additions & 0 deletions lib/commercetools-api/docs/RequestBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -7979,6 +7979,36 @@ $request = $builder
->productSelections()
->get();
```
## `withProjectKey("projectKey")->products()->search()->post(null)`

null

### Example
```php
use Commercetools\Api\Client\ApiRequestBuilder;

$builder = new ApiRequestBuilder();
$request = $builder
->withProjectKey("projectKey")
->products()
->search()
->post(null);
```
## `withProjectKey("projectKey")->products()->search()->head()`

Checks whether a search index for the Project's Products exists.

### Example
```php
use Commercetools\Api\Client\ApiRequestBuilder;

$builder = new ApiRequestBuilder();
$request = $builder
->withProjectKey("projectKey")
->products()
->search()
->head();
```
## `withProjectKey("projectKey")->quoteRequests()->get()`

null
Expand Down
Loading

0 comments on commit 43f34c1

Please sign in to comment.