Skip to content

Commit bc32259

Browse files
committed
build(codegen): updating SDK
1 parent fa48fa5 commit bc32259

36 files changed

+331
-333
lines changed

changes.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -839,6 +839,7 @@
839839
<summary>Changed Type(s)</summary>
840840

841841
- :warning: changed type `Address` from type `object` to `BaseAddress`
842+
- :warning: changed type `GeoLocation` from type `object` to `GeoJson`
842843
</details>
843844

844845

@@ -970,6 +971,8 @@
970971
- changed property `isOnStock` of type `ProductVariantChannelAvailability` to be optional
971972
- changed property `restockableInDays` of type `ProductVariantChannelAvailability` to be optional
972973
- changed property `availableQuantity` of type `ProductVariantChannelAvailability` to be optional
974+
- changed property `id` of type `ResourceIdentifier` to be optional
975+
- changed property `key` of type `ResourceIdentifier` to be optional
973976
- changed property `returnTrackingId` of type `ReturnInfo` to be optional
974977
- changed property `returnDate` of type `ReturnInfo` to be optional
975978
- changed property `comment` of type `ReturnItem` to be optional

lib/commercetools-history/src/Models/Change/AddProductChangeModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ public function getVariantSelection()
136136
if (is_null($data)) {
137137
return null;
138138
}
139-
$className = ProductVariantSelectionModel::resolveDiscriminatorClass($data);
140-
$this->variantSelection = $className::of($data);
139+
140+
$this->variantSelection = ProductVariantSelectionModel::of($data);
141141
}
142142

143143
return $this->variantSelection;

lib/commercetools-history/src/Models/Change/SetVariantSelectionChangeModel.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ public function getPreviousValue()
123123
if (is_null($data)) {
124124
return null;
125125
}
126-
$className = ProductVariantSelectionModel::resolveDiscriminatorClass($data);
127-
$this->previousValue = $className::of($data);
126+
127+
$this->previousValue = ProductVariantSelectionModel::of($data);
128128
}
129129

130130
return $this->previousValue;
@@ -144,8 +144,8 @@ public function getNextValue()
144144
if (is_null($data)) {
145145
return null;
146146
}
147-
$className = ProductVariantSelectionModel::resolveDiscriminatorClass($data);
148-
$this->nextValue = $className::of($data);
147+
148+
$this->nextValue = ProductVariantSelectionModel::of($data);
149149
}
150150

151151
return $this->nextValue;

lib/commercetools-history/src/Models/Common/CartDiscountTarget.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
interface CartDiscountTarget extends JsonObject
1515
{
16-
public const DISCRIMINATOR_FIELD = 'type';
16+
1717
public const FIELD_TYPE = 'type';
1818

1919
/**
@@ -22,4 +22,8 @@ interface CartDiscountTarget extends JsonObject
2222
*/
2323
public function getType();
2424

25+
/**
26+
* @param ?string $type
27+
*/
28+
public function setType(?string $type): void;
2529
}

