Skip to content

Commit

Permalink
feat(conversation): add support for ShareableAggregateReferenceAltern…
Browse files Browse the repository at this point in the history
…ative6 in CreateConversationRequestBody
  • Loading branch information
mittwald-machine committed Sep 11, 2024
1 parent 3395659 commit 81b1653
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative3;
use Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative4;
use Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative5;
use Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative6;

class CreateConversationRequestBody
{
Expand Down Expand Up @@ -46,7 +47,7 @@ class CreateConversationRequestBody

private ?AggregateReference $relatedTo = null;

private ShareableAggregateReferenceAlternative1|ShareableAggregateReferenceAlternative2|ShareableAggregateReferenceAlternative3|ShareableAggregateReferenceAlternative4|ShareableAggregateReferenceAlternative5|null $sharedWith = null;
private ShareableAggregateReferenceAlternative1|ShareableAggregateReferenceAlternative2|ShareableAggregateReferenceAlternative3|ShareableAggregateReferenceAlternative4|ShareableAggregateReferenceAlternative5|ShareableAggregateReferenceAlternative6|null $sharedWith = null;

private ?string $title = null;

Expand Down Expand Up @@ -78,9 +79,9 @@ public function getRelatedTo(): ?AggregateReference

/**
* @return
* \Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative1|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative2|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative3|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative4|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative5|null
* \Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative1|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative2|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative3|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative4|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative5|\Mittwald\ApiClient\Generated\V2\Schemas\Conversation\ShareableAggregateReferenceAlternative6|null
*/
public function getSharedWith(): ShareableAggregateReferenceAlternative1|ShareableAggregateReferenceAlternative2|ShareableAggregateReferenceAlternative3|ShareableAggregateReferenceAlternative4|ShareableAggregateReferenceAlternative5|null
public function getSharedWith(): ShareableAggregateReferenceAlternative1|ShareableAggregateReferenceAlternative2|ShareableAggregateReferenceAlternative3|ShareableAggregateReferenceAlternative4|ShareableAggregateReferenceAlternative5|ShareableAggregateReferenceAlternative6|null
{
return $this->sharedWith;
}
Expand Down Expand Up @@ -151,9 +152,9 @@ public function withoutRelatedTo(): self
}

/**
* @param ShareableAggregateReferenceAlternative1|ShareableAggregateReferenceAlternative2|ShareableAggregateReferenceAlternative3|ShareableAggregateReferenceAlternative4|ShareableAggregateReferenceAlternative5 $sharedWith
* @param ShareableAggregateReferenceAlternative1|ShareableAggregateReferenceAlternative2|ShareableAggregateReferenceAlternative3|ShareableAggregateReferenceAlternative4|ShareableAggregateReferenceAlternative5|ShareableAggregateReferenceAlternative6 $sharedWith
*/
public function withSharedWith(ShareableAggregateReferenceAlternative1|ShareableAggregateReferenceAlternative2|ShareableAggregateReferenceAlternative3|ShareableAggregateReferenceAlternative4|ShareableAggregateReferenceAlternative5 $sharedWith): self
public function withSharedWith(ShareableAggregateReferenceAlternative1|ShareableAggregateReferenceAlternative2|ShareableAggregateReferenceAlternative3|ShareableAggregateReferenceAlternative4|ShareableAggregateReferenceAlternative5|ShareableAggregateReferenceAlternative6 $sharedWith): self
{
$clone = clone $this;
$clone->sharedWith = $sharedWith;
Expand Down Expand Up @@ -227,6 +228,7 @@ public static function buildFromInput(array|object $input, bool $validate = true
ShareableAggregateReferenceAlternative3::validateInput($input->{'sharedWith'}, true) => ShareableAggregateReferenceAlternative3::buildFromInput($input->{'sharedWith'}, validate: $validate),
ShareableAggregateReferenceAlternative4::validateInput($input->{'sharedWith'}, true) => ShareableAggregateReferenceAlternative4::buildFromInput($input->{'sharedWith'}, validate: $validate),
ShareableAggregateReferenceAlternative5::validateInput($input->{'sharedWith'}, true) => ShareableAggregateReferenceAlternative5::buildFromInput($input->{'sharedWith'}, validate: $validate),
ShareableAggregateReferenceAlternative6::validateInput($input->{'sharedWith'}, true) => ShareableAggregateReferenceAlternative6::buildFromInput($input->{'sharedWith'}, validate: $validate),
};
}
$title = null;
Expand Down Expand Up @@ -263,7 +265,7 @@ public function toJson(): array
if (isset($this->sharedWith)) {
$output['sharedWith'] = match (true) {
default => throw new InvalidArgumentException("input cannot be mapped to any valid type"),
($this->sharedWith) instanceof ShareableAggregateReferenceAlternative1, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative2, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative3, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative4, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative5 => $this->sharedWith->toJson(),
($this->sharedWith) instanceof ShareableAggregateReferenceAlternative1, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative2, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative3, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative4, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative5, ($this->sharedWith) instanceof ShareableAggregateReferenceAlternative6 => $this->sharedWith->toJson(),
};
}
if (isset($this->title)) {
Expand Down
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()
{
}
}
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';
}
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';
}

0 comments on commit 81b1653

Please sign in to comment.