Skip to content

Commit 086dc43

Browse files
feat: add deletionDeadline and isDeletionScheduled properties to extension pricing response and variant schemas
- Introduced `deletionDeadline` property to several response classes, providing a date-time for when a variant is scheduled for deletion. - Added `isDeletionScheduled` boolean property to represent if the deletion of an extension variant is planned. - Updated respective constructors, getters, and serialization methods to handle the new properties.
1 parent 735af68 commit 086dc43

8 files changed

+343
-2
lines changed

src/Generated/V2/Clients/Marketplace/ExtensionUpdateExtensionPricing/ExtensionUpdateExtensionPricingOKResponse.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,11 @@ class ExtensionUpdateExtensionPricingOKResponse implements ResponseContainer
6666
],
6767
'type' => 'string',
6868
],
69+
'deletionDeadline' => [
70+
'description' => 'The date the variant will ne deleted',
71+
'format' => 'date-time',
72+
'type' => 'string',
73+
],
6974
'variantKey' => [
7075
'description' => 'The key of the variant of the Extension.',
7176
'type' => 'string',

src/Generated/V2/Clients/Marketplace/ExtensionUpdateExtensionPricing/ExtensionUpdateExtensionPricingOKResponseBody.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ class ExtensionUpdateExtensionPricingOKResponseBody
5959
],
6060
'type' => 'string',
6161
],
62+
'deletionDeadline' => [
63+
'description' => 'The date the variant will ne deleted',
64+
'format' => 'date-time',
65+
'type' => 'string',
66+
],
6267
'variantKey' => [
6368
'description' => 'The key of the variant of the Extension.',
6469
'type' => 'string',

src/Generated/V2/Clients/Marketplace/ExtensionUpdateExtensionPricing/ExtensionUpdateExtensionPricingOKResponseBodyPriceChangeConsequence.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,11 @@ class ExtensionUpdateExtensionPricingOKResponseBodyPriceChangeConsequence
4646
],
4747
'type' => 'string',
4848
],
49+
'deletionDeadline' => [
50+
'description' => 'The date the variant will ne deleted',
51+
'format' => 'date-time',
52+
'type' => 'string',
53+
],
4954
'variantKey' => [
5055
'description' => 'The key of the variant of the Extension.',
5156
'type' => 'string',

src/Generated/V2/Clients/Marketplace/ExtensionUpdateExtensionPricing/ExtensionUpdateExtensionPricingOKResponseBodyPriceChangeConsequenceVariantConsequencesItem.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
namespace Mittwald\ApiClient\Generated\V2\Clients\Marketplace\ExtensionUpdateExtensionPricing;
66

7+
use DateTime;
78
use InvalidArgumentException;
89
use JsonSchema\Validator;
910

@@ -24,6 +25,11 @@ class ExtensionUpdateExtensionPricingOKResponseBodyPriceChangeConsequenceVariant
2425
],
2526
'type' => 'string',
2627
],
28+
'deletionDeadline' => [
29+
'description' => 'The date the variant will ne deleted',
30+
'format' => 'date-time',
31+
'type' => 'string',
32+
],
2733
'variantKey' => [
2834
'description' => 'The key of the variant of the Extension.',
2935
'type' => 'string',
@@ -38,6 +44,11 @@ class ExtensionUpdateExtensionPricingOKResponseBodyPriceChangeConsequenceVariant
3844
*/
3945
private ?ExtensionUpdateExtensionPricingOKResponseBodyPriceChangeConsequenceVariantConsequencesItemConsequence $consequence = null;
4046

47+
/**
48+
* The date the variant will ne deleted
49+
*/
50+
private ?DateTime $deletionDeadline = null;
51+
4152
/**
4253
* The key of the variant of the Extension.
4354
*/
@@ -55,6 +66,11 @@ public function getConsequence(): ?ExtensionUpdateExtensionPricingOKResponseBody
5566
return $this->consequence ?? null;
5667
}
5768

69+
public function getDeletionDeadline(): ?DateTime
70+
{
71+
return $this->deletionDeadline ?? null;
72+
}
73+
5874
public function getVariantKey(): ?string
5975
{
6076
return $this->variantKey ?? null;
@@ -76,6 +92,22 @@ public function withoutConsequence(): self
7692
return $clone;
7793
}
7894

