Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
38 changes: 38 additions & 0 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,13 @@

**Import changes**

<details>
<summary>Added Enum(s)</summary>

- added enum `product-selection` to type `ImportResourceType`
</details>


<details>
<summary>Added Property(s)</summary>

Expand All @@ -418,6 +425,14 @@
</details>


<details>
<summary>Changed Property(s)</summary>

- :warning: changed property `country` of type `ExternalTaxRateDraft` from type `string` to `CountryCode`
- :warning: changed property `value` of type `MoneySetField` from type `Money[]` to `TypedMoney[]`
</details>


<details>
<summary>Removed Property(s)</summary>

Expand All @@ -426,14 +441,37 @@
</details>


<details>
<summary>Added Method(s)</summary>

- added method `$apiRoot->withProjectKeyValue()->productSelections()->importContainers()->withImportContainerKeyValue()->post()`
</details>


<details>
<summary>Added Type(s)</summary>

- added type `StrategyEnum`
- added type `RetentionPolicy`
- added type `TimeToLiveConfig`
- added type `TimeToLiveRetentionPolicy`
- added type `ProductSelectionImportRequest`
- added type `AttributeLevel`
- added type `VariantSelectionType`
- added type `VariantSelection`
- added type `VariantExclusion`
- added type `ProductSelectionAssignment`
- added type `ProductSelectionMode`
- added type `ProductSelectionImport`
</details>


<details>
<summary>Added Resource(s)</summary>

- added resource `/{projectKey}/product-selections`
- added resource `/{projectKey}/product-selections/import-containers`
- added resource `/{projectKey}/product-selections/import-containers/{importContainerKey}`
</details>

**History changes**
Expand Down
2 changes: 1 addition & 1 deletion lib/commercetools-api/src/Models/Common/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface Asset extends JsonObject
public const FIELD_KEY = 'key';

/**
* <p>Unique identifier of the Asset.</p>
* <p>Unique identifier of the Asset. Not required when importing Assets using the <a href="/import-export/import-resources">Import API</a>.</p>
*

* @return null|string
Expand Down
2 changes: 1 addition & 1 deletion lib/commercetools-api/src/Models/Common/AssetBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ final class AssetBuilder implements Builder
private $key;

/**
* <p>Unique identifier of the Asset.</p>
* <p>Unique identifier of the Asset. Not required when importing Assets using the <a href="/import-export/import-resources">Import API</a>.</p>
*

* @return null|string
Expand Down
2 changes: 1 addition & 1 deletion lib/commercetools-api/src/Models/Common/AssetModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public function __construct(
}

/**
* <p>Unique identifier of the Asset.</p>
* <p>Unique identifier of the Asset. Not required when importing Assets using the <a href="/import-export/import-resources">Import API</a>.</p>
*
*
* @return null|string
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
<?php

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

namespace Commercetools\Import\Test\Client\Resource;

use Commercetools\Base\JsonObject;
use Commercetools\Client\ApiRequest;
use Commercetools\Exception\ApiClientException;
use Commercetools\Exception\ApiServerException;
use Commercetools\Import\Client\ImportRequestBuilder;
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\Import\Client\Resource\ByProjectKeyProductSelectionsImportContainersByImportContainerKeyPost
* @covers \Commercetools\Import\Client\Resource\ResourceByProjectKeyProductSelectionsImportContainersByImportContainerKey
*/
class ResourceByProjectKeyProductSelectionsImportContainersByImportContainerKeyTest extends TestCase
{
/**
* @dataProvider getRequests()
*/
public function testBuilder(callable $builderFunction, string $method, string $relativeUri, ?string $body = null)
{
$builder = new ImportRequestBuilder();
$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 ImportRequestBuilder();
$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 ImportRequestBuilder($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 ImportRequestBuilder($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 [
'ByProjectKeyProductSelectionsImportContainersByImportContainerKeyPost' => [
function (ImportRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKeyValue("test_projectKey")
->productSelections()
->importContainers()
->withImportContainerKeyValue("test_importContainerKey")
->post(null);
},
'post',
'test_projectKey/product-selections/import-containers/test_importContainerKey',
]
];
}

public function getResources()
{
return [
];
}

public function getRequestBuilders()
{
return [
'ByProjectKeyProductSelectionsImportContainersByImportContainerKeyPost' => [
function (ImportRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKeyValue("projectKey")
->productSelections()
->importContainers()
->withImportContainerKeyValue("importContainerKey")
->post(null);
}
]
];
}

public function getRequestBuilderResponses()
{
return [
'ByProjectKeyProductSelectionsImportContainersByImportContainerKeyPost_201' => [
function (ImportRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKeyValue("projectKey")
->productSelections()
->importContainers()
->withImportContainerKeyValue("importContainerKey")
->post(null);
},
201
],
'ByProjectKeyProductSelectionsImportContainersByImportContainerKeyPost_400' => [
function (ImportRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKeyValue("projectKey")
->productSelections()
->importContainers()
->withImportContainerKeyValue("importContainerKey")
->post(null);
},
400
],
'ByProjectKeyProductSelectionsImportContainersByImportContainerKeyPost_599' => [
function (ImportRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKeyValue("projectKey")
->productSelections()
->importContainers()
->withImportContainerKeyValue("importContainerKey")
->post(null);
},
599
]
];
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?php

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

namespace Commercetools\Import\Test\Client\Resource;

use Commercetools\Base\JsonObject;
use Commercetools\Client\ApiRequest;
use Commercetools\Exception\ApiClientException;
use Commercetools\Exception\ApiServerException;
use Commercetools\Import\Client\ImportRequestBuilder;
use Commercetools\Import\Client\Resource\ResourceByProjectKeyProductSelectionsImportContainersByImportContainerKey;
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\Import\Client\Resource\ResourceByProjectKeyProductSelectionsImportContainers
*/
class ResourceByProjectKeyProductSelectionsImportContainersTest extends TestCase
{
/**
* @dataProvider getResources()
*/
public function testResources(callable $builderFunction, string $class, array $expectedArgs)
{
$builder = new ImportRequestBuilder();
$resource = $builderFunction($builder);
$this->assertInstanceOf($class, $resource);
$this->assertEquals($expectedArgs, $resource->getArgs());
}







public function getRequests()
{
return [
];
}

public function getResources()
{
return [
'ResourceByProjectKeyProductSelectionsImportContainersByImportContainerKey' => [
function (ImportRequestBuilder $builder): ResourceByProjectKeyProductSelectionsImportContainersByImportContainerKey {
return $builder
->withProjectKeyValue("test_projectKey")
->productSelections()
->importContainers()
->withImportContainerKeyValue("test_importContainerKey");
},
ResourceByProjectKeyProductSelectionsImportContainersByImportContainerKey::class,
['projectKey' => 'test_projectKey', 'importContainerKey' => 'test_importContainerKey'],
'/{projectKey}/product-selections/import-containers/{importContainerKey}'
]
];
}

public function getRequestBuilders()
{
return [
];
}

public function getRequestBuilderResponses()
{
return [
];
}
}
Loading
Loading