diff --git a/changes.md b/changes.md index 107e80c15e4..c2f8369d30e 100644 --- a/changes.md +++ b/changes.md @@ -1,104 +1,15 @@ -**Api changes** - -
-Changed Property(s) - -- :warning: changed property `exact` of type `SearchExactExpression` from type `SearchAnyValue` to `SearchExactValue` -
- - -
-Added Property(s) - -- added property `applicationMode` to type `CartDiscountValueFixed` -- added property `applicationMode` to type `CartDiscountValueFixedDraft` -- added property `custom` to type `CartSetCustomShippingMethodAction` -- added property `custom` to type `StagedOrderSetCustomShippingMethodAction` -- added property `custom` to type `StagedOrderSetShippingAddressAndCustomShippingMethodAction` -- added property `businessUnits` to type `SearchIndexingConfiguration` -
- - -
-Added Resource(s) - -- added resource `/{projectKey}/business-units/search` -- added resource `/{projectKey}/business-units/search/indexing-status` -- added resource `/{projectKey}/channels/key={key}` -
- - -
-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()` -- added method `$apiRoot->withProjectKey()->channels()->withKey()->delete()` -
- - -
-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` -- added type `PatternComponent` -- added type `ShoppingListLineItemAddedMessage` -- added type `ShoppingListLineItemRemovedMessage` -- added type `ShoppingListMessage` -- added type `ShoppingListLineItemAddedMessagePayload` -- added type `ShoppingListLineItemRemovedMessagePayload` -- added type `ShoppingListMessagePayload` -- added type `BusinessUnitSearchStatus` -- added type `ProjectChangeBusinessUnitSearchStatusAction` -- added type `SearchExactValue` -
- - -
-Added Enum(s) - -- added enum `Canceled` to type `ShipmentState` -- added enum `shopping-list` to type `MessageSubscriptionResourceTypeId` -
- **History changes**
-Added Resource(s) - -- added resource `/{projectKey}/graphql` -
- - -
-Added Method(s) +Changed Property(s) -- added method `$apiRoot->withProjectKeyValue()->graphql()->post()` +- :warning: changed property `extensions` of type `GraphQLError` from type `GraphQLErrorObject` to `object`
-Added Type(s) +Removed Type(s) -- added type `GraphQLRequest` -- added type `GraphQLResponse` -- added type `GraphQLError` -- added type `GraphQLErrorLocation` -- added type `GraphQLVariablesMap` -- added type `GraphQLErrorObject` -- added type `ChangeTargetPatternChangeValue` -- added type `PatternComponent` +- :warning: removed type `GraphQLErrorObject`
diff --git a/lib/commercetools-history/src/Models/CartDiscount/PatternComponent.php b/lib/commercetools-history/src/Models/CartDiscount/PatternComponent.php index 4688b2132ae..a4f74b724e5 100644 --- a/lib/commercetools-history/src/Models/CartDiscount/PatternComponent.php +++ b/lib/commercetools-history/src/Models/CartDiscount/PatternComponent.php @@ -13,7 +13,7 @@ interface PatternComponent extends JsonObject { - public const DISCRIMINATOR_FIELD = 'type'; + public const FIELD_TYPE = 'type'; /** @@ -22,4 +22,8 @@ interface PatternComponent extends JsonObject */ public function getType(); + /** + * @param ?string $type + */ + public function setType(?string $type): void; } diff --git a/lib/commercetools-history/src/Models/CartDiscount/PatternComponentBuilder.php b/lib/commercetools-history/src/Models/CartDiscount/PatternComponentBuilder.php index d5555ba3a22..e59bd83d141 100644 --- a/lib/commercetools-history/src/Models/CartDiscount/PatternComponentBuilder.php +++ b/lib/commercetools-history/src/Models/CartDiscount/PatternComponentBuilder.php @@ -20,13 +20,37 @@ */ final class PatternComponentBuilder implements Builder { + /** + * @var ?string + */ + private $type; + /** + + * @return null|string + */ + public function getType() + { + return $this->type; + } + + /** + * @param ?string $type + * @return $this + */ + public function withType(?string $type) + { + $this->type = $type; + + return $this; + } public function build(): PatternComponent { return new PatternComponentModel( + $this->type ); } diff --git a/lib/commercetools-history/src/Models/CartDiscount/PatternComponentModel.php b/lib/commercetools-history/src/Models/CartDiscount/PatternComponentModel.php index 9d0fe1a2afe..cb87338ca9a 100644 --- a/lib/commercetools-history/src/Models/CartDiscount/PatternComponentModel.php +++ b/lib/commercetools-history/src/Models/CartDiscount/PatternComponentModel.php @@ -20,19 +20,13 @@ final class PatternComponentModel extends JsonObjectModel implements PatternComponent { - public const DISCRIMINATOR_VALUE = ''; + /** * * @var ?string */ protected $type; - /** - * @psalm-var array > - * - */ - private static $discriminatorClasses = [ - ]; /** * @psalm-suppress MissingParamType @@ -63,33 +57,14 @@ public function getType() } - - - /** - * @psalm-param stdClass|array $value - * @psalm-return class-string + * @param ?string $type */ - public static function resolveDiscriminatorClass($value): string + public function setType(?string $type): void { - $fieldName = PatternComponent::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 = PatternComponentModel::class; - return $type; + $this->type = $type; } + + + } diff --git a/lib/commercetools-history/src/Models/Error/GraphQLErrorObject.php b/lib/commercetools-history/src/Models/Error/GraphQLErrorObject.php deleted file mode 100644 index 156108a46eb..00000000000 --- a/lib/commercetools-history/src/Models/Error/GraphQLErrorObject.php +++ /dev/null @@ -1,28 +0,0 @@ -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 deleted file mode 100644 index 8e57eb2f89b..00000000000 --- a/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectBuilder.php +++ /dev/null @@ -1,37 +0,0 @@ - - */ -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 deleted file mode 100644 index e9b01fdca05..00000000000 --- a/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectCollection.php +++ /dev/null @@ -1,56 +0,0 @@ - - * @method GraphQLErrorObject current() - * @method GraphQLErrorObject end() - * @method GraphQLErrorObject at($offset) - */ -class GraphQLErrorObjectCollection extends MapperSequence -{ - /** - * @psalm-assert GraphQLErrorObject $value - * @psalm-param GraphQLErrorObject|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):?GraphQLErrorObject - */ - protected function mapper() - { - return function (?int $index): ?GraphQLErrorObject { - $data = $this->get($index); - if ($data instanceof stdClass) { - /** @var GraphQLErrorObject $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 deleted file mode 100644 index 618c4eb622b..00000000000 --- a/lib/commercetools-history/src/Models/Error/GraphQLErrorObjectModel.php +++ /dev/null @@ -1,113 +0,0 @@ - > - * - */ - private static $discriminatorClasses = [ - ]; - - /** - * @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/GraphQl/GraphQLError.php b/lib/commercetools-history/src/Models/GraphQl/GraphQLError.php index ee06bfabbfb..252160bcd64 100644 --- a/lib/commercetools-history/src/Models/GraphQl/GraphQLError.php +++ b/lib/commercetools-history/src/Models/GraphQl/GraphQLError.php @@ -10,7 +10,6 @@ use Commercetools\Base\JsonObject; use Commercetools\Base\DateTimeImmutableCollection; -use Commercetools\History\Models\Error\GraphQLErrorObject; interface GraphQLError extends JsonObject { @@ -48,7 +47,7 @@ public function getPath(); *

Dictionary with additional information where applicable.

* - * @return null|GraphQLErrorObject + * @return null|mixed */ public function getExtensions(); @@ -68,7 +67,7 @@ public function setLocations(?GraphQLErrorLocationCollection $locations): void; public function setPath(?array $path): void; /** - * @param ?GraphQLErrorObject $extensions + * @param ?JsonObject $extensions */ - public function setExtensions(?GraphQLErrorObject $extensions): void; + public function setExtensions(?JsonObject $extensions): void; } diff --git a/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorBuilder.php b/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorBuilder.php index 95278d33a16..05b6b0e07d1 100644 --- a/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorBuilder.php +++ b/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorBuilder.php @@ -14,8 +14,6 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Error\GraphQLErrorObject; -use Commercetools\History\Models\Error\GraphQLErrorObjectBuilder; /** * @implements Builder @@ -42,7 +40,7 @@ final class GraphQLErrorBuilder implements Builder /** - * @var null|GraphQLErrorObject|GraphQLErrorObjectBuilder + * @var ?JsonObject */ private $extensions; @@ -83,11 +81,11 @@ public function getPath() *

Dictionary with additional information where applicable.

* - * @return null|GraphQLErrorObject + * @return null|JsonObject */ public function getExtensions() { - return $this->extensions instanceof GraphQLErrorObjectBuilder ? $this->extensions->build() : $this->extensions; + return $this->extensions; } /** @@ -124,26 +122,16 @@ public function withPath(?array $path) } /** - * @param ?GraphQLErrorObject $extensions + * @param ?JsonObject $extensions * @return $this */ - public function withExtensions(?GraphQLErrorObject $extensions) + public function withExtensions(?JsonObject $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 { @@ -151,7 +139,7 @@ public function build(): GraphQLError $this->message, $this->locations, $this->path, - $this->extensions instanceof GraphQLErrorObjectBuilder ? $this->extensions->build() : $this->extensions + $this->extensions ); } diff --git a/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorModel.php b/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorModel.php index 090b2f8d31b..a6d2c7ba24e 100644 --- a/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorModel.php +++ b/lib/commercetools-history/src/Models/GraphQl/GraphQLErrorModel.php @@ -13,8 +13,6 @@ use Commercetools\Base\JsonObjectModel; use Commercetools\Base\MapperFactory; use stdClass; -use Commercetools\History\Models\Error\GraphQLErrorObject; -use Commercetools\History\Models\Error\GraphQLErrorObjectModel; /** * @internal @@ -43,7 +41,7 @@ final class GraphQLErrorModel extends JsonObjectModel implements GraphQLError /** * - * @var ?GraphQLErrorObject + * @var ?mixed */ protected $extensions; @@ -55,7 +53,7 @@ public function __construct( ?string $message = null, ?GraphQLErrorLocationCollection $locations = null, ?array $path = null, - ?GraphQLErrorObject $extensions = null + ?JsonObject $extensions = null ) { $this->message = $message; $this->locations = $locations; @@ -128,7 +126,7 @@ public function getPath() *

Dictionary with additional information where applicable.

* * - * @return null|GraphQLErrorObject + * @return null|mixed */ public function getExtensions() { @@ -138,8 +136,7 @@ public function getExtensions() if (is_null($data)) { return null; } - $className = GraphQLErrorObjectModel::resolveDiscriminatorClass($data); - $this->extensions = $className::of($data); + $this->extensions = JsonObjectModel::of($data); } return $this->extensions; @@ -171,9 +168,9 @@ public function setPath(?array $path): void } /** - * @param ?GraphQLErrorObject $extensions + * @param ?JsonObject $extensions */ - public function setExtensions(?GraphQLErrorObject $extensions): void + public function setExtensions(?JsonObject $extensions): void { $this->extensions = $extensions; } diff --git a/reference.txt b/reference.txt new file mode 100644 index 00000000000..e5c7c0e15d2 --- /dev/null +++ b/reference.txt @@ -0,0 +1 @@ +2a4e9c2d60f68a2f2b7976054db2c5052988fcaf diff --git a/references.txt b/references.txt index 754e1fdec88..14487299e26 100644 --- a/references.txt +++ b/references.txt @@ -345,3 +345,4 @@ e5666d7956fd6de53e41f965b052896d2a2ddd9b e8f731a742ca2997342b1b5f98121d86c8189a3b 473d2c6f1a9e9da0d2a42408ccf11f27a838f8b5 b7b82f5a701908239fcf39781bcbfa80823c9fa0 +cc1732f88ea3dc336358ff9f39cda9d5271cf7c2