95+
public function withDeletionDeadline(DateTime $deletionDeadline): self
96+
{
97+
$clone = clone $this;
98+
$clone->deletionDeadline = $deletionDeadline;
99+
100+
return $clone;
101+
}
102+
103+
public function withoutDeletionDeadline(): self
104+
{
105+
$clone = clone $this;
106+
unset($clone->deletionDeadline);
107+
108+
return $clone;
109+
}
110+
79111
public function withVariantKey(string $variantKey): self
80112
{
81113
$validator = new Validator();
@@ -117,13 +149,18 @@ public static function buildFromInput(array|object $input, bool $validate = true
117149
if (isset($input->{'consequence'})) {
118150
$consequence = ExtensionUpdateExtensionPricingOKResponseBodyPriceChangeConsequenceVariantConsequencesItemConsequence::from($input->{'consequence'});
119151
}
152+
$deletionDeadline = null;
153+
if (isset($input->{'deletionDeadline'})) {
154+
$deletionDeadline = new DateTime($input->{'deletionDeadline'});
155+
}
120156
$variantKey = null;
121157
if (isset($input->{'variantKey'})) {
122158
$variantKey = $input->{'variantKey'};
123159
}
124160

125161
$obj = new self();
126162
$obj->consequence = $consequence;
163+
$obj->deletionDeadline = $deletionDeadline;
127164
$obj->variantKey = $variantKey;
128165
return $obj;
129166
}
@@ -139,6 +176,9 @@ public function toJson(): array
139176
if (isset($this->consequence)) {
140177
$output['consequence'] = ($this->consequence)->value;
141178
}
179+
if (isset($this->deletionDeadline)) {
180+
$output['deletionDeadline'] = ($this->deletionDeadline)->format(DateTime::ATOM);
181+
}
142182
if (isset($this->variantKey)) {
143183
$output['variantKey'] = $this->variantKey;
144184
}
@@ -172,5 +212,8 @@ public static function validateInput(array|object $input, bool $return = false):
172212

173213
public function __clone()
174214
{
215+
if (isset($this->deletionDeadline)) {
216+
$this->deletionDeadline = clone $this->deletionDeadline;
217+
}
175218
}
176219
}

