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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 5 additions & 11 deletions changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -622,16 +622,10 @@
**History changes**

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

- :warning: changed property `extensions` of type `GraphQLError` from type `GraphQLErrorObject` to `object`
</details>


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

- :warning: changed property `triggerPattern` of type `ChangeTargetPatternChangeValue` to be required
- added type `TooManyRequestsError`
- added type `GraphQLTooManyRequestsError`
</details>


Expand All @@ -653,8 +647,8 @@


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

- :warning: removed type `GraphQLErrorObject`
- :warning: changed property `triggerPattern` of type `ChangeTargetPatternChangeValue` to be required
</details>

Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ function (HistoryRequestBuilder $builder): RequestInterface {
},
403
],
'ByProjectKeyByResourceTypeByIDGet_429' => [
function (HistoryRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKeyValue("projectKey")
->withResourceTypeValue("resourceType")
->withIDValue("ID")
->get();
},
429
],
'ByProjectKeyByResourceTypeByIDGet_500' => [
function (HistoryRequestBuilder $builder): RequestInterface {
return $builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,15 @@ function (HistoryRequestBuilder $builder): RequestInterface {
},
403
],
'ByProjectKeyByResourceTypeGet_429' => [
function (HistoryRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKeyValue("projectKey")
->withResourceTypeValue("resourceType")
->get();
},
429
],
'ByProjectKeyByResourceTypeGet_500' => [
function (HistoryRequestBuilder $builder): RequestInterface {
return $builder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,14 @@ function (HistoryRequestBuilder $builder): RequestInterface {
},
403
],
'ByProjectKeyGet_429' => [
function (HistoryRequestBuilder $builder): RequestInterface {
return $builder
->withProjectKeyValue("projectKey")
->get();
},
429
],
'ByProjectKeyGet_500' => [
function (HistoryRequestBuilder $builder): RequestInterface {
return $builder
Expand Down
9 changes: 9 additions & 0 deletions lib/commercetools-history/docs/RequestBuilder.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ $root = new HistoryRequestBuilder();

The `view_audit_log:{projectKey}` scope is required, and depending on the [resource type](ctp:history:type:ChangeHistoryResourceType) queried, their respective scopes must be granted.

If the request exceeds the rate limit, a [TooManyRequests](ctp:history:type:TooManyRequestsError) error is returned.


### Example
```php
use Commercetools\History\Client\HistoryRequestBuilder;
Expand All @@ -25,6 +28,9 @@ $request = $builder

The `view_audit_log:{projectKey}` scope is required, and depending on the [resource type](ctp:history:type:ChangeHistoryResourceType) queried, their respective scopes must be granted.

If the request exceeds the rate limit, a [TooManyRequests](ctp:history:type:TooManyRequestsError) error is returned.


### Example
```php
use Commercetools\History\Client\HistoryRequestBuilder;
Expand All @@ -39,6 +45,9 @@ $request = $builder

The `view_audit_log:{projectKey}` scope is required, and depending on the [resource type](ctp:history:type:ChangeHistoryResourceType) queried, their respective scopes must be granted.

If the request exceeds the rate limit, a [TooManyRequests](ctp:history:type:TooManyRequestsError) error is returned.


### Example
```php
use Commercetools\History\Client\HistoryRequestBuilder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public function mapFromResponse(?ResponseInterface $response, ?string $resultTyp
case '403':
$resultType = ErrorResponseModel::class;

break;
case '429':
$resultType = ErrorResponseModel::class;

break;
case '500':
$resultType = ErrorResponseModel::class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public function mapFromResponse(?ResponseInterface $response, ?string $resultTyp
case '403':
$resultType = ErrorResponseModel::class;

break;
case '429':
$resultType = ErrorResponseModel::class;

break;
case '500':
$resultType = ErrorResponseModel::class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ public function mapFromResponse(?ResponseInterface $response, ?string $resultTyp
case '403':
$resultType = ErrorResponseModel::class;

break;
case '429':
$resultType = ErrorResponseModel::class;

break;
case '500':
$resultType = ErrorResponseModel::class;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

use Commercetools\Base\JsonObject;
use Commercetools\Base\DateTimeImmutableCollection;
use Commercetools\History\Models\Error\TooManyRequestsError;

interface ErrorObject extends JsonObject
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
use Commercetools\Base\JsonObjectModel;
use Commercetools\Base\MapperFactory;
use stdClass;
use Commercetools\History\Models\Error\TooManyRequestsError;
use Commercetools\History\Models\Error\TooManyRequestsErrorBuilder;

/**
* @implements Builder<ErrorObject>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,20 @@
use stdClass;

/**
* @extends MapperSequence<ErrorObject>
* @template T of ErrorObject
* @extends MapperSequence<T>
* @psalm-method T current()
* @psalm-method T end()
* @psalm-method T at($offset)
* @method ErrorObject current()
* @method ErrorObject end()
* @method ErrorObject at($offset)
*/
class ErrorObjectCollection extends MapperSequence
{
/**
* @psalm-assert ErrorObject $value
* @psalm-param ErrorObject|stdClass $value
* @psalm-assert T $value
* @psalm-param T|stdClass $value
* @throws InvalidArgumentException
*
* @return ErrorObjectCollection
Expand All @@ -38,14 +42,14 @@ public function add($value)
}

/**
* @psalm-return callable(int):?ErrorObject
* @psalm-return callable(int):?T
*/
protected function mapper()
{
return function (?int $index): ?ErrorObject {
$data = $this->get($index);
if ($data instanceof stdClass) {
/** @var ErrorObject $data */
/** @var T $data */
$data = ErrorObjectModel::of($data);
$this->set($data, $index);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Commercetools\Base\JsonObjectModel;
use Commercetools\Base\MapperFactory;
use stdClass;
use Commercetools\History\Models\Error\TooManyRequestsError;
use Commercetools\History\Models\Error\TooManyRequestsErrorModel;

/**
* @internal
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

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

namespace Commercetools\History\Models\Error;

use Commercetools\Base\JsonObject;
use Commercetools\Base\DateTimeImmutableCollection;

interface GraphQLErrorObject extends JsonObject
{
public const DISCRIMINATOR_FIELD = 'code';
public const FIELD_CODE = 'code';
public const FIELD_PATTERN1 = '//';

/**
* <p>One of the error codes that is listed on the <a href="/errors">Errors</a> page.</p>
*

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

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

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

namespace Commercetools\History\Models\Error;

use Commercetools\Base\Builder;
use Commercetools\Base\DateTimeImmutableCollection;
use Commercetools\Base\JsonObject;
use Commercetools\Base\JsonObjectModel;
use Commercetools\Base\MapperFactory;
use stdClass;

/**
* @implements Builder<GraphQLErrorObject>
*/
final class GraphQLErrorObjectBuilder implements Builder
{




public function build(): GraphQLErrorObject
{
return new GraphQLErrorObjectModel(
);
}

public static function of(): GraphQLErrorObjectBuilder
{
return new self();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php

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

namespace Commercetools\History\Models\Error;

use Commercetools\Base\MapperSequence;
use Commercetools\Exception\InvalidArgumentException;
use stdClass;

/**
* @template T of GraphQLErrorObject
* @extends MapperSequence<T>
* @psalm-method T current()
* @psalm-method T end()
* @psalm-method T at($offset)
* @method GraphQLErrorObject current()
* @method GraphQLErrorObject end()
* @method GraphQLErrorObject at($offset)
*/
class GraphQLErrorObjectCollection extends MapperSequence
{
/**
* @psalm-assert T $value
* @psalm-param T|stdClass $value
* @throws InvalidArgumentException
*
* @return GraphQLErrorObjectCollection
*/
public function add($value)
{
if (!$value instanceof GraphQLErrorObject) {
throw new InvalidArgumentException();
}
$this->store($value);

return $this;
}

/**
* @psalm-return callable(int):?T
*/
protected function mapper()
{
return function (?int $index): ?GraphQLErrorObject {
$data = $this->get($index);
if ($data instanceof stdClass) {
/** @var T $data */
$data = GraphQLErrorObjectModel::of($data);
$this->set($data, $index);
}

return $data;
};
}
}
Loading