-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(deprecation): mark upload rules and extensions as deprecated
- Added deprecation notices to the upload rules methods in FileClient and FileClientImpl. - Introduced a deprecation property to the Extension class to indicate expiration details. - Updated OptionalExtension and Extension classes with deprecated annotations on relevant properties and methods.
- Loading branch information
1 parent
a331ed7
commit 899a0c6
Showing
5 changed files
with
201 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
123 changes: 123 additions & 0 deletions
123
src/Generated/V2/Schemas/Marketplace/ExtensionDeprecation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mittwald\ApiClient\Generated\V2\Schemas\Marketplace; | ||
|
||
use DateTime; | ||
use InvalidArgumentException; | ||
use JsonSchema\Validator; | ||
|
||
/** | ||
* Auto-generated class for de.mittwald.v1.marketplace.Extension. | ||
* | ||
* DO NOT EDIT; this class was generated by the mittwald/api-client-builder package | ||
* (https://github.com/mittwald/api-client-php-builder). Please make any changes | ||
* there. | ||
* | ||
* @generated | ||
* @see https://github.com/mittwald/api-client-php-builder | ||
*/ | ||
class ExtensionDeprecation | ||
{ | ||
/** | ||
* Schema used to validate input for creating instances of this class | ||
*/ | ||
private static array $schema = [ | ||
'description' => 'The Extension is deprecated by the contributor and will expire at the given date.', | ||
'properties' => [ | ||
'deprecatedAt' => [ | ||
'format' => 'date-time', | ||
'type' => 'string', | ||
], | ||
], | ||
'required' => [ | ||
'deprecatedAt', | ||
], | ||
'type' => 'object', | ||
]; | ||
|
||
private DateTime $deprecatedAt; | ||
|
||
public function __construct(DateTime $deprecatedAt) | ||
{ | ||
$this->deprecatedAt = $deprecatedAt; | ||
} | ||
|
||
public function getDeprecatedAt(): DateTime | ||
{ | ||
return $this->deprecatedAt; | ||
} | ||
|
||
public function withDeprecatedAt(DateTime $deprecatedAt): self | ||
{ | ||
$clone = clone $this; | ||
$clone->deprecatedAt = $deprecatedAt; | ||
|
||
return $clone; | ||
} | ||
|
||
/** | ||
* Builds a new instance from an input array | ||
* | ||
* @param array|object $input Input data | ||
* @param bool $validate Set this to false to skip validation; use at own risk | ||
* @return ExtensionDeprecation Created instance | ||
* @throws InvalidArgumentException | ||
*/ | ||
public static function buildFromInput(array|object $input, bool $validate = true): ExtensionDeprecation | ||
{ | ||
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; | ||
if ($validate) { | ||
static::validateInput($input); | ||
} | ||
|
||
$deprecatedAt = new DateTime($input->{'deprecatedAt'}); | ||
|
||
$obj = new self($deprecatedAt); | ||
|
||
return $obj; | ||
} | ||
|
||
/** | ||
* Converts this object back to a simple array that can be JSON-serialized | ||
* | ||
* @return array Converted array | ||
*/ | ||
public function toJson(): array | ||
{ | ||
$output = []; | ||
$output['deprecatedAt'] = ($this->deprecatedAt)->format(DateTime::ATOM); | ||
|
||
return $output; | ||
} | ||
|
||
/** | ||
* Validates an input array | ||
* | ||
* @param array|object $input Input data | ||
* @param bool $return Return instead of throwing errors | ||
* @return bool Validation result | ||
* @throws InvalidArgumentException | ||
*/ | ||
public static function validateInput(array|object $input, bool $return = false): bool | ||
{ | ||
$validator = new \Mittwald\ApiClient\Validator\Validator(); | ||
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; | ||
$validator->validate($input, static::$schema); | ||
|
||
if (!$validator->isValid() && !$return) { | ||
$errors = array_map(function (array $e): string { | ||
return $e["property"] . ": " . $e["message"]; | ||
}, $validator->getErrors()); | ||
throw new InvalidArgumentException(join(", ", $errors)); | ||
} | ||
|
||
return $validator->isValid(); | ||
} | ||
|
||
public function __clone() | ||
{ | ||
$this->deprecatedAt = clone $this->deprecatedAt; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters