diff --git a/changes.md b/changes.md
index e3e21373500..fa719b9fb3a 100644
--- a/changes.md
+++ b/changes.md
@@ -622,16 +622,10 @@
**History changes**
-Changed Property(s)
-
-- :warning: changed property `extensions` of type `GraphQLError` from type `GraphQLErrorObject` to `object`
-
-
-
-
-Required Property(s)
+Added Type(s)
-- :warning: changed property `triggerPattern` of type `ChangeTargetPatternChangeValue` to be required
+- added type `TooManyRequestsError`
+- added type `GraphQLTooManyRequestsError`
@@ -653,8 +647,8 @@
-Removed Type(s)
+Required Property(s)
-- :warning: removed type `GraphQLErrorObject`
+- :warning: changed property `triggerPattern` of type `ChangeTargetPatternChangeValue` to be required
diff --git a/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyByResourceTypeByIDTest.php b/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyByResourceTypeByIDTest.php
index 1ca90cdca17..caa53303061 100644
--- a/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyByResourceTypeByIDTest.php
+++ b/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyByResourceTypeByIDTest.php
@@ -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
diff --git a/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyByResourceTypeTest.php b/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyByResourceTypeTest.php
index 669ff073aa2..fd6c93db712 100644
--- a/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyByResourceTypeTest.php
+++ b/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyByResourceTypeTest.php
@@ -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
diff --git a/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php b/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php
index e01f3b09ea1..e3eac1fe09a 100644
--- a/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php
+++ b/lib/commercetools-history-tests/test/unit/Client/Resource/ResourceByProjectKeyTest.php
@@ -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
diff --git a/lib/commercetools-history/docs/RequestBuilder.md b/lib/commercetools-history/docs/RequestBuilder.md
index 393dd9f4c2f..0f25dd350a2 100644
--- a/lib/commercetools-history/docs/RequestBuilder.md
+++ b/lib/commercetools-history/docs/RequestBuilder.md
@@ -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;
@@ -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;
@@ -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;
diff --git a/lib/commercetools-history/src/Client/Resource/ByProjectKeyByResourceTypeByIDGet.php b/lib/commercetools-history/src/Client/Resource/ByProjectKeyByResourceTypeByIDGet.php
index 7e88f40e78b..ef61244b196 100644
--- a/lib/commercetools-history/src/Client/Resource/ByProjectKeyByResourceTypeByIDGet.php
+++ b/lib/commercetools-history/src/Client/Resource/ByProjectKeyByResourceTypeByIDGet.php
@@ -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;
diff --git a/lib/commercetools-history/src/Client/Resource/ByProjectKeyByResourceTypeGet.php b/lib/commercetools-history/src/Client/Resource/ByProjectKeyByResourceTypeGet.php
index 56412602e7c..5ed9732b143 100644
--- a/lib/commercetools-history/src/Client/Resource/ByProjectKeyByResourceTypeGet.php
+++ b/lib/commercetools-history/src/Client/Resource/ByProjectKeyByResourceTypeGet.php
@@ -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;
diff --git a/lib/commercetools-history/src/Client/Resource/ByProjectKeyGet.php b/lib/commercetools-history/src/Client/Resource/ByProjectKeyGet.php
index f4db6b6882e..910de2fe931 100644
--- a/lib/commercetools-history/src/Client/Resource/ByProjectKeyGet.php
+++ b/lib/commercetools-history/src/Client/Resource/ByProjectKeyGet.php
@@ -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;
diff --git a/lib/commercetools-history/src/Models/ChangeHistory/ErrorObject.php b/lib/commercetools-history/src/Models/ChangeHistory/ErrorObject.php
index 9a834352108..34d7b69a73d 100644
--- a/lib/commercetools-history/src/Models/ChangeHistory/ErrorObject.php
+++ b/lib/commercetools-history/src/Models/ChangeHistory/ErrorObject.php
@@ -10,6 +10,7 @@
use Commercetools\Base\JsonObject;
use Commercetools\Base\DateTimeImmutableCollection;
+use Commercetools\History\Models\Error\TooManyRequestsError;
interface ErrorObject extends JsonObject
{
diff --git a/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectBuilder.php b/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectBuilder.php
index 25d1577e6c6..1d941d8dbb7 100644
--- a/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectBuilder.php
+++ b/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectBuilder.php
@@ -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
diff --git a/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectCollection.php b/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectCollection.php
index 91ff495697f..9e93ad4bc52 100644
--- a/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectCollection.php
+++ b/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectCollection.php
@@ -13,7 +13,11 @@
use stdClass;
/**
- * @extends MapperSequence
+ * @template T of ErrorObject
+ * @extends MapperSequence
+ * @psalm-method T current()
+ * @psalm-method T end()
+ * @psalm-method T at($offset)
* @method ErrorObject current()
* @method ErrorObject end()
* @method ErrorObject at($offset)
@@ -21,8 +25,8 @@
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
@@ -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);
}
diff --git a/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectModel.php b/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectModel.php
index 4d221263ce6..f2afe233742 100644
--- a/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectModel.php
+++ b/lib/commercetools-history/src/Models/ChangeHistory/ErrorObjectModel.php
@@ -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
diff --git a/lib/commercetools-history/src/Models/Error/GraphQLErrorObject.php b/lib/commercetools-history/src/Models/Error/GraphQLErrorObject.php
new file mode 100644
index 00000000000..156108a46eb
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/GraphQLErrorObject.php
@@ -0,0 +1,28 @@
+One of the error codes that is listed on the Errors page.
+ *
+
+ * @return null|string
+ */
+ public function getCode();
+
+}
diff --git a/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectBuilder.php b/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectBuilder.php
new file mode 100644
index 00000000000..8e57eb2f89b
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectBuilder.php
@@ -0,0 +1,37 @@
+
+ */
+final class GraphQLErrorObjectBuilder implements Builder
+{
+
+
+
+
+ public function build(): GraphQLErrorObject
+ {
+ return new GraphQLErrorObjectModel(
+ );
+ }
+
+ public static function of(): GraphQLErrorObjectBuilder
+ {
+ return new self();
+ }
+}
diff --git a/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectCollection.php b/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectCollection.php
new file mode 100644
index 00000000000..082a09581de
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectCollection.php
@@ -0,0 +1,60 @@
+
+ * @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;
+ };
+ }
+}
diff --git a/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectModel.php b/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectModel.php
new file mode 100644
index 00000000000..b479db75ef2
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectModel.php
@@ -0,0 +1,114 @@
+ >
+ *
+ */
+ private static $discriminatorClasses = [
+ 'TooManyRequests' => GraphQLTooManyRequestsErrorModel::class,
+ ];
+
+ /**
+ * @psalm-suppress MissingParamType
+ */
+ public function __construct(
+ ?string $code = null
+ ) {
+ $this->code = $code;
+
+ }
+
+ /**
+ * One of the error codes that is listed on the Errors page.
+ *
+ *
+ * @return null|string
+ */
+ public function getCode()
+ {
+ if (is_null($this->code)) {
+ /** @psalm-var ?string $data */
+ $data = $this->raw(self::FIELD_CODE);
+ if (is_null($data)) {
+ return null;
+ }
+ $this->code = (string) $data;
+ }
+
+ return $this->code;
+ }
+
+
+
+ /**
+ * @return mixed
+ */
+ public function by(string $key)
+ {
+ $data = $this->raw($key);
+ if (is_null($data)) {
+ return null;
+ }
+ if (preg_match(GraphQLErrorObject::FIELD_PATTERN1, $key) === 1) {
+ /** @psalm-var stdClass $data */
+ return JsonObjectModel::of($data);
+ }
+
+ return $data;
+ }
+
+
+ /**
+ * @psalm-param stdClass|array $value
+ * @psalm-return class-string
+ */
+ public static function resolveDiscriminatorClass($value): string
+ {
+ $fieldName = GraphQLErrorObject::DISCRIMINATOR_FIELD;
+ if (is_object($value) && isset($value->$fieldName)) {
+ /** @psalm-var string $discriminatorValue */
+ $discriminatorValue = $value->$fieldName;
+ if (isset(self::$discriminatorClasses[$discriminatorValue])) {
+ return self::$discriminatorClasses[$discriminatorValue];
+ }
+ }
+ if (is_array($value) && isset($value[$fieldName])) {
+ /** @psalm-var string $discriminatorValue */
+ $discriminatorValue = $value[$fieldName];
+ if (isset(self::$discriminatorClasses[$discriminatorValue])) {
+ return self::$discriminatorClasses[$discriminatorValue];
+ }
+ }
+
+ /** @psalm-var class-string */
+ $type = GraphQLErrorObjectModel::class;
+ return $type;
+ }
+}
diff --git a/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsError.php b/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsError.php
new file mode 100644
index 00000000000..0c6215d5b49
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsError.php
@@ -0,0 +1,24 @@
+
+ */
+final class GraphQLTooManyRequestsErrorBuilder implements Builder
+{
+
+
+
+
+ public function build(): GraphQLTooManyRequestsError
+ {
+ return new GraphQLTooManyRequestsErrorModel(
+ );
+ }
+
+ public static function of(): GraphQLTooManyRequestsErrorBuilder
+ {
+ return new self();
+ }
+}
diff --git a/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsErrorCollection.php b/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsErrorCollection.php
new file mode 100644
index 00000000000..a75372985f4
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsErrorCollection.php
@@ -0,0 +1,56 @@
+
+ * @method GraphQLTooManyRequestsError current()
+ * @method GraphQLTooManyRequestsError end()
+ * @method GraphQLTooManyRequestsError at($offset)
+ */
+class GraphQLTooManyRequestsErrorCollection extends GraphQLErrorObjectCollection
+{
+ /**
+ * @psalm-assert GraphQLTooManyRequestsError $value
+ * @psalm-param GraphQLTooManyRequestsError|stdClass $value
+ * @throws InvalidArgumentException
+ *
+ * @return GraphQLTooManyRequestsErrorCollection
+ */
+ public function add($value)
+ {
+ if (!$value instanceof GraphQLTooManyRequestsError) {
+ throw new InvalidArgumentException();
+ }
+ $this->store($value);
+
+ return $this;
+ }
+
+ /**
+ * @psalm-return callable(int):?GraphQLTooManyRequestsError
+ */
+ protected function mapper()
+ {
+ return function (?int $index): ?GraphQLTooManyRequestsError {
+ $data = $this->get($index);
+ if ($data instanceof stdClass) {
+ /** @var GraphQLTooManyRequestsError $data */
+ $data = GraphQLTooManyRequestsErrorModel::of($data);
+ $this->set($data, $index);
+ }
+
+ return $data;
+ };
+ }
+}
diff --git a/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsErrorModel.php b/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsErrorModel.php
new file mode 100644
index 00000000000..915576c0c22
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/GraphQLTooManyRequestsErrorModel.php
@@ -0,0 +1,74 @@
+code = $code ?? self::DISCRIMINATOR_VALUE;
+ }
+
+ /**
+ *
+ * @return null|string
+ */
+ public function getCode()
+ {
+ if (is_null($this->code)) {
+ /** @psalm-var ?string $data */
+ $data = $this->raw(self::FIELD_CODE);
+ if (is_null($data)) {
+ return null;
+ }
+ $this->code = (string) $data;
+ }
+
+ return $this->code;
+ }
+
+
+
+ /**
+ * @return mixed
+ */
+ public function by(string $key)
+ {
+ $data = $this->raw($key);
+ if (is_null($data)) {
+ return null;
+ }
+
+ return $data;
+ }
+
+
+}
diff --git a/lib/commercetools-history/src/Models/Error/TooManyRequestsError.php b/lib/commercetools-history/src/Models/Error/TooManyRequestsError.php
new file mode 100644
index 00000000000..a50d7dca90c
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/TooManyRequestsError.php
@@ -0,0 +1,44 @@
+"TooManyRequests"
+ *
+
+ * @return null|string
+ */
+ public function getCode();
+
+ /**
+ * "You have made too many requests. Please try again later."
+ *
+
+ * @return null|string
+ */
+ public function getMessage();
+
+ /**
+ * @param ?string $code
+ */
+ public function setCode(?string $code): void;
+
+ /**
+ * @param ?string $message
+ */
+ public function setMessage(?string $message): void;
+}
diff --git a/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorBuilder.php b/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorBuilder.php
new file mode 100644
index 00000000000..0ad17c06957
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorBuilder.php
@@ -0,0 +1,94 @@
+
+ */
+final class TooManyRequestsErrorBuilder implements Builder
+{
+ /**
+
+ * @var ?string
+ */
+ private $code;
+
+ /**
+
+ * @var ?string
+ */
+ private $message;
+
+ /**
+ * "TooManyRequests"
+ *
+
+ * @return null|string
+ */
+ public function getCode()
+ {
+ return $this->code;
+ }
+
+ /**
+ * "You have made too many requests. Please try again later."
+ *
+
+ * @return null|string
+ */
+ public function getMessage()
+ {
+ return $this->message;
+ }
+
+ /**
+ * @param ?string $code
+ * @return $this
+ */
+ public function withCode(?string $code)
+ {
+ $this->code = $code;
+
+ return $this;
+ }
+
+ /**
+ * @param ?string $message
+ * @return $this
+ */
+ public function withMessage(?string $message)
+ {
+ $this->message = $message;
+
+ return $this;
+ }
+
+
+ public function build(): TooManyRequestsError
+ {
+ return new TooManyRequestsErrorModel(
+ $this->code,
+ $this->message
+ );
+ }
+
+ public static function of(): TooManyRequestsErrorBuilder
+ {
+ return new self();
+ }
+}
diff --git a/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorCollection.php b/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorCollection.php
new file mode 100644
index 00000000000..906b81b36dd
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorCollection.php
@@ -0,0 +1,56 @@
+
+ * @method TooManyRequestsError current()
+ * @method TooManyRequestsError end()
+ * @method TooManyRequestsError at($offset)
+ */
+class TooManyRequestsErrorCollection extends ErrorObjectCollection
+{
+ /**
+ * @psalm-assert TooManyRequestsError $value
+ * @psalm-param TooManyRequestsError|stdClass $value
+ * @throws InvalidArgumentException
+ *
+ * @return TooManyRequestsErrorCollection
+ */
+ public function add($value)
+ {
+ if (!$value instanceof TooManyRequestsError) {
+ throw new InvalidArgumentException();
+ }
+ $this->store($value);
+
+ return $this;
+ }
+
+ /**
+ * @psalm-return callable(int):?TooManyRequestsError
+ */
+ protected function mapper()
+ {
+ return function (?int $index): ?TooManyRequestsError {
+ $data = $this->get($index);
+ if ($data instanceof stdClass) {
+ /** @var TooManyRequestsError $data */
+ $data = TooManyRequestsErrorModel::of($data);
+ $this->set($data, $index);
+ }
+
+ return $data;
+ };
+ }
+}
diff --git a/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorModel.php b/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorModel.php
new file mode 100644
index 00000000000..9fe68a982ac
--- /dev/null
+++ b/lib/commercetools-history/src/Models/Error/TooManyRequestsErrorModel.php
@@ -0,0 +1,110 @@
+code = $code;
+ $this->message = $message;
+
+ }
+
+ /**
+ * "TooManyRequests"
+ *
+ *
+ * @return null|string
+ */
+ public function getCode()
+ {
+ if (is_null($this->code)) {
+ /** @psalm-var ?string $data */
+ $data = $this->raw(self::FIELD_CODE);
+ if (is_null($data)) {
+ return null;
+ }
+ $this->code = (string) $data;
+ }
+
+ return $this->code;
+ }
+
+ /**
+ * "You have made too many requests. Please try again later."
+ *
+ *
+ * @return null|string
+ */
+ public function getMessage()
+ {
+ if (is_null($this->message)) {
+ /** @psalm-var ?string $data */
+ $data = $this->raw(self::FIELD_MESSAGE);
+ if (is_null($data)) {
+ return null;
+ }
+ $this->message = (string) $data;
+ }
+
+ return $this->message;
+ }
+
+
+ /**
+ * @param ?string $code
+ */
+ public function setCode(?string $code): void
+ {
+ $this->code = $code;
+ }
+
+ /**
+ * @param ?string $message
+ */
+ public function setMessage(?string $message): void
+ {
+ $this->message = $message;
+ }
+
+
+
+}
diff --git a/lib/commercetools-history/src/Models/GraphQl/GraphQLError.php b/lib/commercetools-history/src/Models/GraphQl/GraphQLError.php
index 252160bcd64..ee06bfabbfb 100644
--- a/lib/commercetools-history/src/Models/GraphQl/GraphQLError.php
+++ b/lib/commercetools-history/src/Models/GraphQl/GraphQLError.php
@@ -10,6 +10,7 @@
use Commercetools\Base\JsonObject;
use Commercetools\Base\DateTimeImmutableCollection;
+use Commercetools\History\Models\Error\GraphQLErrorObject;
interface GraphQLError extends JsonObject
{
@@ -47,7 +48,7 @@ public function getPath();
* Dictionary with additional information where applicable.
*
- * @return null|mixed
+ * @return null|GraphQLErrorObject
*/
public function getExtensions();
@@ -67,7 +68,7 @@ public function setLocations(?GraphQLErrorLocationCollection $locations): void;
public function setPath(?array $path): void;
/**
- * @param ?JsonObject $extensions
+ * @param ?GraphQLErrorObject $extensions
*/
- public function setExtensions(?JsonObject $extensions): void;
+ public function setExtensions(?GraphQLErrorObject $extensions): void;
}
diff --git a/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorBuilder.php b/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorBuilder.php
index 05b6b0e07d1..95278d33a16 100644
--- a/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorBuilder.php
+++ b/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorBuilder.php
@@ -14,6 +14,8 @@
use Commercetools\Base\JsonObjectModel;
use Commercetools\Base\MapperFactory;
use stdClass;
+use Commercetools\History\Models\Error\GraphQLErrorObject;
+use Commercetools\History\Models\Error\GraphQLErrorObjectBuilder;
/**
* @implements Builder
@@ -40,7 +42,7 @@ final class GraphQLErrorBuilder implements Builder
/**
- * @var ?JsonObject
+ * @var null|GraphQLErrorObject|GraphQLErrorObjectBuilder
*/
private $extensions;
@@ -81,11 +83,11 @@ public function getPath()
* Dictionary with additional information where applicable.
*
- * @return null|JsonObject
+ * @return null|GraphQLErrorObject
*/
public function getExtensions()
{
- return $this->extensions;
+ return $this->extensions instanceof GraphQLErrorObjectBuilder ? $this->extensions->build() : $this->extensions;
}
/**
@@ -122,16 +124,26 @@ public function withPath(?array $path)
}
/**
- * @param ?JsonObject $extensions
+ * @param ?GraphQLErrorObject $extensions
* @return $this
*/
- public function withExtensions(?JsonObject $extensions)
+ public function withExtensions(?GraphQLErrorObject $extensions)
{
$this->extensions = $extensions;
return $this;
}
+ /**
+ * @deprecated use withExtensions() instead
+ * @return $this
+ */
+ public function withExtensionsBuilder(?GraphQLErrorObjectBuilder $extensions)
+ {
+ $this->extensions = $extensions;
+
+ return $this;
+ }
public function build(): GraphQLError
{
@@ -139,7 +151,7 @@ public function build(): GraphQLError
$this->message,
$this->locations,
$this->path,
- $this->extensions
+ $this->extensions instanceof GraphQLErrorObjectBuilder ? $this->extensions->build() : $this->extensions
);
}
diff --git a/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorModel.php b/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorModel.php
index a6d2c7ba24e..090b2f8d31b 100644
--- a/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorModel.php
+++ b/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorModel.php
@@ -13,6 +13,8 @@
use Commercetools\Base\JsonObjectModel;
use Commercetools\Base\MapperFactory;
use stdClass;
+use Commercetools\History\Models\Error\GraphQLErrorObject;
+use Commercetools\History\Models\Error\GraphQLErrorObjectModel;
/**
* @internal
@@ -41,7 +43,7 @@ final class GraphQLErrorModel extends JsonObjectModel implements GraphQLError
/**
*
- * @var ?mixed
+ * @var ?GraphQLErrorObject
*/
protected $extensions;
@@ -53,7 +55,7 @@ public function __construct(
?string $message = null,
?GraphQLErrorLocationCollection $locations = null,
?array $path = null,
- ?JsonObject $extensions = null
+ ?GraphQLErrorObject $extensions = null
) {
$this->message = $message;
$this->locations = $locations;
@@ -126,7 +128,7 @@ public function getPath()
* Dictionary with additional information where applicable.
*
*
- * @return null|mixed
+ * @return null|GraphQLErrorObject
*/
public function getExtensions()
{
@@ -136,7 +138,8 @@ public function getExtensions()
if (is_null($data)) {
return null;
}
- $this->extensions = JsonObjectModel::of($data);
+ $className = GraphQLErrorObjectModel::resolveDiscriminatorClass($data);
+ $this->extensions = $className::of($data);
}
return $this->extensions;
@@ -168,9 +171,9 @@ public function setPath(?array $path): void
}
/**
- * @param ?JsonObject $extensions
+ * @param ?GraphQLErrorObject $extensions
*/
- public function setExtensions(?JsonObject $extensions): void
+ public function setExtensions(?GraphQLErrorObject $extensions): void
{
$this->extensions = $extensions;
}
diff --git a/references.txt b/references.txt
index c5bfb786754..5acd9786029 100644
--- a/references.txt
+++ b/references.txt
@@ -472,3 +472,4 @@ a3b3120c87d02dcb4019d8f0dcc6d1f7496725ca
0e52ed3672e48fed855eed94497de9b16e7a50fa
e4973c1b97c71699c2945d476161cd47eded2e6d
c47b5eda641591a8ffe2eb071826f157e2150771
+48cdda09a82127b5745d64a6b889a500a31139d8