lib/commercetools-history/src/Models/Common/CartDiscountTargetBuilder.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,37 @@
2020
*/
2121
final class CartDiscountTargetBuilder implements Builder
2222
{
23+
/**
2324
25+
* @var ?string
26+
*/
27+
private $type;
2428

29+
/**
30+
31+
* @return null|string
32+
*/
33+
public function getType()
34+
{
35+
return $this->type;
36+
}
37+
38+
/**
39+
* @param ?string $type
40+
* @return $this
41+
*/
42+
public function withType(?string $type)
43+
{
44+
$this->type = $type;
45+
46+
return $this;
47+
}
2548

2649

2750
public function build(): CartDiscountTarget
2851
{
2952
return new CartDiscountTargetModel(
53+
$this->type
3054
);
3155
}
3256

lib/commercetools-history/src/Models/Common/CartDiscountTargetModel.php

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,13 @@
2020
final class CartDiscountTargetModel extends JsonObjectModel implements CartDiscountTarget
2121
{
2222

23-
public const DISCRIMINATOR_VALUE = '';
23+
2424
/**
2525
*
2626
* @var ?string
2727
*/
2828
protected $type;
2929

30-
/**
31-
* @psalm-var array<string, class-string<CartDiscountTarget> >
32-
*
33-
*/
34-
private static $discriminatorClasses = [
35-
];
3630

3731
/**
3832
* @psalm-suppress MissingParamType
@@ -63,33 +57,14 @@ public function getType()
6357
}
6458

6559

66-
67-
68-
6960
/**
70-
* @psalm-param stdClass|array<string, mixed> $value
71-
* @psalm-return class-string<CartDiscountTarget>
61+
* @param ?string $type
7262
*/
73-
public static function resolveDiscriminatorClass($value): string
63+
public function setType(?string $type): void
7464
{
75-
$fieldName = CartDiscountTarget::DISCRIMINATOR_FIELD;
76-
if (is_object($value) && isset($value->$fieldName)) {
77-
/** @psalm-var string $discriminatorValue */
78-
$discriminatorValue = $value->$fieldName;
79-
if (isset(self::$discriminatorClasses[$discriminatorValue])) {
80-
return self::$discriminatorClasses[$discriminatorValue];
81-
}
82-
}
83-
if (is_array($value) && isset($value[$fieldName])) {
84-
/** @psalm-var string $discriminatorValue */
85-
$discriminatorValue = $value[$fieldName];
86-
if (isset(self::$discriminatorClasses[$discriminatorValue])) {
87-
return self::$discriminatorClasses[$discriminatorValue];
88-
}
89-
}
90-
91-
/** @psalm-var class-string<CartDiscountTarget> */
92-
$type = CartDiscountTargetModel::class;
93-
return $type;
65+
$this->type = $type;
9466
}
67+
68+
69+
9570
}

lib/commercetools-history/src/Models/Common/CartDiscountValue.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
interface CartDiscountValue extends JsonObject
1515
{
16-
public const DISCRIMINATOR_FIELD = 'type';
16+
1717
public const FIELD_TYPE = 'type';
1818

1919
/**
@@ -22,4 +22,8 @@ interface CartDiscountValue extends JsonObject
2222
*/
2323
public function getType();
2424

25+
/**
26+
* @param ?string $type
27+
*/
28+
public function setType(?string $type): void;
2529
}

lib/commercetools-history/src/Models/Common/CartDiscountValueBuilder.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,37 @@
2020
*/
2121
final class CartDiscountValueBuilder implements Builder
2222
{
23+
/**
2324
25+
* @var ?string
26+
*/
27+
private $type;
2428

29+
/**
30+
31+
* @return null|string
32+
*/
33+
public function getType()
34+
{
35+
return $this->type;
36+
}
37+
38+
/**
39+
* @param ?string $type
40+
* @return $this
41+
*/
42+
public function withType(?string $type)
43+
{
44+
$this->type = $type;
45+
46+
return $this;
47+
}
2548

2649

2750
public function build(): CartDiscountValue
2851
{
2952
return new CartDiscountValueModel(
53+
$this->type
3054
);
3155
}
3256

lib/commercetools-history/src/Models/Common/CartDiscountValueModel.php

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,13 @@
2020
final class CartDiscountValueModel extends JsonObjectModel implements CartDiscountValue
2121
{
2222

23-
public const DISCRIMINATOR_VALUE = '';
23+
2424
/**
2525
*
2626
* @var ?string
2727
*/
2828
protected $type;
2929

30-
/**
31-
* @psalm-var array<string, class-string<CartDiscountValue> >
32-
*
33-
*/
34-
private static $discriminatorClasses = [
35-
];
3630

3731
/**
3832
* @psalm-suppress MissingParamType
@@ -63,33 +57,14 @@ public function getType()
6357
}
6458

6559

66-
67-
68-
6960
/**
70-
* @psalm-param stdClass|array<string, mixed> $value
71-
* @psalm-return class-string<CartDiscountValue>
61+
* @param ?string $type
7262
*/
73-
public static function resolveDiscriminatorClass($value): string
63+
public function setType(?string $type): void
7464
{
75-
$fieldName = CartDiscountValue::DISCRIMINATOR_FIELD;
76-
if (is_object($value) && isset($value->$fieldName)) {
77-
/** @psalm-var string $discriminatorValue */
78-
$discriminatorValue = $value->$fieldName;
79-
if (isset(self::$discriminatorClasses[$discriminatorValue])) {
80-
return self::$discriminatorClasses[$discriminatorValue];
81-
}
82-
}
83-
if (is_array($value) && isset($value[$fieldName])) {
84-
/** @psalm-var string $discriminatorValue */
85-
$discriminatorValue = $value[$fieldName];
86-
if (isset(self::$discriminatorClasses[$discriminatorValue])) {
87-
return self::$discriminatorClasses[$discriminatorValue];
88-
}
89-
}
90-
91-
/** @psalm-var class-string<CartDiscountValue> */
92-
$type = CartDiscountValueModel::class;
93-
return $type;
65+
$this->type = $type;
9466
}
67+
68+
69+
9570
}

lib/commercetools-history/src/Models/Common/GeoJsonCollection.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,20 @@
1313
use stdClass;
1414

1515
/**
16-
* @extends MapperSequence<GeoJson>
16+
* @template T of GeoJson
17+
* @extends MapperSequence<T>
18+
* @psalm-method T current()
19+
* @psalm-method T end()
20+
* @psalm-method T at($offset)
1721
* @method GeoJson current()
1822
* @method GeoJson end()
1923
* @method GeoJson at($offset)
2024
*/
2125
class GeoJsonCollection extends MapperSequence
2226
{
2327
/**
24-
* @psalm-assert GeoJson $value
25-
* @psalm-param GeoJson|stdClass $value
28+
* @psalm-assert T $value
29+
* @psalm-param T|stdClass $value
2630
* @throws InvalidArgumentException
2731
*
2832
* @return GeoJsonCollection
@@ -38,14 +42,14 @@ public function add($value)
3842
}
3943

4044
/**
41-
* @psalm-return callable(int):?GeoJson
45+
* @psalm-return callable(int):?T
4246
*/
4347
protected function mapper()
4448
{
4549
return function (?int $index): ?GeoJson {
4650
$data = $this->get($index);
4751
if ($data instanceof stdClass) {
48-
/** @var GeoJson $data */
52+
/** @var T $data */
4953
$data = GeoJsonModel::of($data);
5054
$this->set($data, $index);
5155
}

0 commit comments

Comments
 (0)