src/Generated/V2/Clients/ProjectFileSystem/ProjectFileSystemClientImpl.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
use Mittwald\ApiClient\Generated\V2\Clients\ProjectFileSystem\ProjectFileSystemGetJwt\ProjectFileSystemGetJwtRequest;
4040
use Mittwald\ApiClient\Generated\V2\Clients\ProjectFileSystem\ProjectFileSystemGetJwt\ProjectFileSystemGetJwtServiceUnavailableResponse;
4141
use Mittwald\ApiClient\Generated\V2\Clients\ProjectFileSystem\ProjectFileSystemGetJwt\ProjectFileSystemGetJwtTooManyRequestsResponse;
42+
use Mittwald\ApiClient\Generated\V2\Clients\ProjectFileSystem\ProjectFileSystemGetJwt\ProjectFileSystemGetJwtUnauthorizedResponse;
4243
use Mittwald\ApiClient\Generated\V2\Clients\ProjectFileSystem\ProjectFileSystemListFiles\ProjectFileSystemListFilesBadGatewayResponse;
4344
use Mittwald\ApiClient\Generated\V2\Clients\ProjectFileSystem\ProjectFileSystemListFiles\ProjectFileSystemListFilesDefaultResponse;
4445
use Mittwald\ApiClient\Generated\V2\Clients\ProjectFileSystem\ProjectFileSystemListFiles\ProjectFileSystemListFilesForbiddenResponse;
@@ -164,6 +165,7 @@ public function projectFileSystemGetJwt(ProjectFileSystemGetJwtRequest $request)
164165
return ProjectFileSystemGetJwtOKResponse::fromResponse($httpResponse);
165166
}
166167
throw new UnexpectedResponseException(match ($httpResponse->getStatusCode()) {
168+
401 => ProjectFileSystemGetJwtUnauthorizedResponse::fromResponse($httpResponse),
167169
403 => ProjectFileSystemGetJwtForbiddenResponse::fromResponse($httpResponse),
168170
404 => ProjectFileSystemGetJwtNotFoundResponse::fromResponse($httpResponse),
169171
429 => ProjectFileSystemGetJwtTooManyRequestsResponse::fromResponse($httpResponse),
Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Mittwald\ApiClient\Generated\V2\Clients\ProjectFileSystem\ProjectFileSystemGetJwt;
6+
7+
use InvalidArgumentException;
8+
use JsonSchema\Validator;
9+
use Mittwald\ApiClient\Client\ResponseContainer;
10+
use Mittwald\ApiClient\Generated\V2\Schemas\Commons\Error;
11+
use Psr\Http\Message\ResponseInterface;
12+
13+
class ProjectFileSystemGetJwtUnauthorizedResponse implements ResponseContainer
14+
{
15+
/**
16+
* Schema used to validate input for creating instances of this class
17+
*/
18+
private static array $internalValidationSchema = [
19+
'type' => 'object',
20+
'required' => [
21+
'body',
22+
],
23+
'properties' => [
24+
'body' => [
25+
'$ref' => '#/components/schemas/de.mittwald.v1.commons.Error',
26+
],
27+
],
28+
];
29+
30+
private Error $body;
31+
32+
private ResponseInterface|null $httpResponse = null;
33+
34+
public function __construct(Error $body)
35+
{
36+
$this->body = $body;
37+
}
38+
39+
public function getBody(): Error
40+
{
41+
return $this->body;
42+
}
43+
44+
public function withBody(Error $body): self
45+
{
46+
$clone = clone $this;
47+
$clone->body = $body;
48+
49+
return $clone;
50+
}
51+
52+
/**
53+
* Builds a new instance from an input array
54+
*
55+
* @param array|object $input Input data
56+
* @param bool $validate Set this to false to skip validation; use at own risk
57+
* @return ProjectFileSystemGetJwtUnauthorizedResponse Created instance
58+
* @throws InvalidArgumentException
59+
*/
60+
public static function buildFromInput(array|object $input, bool $validate = true): ProjectFileSystemGetJwtUnauthorizedResponse
61+
{
62+
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
63+
if ($validate) {
64+
static::validateInput($input);
65+
}
66+
67+
$body = Error::buildFromInput($input->{'body'}, validate: $validate);
68+
69+
$obj = new self($body);
70+
71+
return $obj;
72+
}
73+
74+
/**
75+
* Converts this object back to a simple array that can be JSON-serialized
76+
*
77+
* @return array Converted array
78+
*/
79+
public function toJson(): array
80+
{
81+
$output = [];
82+
$output['body'] = $this->body->toJson();
83+
84+
return $output;
85+
}
86+
87+
/**
88+
* Validates an input array
89+
*
90+
* @param array|object $input Input data
91+
* @param bool $return Return instead of throwing errors
92+
* @return bool Validation result
93+
* @throws InvalidArgumentException
94+
*/
95+
public static function validateInput(array|object $input, bool $return = false): bool
96+
{
97+
$validator = new \Mittwald\ApiClient\Validator\Validator();
98+
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input;
99+
$validator->validate($input, self::$internalValidationSchema);
100+
101+
if (!$validator->isValid() && !$return) {
102+
$errors = array_map(function (array $e): string {
103+
return $e["property"] . ": " . $e["message"];
104+
}, $validator->getErrors());
105+
throw new InvalidArgumentException(join(", ", $errors));
106+
}
107+
108+
return $validator->isValid();
109+
}
110+
111+
public function __clone()
112+
{
113+
}
114+
115+
public static function fromResponse(ResponseInterface $httpResponse): self
116+
{
117+
$parsedBody = json_decode($httpResponse->getBody()->getContents(), associative: true);
118+
$response = static::buildFromInput(['body' => $parsedBody], validate: false);
119+
$response->httpResponse = $httpResponse;
120+
return $response;
121+
}
122+
123+
public function getResponse(): ResponseInterface|null
124+
{
125+
return $this->httpResponse;
126+
}
127+
}

0 commit comments

Comments
 (0)