-
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(conversation): add support for ShareableAggregateReferenceAltern…
…ative6 in CreateConversationRequestBody
- Loading branch information
1 parent
3395659
commit 81b1653
Showing
4 changed files
with
204 additions
and
6 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
176 changes: 176 additions & 0 deletions
176
src/Generated/V2/Schemas/Conversation/ShareableAggregateReferenceAlternative6.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,176 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mittwald\ApiClient\Generated\V2\Schemas\Conversation; | ||
|
||
use InvalidArgumentException; | ||
use JsonSchema\Validator; | ||
|
||
/** | ||
* Auto-generated class for | ||
* de.mittwald.v1.conversation.ShareableAggregateReferenceAlternative6. | ||
* | ||
* 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 ShareableAggregateReferenceAlternative6 | ||
{ | ||
/** | ||
* Schema used to validate input for creating instances of this class | ||
*/ | ||
private static array $schema = [ | ||
'properties' => [ | ||
'aggregate' => [ | ||
'enum' => [ | ||
'extensionInstance', | ||
], | ||
'type' => 'string', | ||
], | ||
'domain' => [ | ||
'enum' => [ | ||
'extension', | ||
], | ||
'type' => 'string', | ||
], | ||
'id' => [ | ||
'type' => 'string', | ||
], | ||
], | ||
'required' => [ | ||
'id', | ||
'aggregate', | ||
'domain', | ||
], | ||
'type' => 'object', | ||
]; | ||
|
||
private ShareableAggregateReferenceAlternative6Aggregate $aggregate; | ||
|
||
private ShareableAggregateReferenceAlternative6Domain $domain; | ||
|
||
private string $id; | ||
|
||
public function __construct(ShareableAggregateReferenceAlternative6Aggregate $aggregate, ShareableAggregateReferenceAlternative6Domain $domain, string $id) | ||
{ | ||
$this->aggregate = $aggregate; | ||
$this->domain = $domain; | ||
$this->id = $id; | ||
} | ||
|
||
public function getAggregate(): ShareableAggregateReferenceAlternative6Aggregate | ||
{ | ||
return $this->aggregate; | ||
} | ||
|
||
public function getDomain(): ShareableAggregateReferenceAlternative6Domain | ||
{ | ||
return $this->domain; | ||
} | ||
|
||
public function getId(): string | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function withAggregate(ShareableAggregateReferenceAlternative6Aggregate $aggregate): self | ||
{ | ||
$clone = clone $this; | ||
$clone->aggregate = $aggregate; | ||
|
||
return $clone; | ||
} | ||
|
||
public function withDomain(ShareableAggregateReferenceAlternative6Domain $domain): self | ||
{ | ||
$clone = clone $this; | ||
$clone->domain = $domain; | ||
|
||
return $clone; | ||
} | ||
|
||
public function withId(string $id): self | ||
{ | ||
$validator = new Validator(); | ||
$validator->validate($id, static::$schema['properties']['id']); | ||
if (!$validator->isValid()) { | ||
throw new InvalidArgumentException($validator->getErrors()[0]['message']); | ||
} | ||
|
||
$clone = clone $this; | ||
$clone->id = $id; | ||
|
||
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 ShareableAggregateReferenceAlternative6 Created instance | ||
* @throws InvalidArgumentException | ||
*/ | ||
public static function buildFromInput(array|object $input, bool $validate = true): ShareableAggregateReferenceAlternative6 | ||
{ | ||
$input = is_array($input) ? Validator::arrayToObjectRecursive($input) : $input; | ||
if ($validate) { | ||
static::validateInput($input); | ||
} | ||
|
||
$aggregate = ShareableAggregateReferenceAlternative6Aggregate::from($input->{'aggregate'}); | ||
$domain = ShareableAggregateReferenceAlternative6Domain::from($input->{'domain'}); | ||
$id = $input->{'id'}; | ||
|
||
$obj = new self($aggregate, $domain, $id); | ||
|
||
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['aggregate'] = ($this->aggregate)->value; | ||
$output['domain'] = ($this->domain)->value; | ||
$output['id'] = $this->id; | ||
|
||
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() | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Generated/V2/Schemas/Conversation/ShareableAggregateReferenceAlternative6Aggregate.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mittwald\ApiClient\Generated\V2\Schemas\Conversation; | ||
|
||
enum ShareableAggregateReferenceAlternative6Aggregate: string | ||
{ | ||
case extensionInstance = 'extensionInstance'; | ||
} |
10 changes: 10 additions & 0 deletions
10
src/Generated/V2/Schemas/Conversation/ShareableAggregateReferenceAlternative6Domain.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,10 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Mittwald\ApiClient\Generated\V2\Schemas\Conversation; | ||
|
||
enum ShareableAggregateReferenceAlternative6Domain: string | ||
{ | ||
case extension = 'extension'; | ||
} |