diff --git a/composer.json b/composer.json index 0e0b0dcd..dceba6cc 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.1", "doctrine/cache": "^1.10", "guzzlehttp/guzzle": "^7.0", - "illuminate/database": "^11.8", + "jenssegers/model": "^1.5", "kevinrob/guzzle-cache-middleware": "^5.0", "phpdocumentor/reflection-docblock": "^5.2", "psr/http-message": "^1.0", diff --git a/composer.lock b/composer.lock index 51ff3fb3..4fec7d19 100644 --- a/composer.lock +++ b/composer.lock @@ -4,68 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ab87a0d0b8e28fc78b096a97ffcb09a6", + "content-hash": "287eb9284e4a97779cf04d319af71322", "packages": [ - { - "name": "brick/math", - "version": "0.12.1", - "source": { - "type": "git", - "url": "https://github.com/brick/math.git", - "reference": "f510c0a40911935b77b86859eb5223d58d660df1" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/brick/math/zipball/f510c0a40911935b77b86859eb5223d58d660df1", - "reference": "f510c0a40911935b77b86859eb5223d58d660df1", - "shasum": "" - }, - "require": { - "php": "^8.1" - }, - "require-dev": { - "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^10.1", - "vimeo/psalm": "5.16.0" - }, - "type": "library", - "autoload": { - "psr-4": { - "Brick\\Math\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "description": "Arbitrary-precision arithmetic library", - "keywords": [ - "Arbitrary-precision", - "BigInteger", - "BigRational", - "arithmetic", - "bigdecimal", - "bignum", - "bignumber", - "brick", - "decimal", - "integer", - "math", - "mathematics", - "rational" - ], - "support": { - "issues": "https://github.com/brick/math/issues", - "source": "https://github.com/brick/math/tree/0.12.1" - }, - "funding": [ - { - "url": "https://github.com/BenMorel", - "type": "github" - } - ], - "time": "2023-11-29T23:19:16+00:00" - }, { "name": "carbonphp/carbon-doctrine-types", "version": "3.2.0", @@ -798,57 +738,6 @@ }, "time": "2024-04-04T17:36:49+00:00" }, - { - "name": "illuminate/container", - "version": "v11.8.0", - "source": { - "type": "git", - "url": "https://github.com/illuminate/container.git", - "reference": "af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7", - "reference": "af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7", - "shasum": "" - }, - "require": { - "illuminate/contracts": "^11.0", - "php": "^8.2", - "psr/container": "^1.1.1|^2.0.1" - }, - "provide": { - "psr/container-implementation": "1.1|2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "11.x-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Container\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Container package.", - "homepage": "https://laravel.com", - "support": { - "issues": "https://github.com/laravel/framework/issues", - "source": "https://github.com/laravel/framework" - }, - "time": "2024-04-04T17:36:49+00:00" - }, { "name": "illuminate/contracts", "version": "v11.8.0", @@ -897,74 +786,6 @@ }, "time": "2024-04-17T14:09:55+00:00" }, - { - "name": "illuminate/database", - "version": "v11.8.0", - "source": { - "type": "git", - "url": "https://github.com/illuminate/database.git", - "reference": "a4e73c5ad7678d5ec934374e8522bf62a4d75d99" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/a4e73c5ad7678d5ec934374e8522bf62a4d75d99", - "reference": "a4e73c5ad7678d5ec934374e8522bf62a4d75d99", - "shasum": "" - }, - "require": { - "brick/math": "^0.9.3|^0.10.2|^0.11|^0.12", - "ext-pdo": "*", - "illuminate/collections": "^11.0", - "illuminate/container": "^11.0", - "illuminate/contracts": "^11.0", - "illuminate/macroable": "^11.0", - "illuminate/support": "^11.0", - "php": "^8.2" - }, - "suggest": { - "ext-filter": "Required to use the Postgres database driver.", - "fakerphp/faker": "Required to use the eloquent factory builder (^1.21).", - "illuminate/console": "Required to use the database commands (^11.0).", - "illuminate/events": "Required to use the observers with Eloquent (^11.0).", - "illuminate/filesystem": "Required to use the migrations (^11.0).", - "illuminate/pagination": "Required to paginate the result set (^11.0).", - "symfony/finder": "Required to use Eloquent model factories (^7.0)." - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "11.x-dev" - } - }, - "autoload": { - "psr-4": { - "Illuminate\\Database\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Taylor Otwell", - "email": "taylor@laravel.com" - } - ], - "description": "The Illuminate Database package.", - "homepage": "https://laravel.com", - "keywords": [ - "database", - "laravel", - "orm", - "sql" - ], - "support": { - "issues": "https://github.com/laravel/framework/issues", - "source": "https://github.com/laravel/framework" - }, - "time": "2024-05-21T15:24:23+00:00" - }, { "name": "illuminate/macroable", "version": "v11.8.0", @@ -1085,6 +906,57 @@ }, "time": "2024-05-21T15:24:23+00:00" }, + { + "name": "jenssegers/model", + "version": "v1.5.2", + "source": { + "type": "git", + "url": "https://github.com/jenssegers/model.git", + "reference": "2f91457d2efa7f0440ed8703a0d85ba65ee31b94" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jenssegers/model/zipball/2f91457d2efa7f0440ed8703a0d85ba65ee31b94", + "reference": "2f91457d2efa7f0440ed8703a0d85ba65ee31b94", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0", + "illuminate/support": "^4.0|^5.0|^6.0|^7.0|^8.0|^9.0|^10.0|^11.0" + }, + "require-dev": { + "php-coveralls/php-coveralls": "*", + "phpunit/phpunit": "*" + }, + "type": "library", + "autoload": { + "psr-4": { + "Jenssegers\\Model\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jens Segers", + "homepage": "https://jenssegers.com" + } + ], + "description": "An Laravel eloquent-like model class, for Laravel and other frameworks", + "homepage": "https://github.com/jenssegers/model", + "keywords": [ + "eloquent", + "laravel", + "model" + ], + "support": { + "issues": "https://github.com/jenssegers/model/issues", + "source": "https://github.com/jenssegers/model/tree/v1.5.2" + }, + "time": "2024-04-03T13:39:07+00:00" + }, { "name": "kevinrob/guzzle-cache-middleware", "version": "v5.1.0", diff --git a/src/Api/Api.php b/src/Api/Api.php index d73cdd6a..2b03dec7 100644 --- a/src/Api/Api.php +++ b/src/Api/Api.php @@ -8,10 +8,10 @@ use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\ApiClient\UserApiClient; -use SupportPal\ApiClient\Converter\ModelToArrayConverter; use SupportPal\ApiClient\Factory\Collection\CollectionFactory; use SupportPal\ApiClient\Factory\ModelCollectionFactory; -use Symfony\Component\Serializer\Encoder\DecoderInterface; + +use function json_decode; abstract class Api { @@ -20,53 +20,22 @@ abstract class Api /** @var UserApiClient|SelfServiceApiClient|TicketApiClient|CoreApiClient|ApiClient */ protected $apiClient; - /** @var ModelToArrayConverter */ - private $modelToArrayConverter; - - /** @var string */ - private $formatType; - /** @var ModelCollectionFactory */ private $modelCollectionFactory; - /** @var DecoderInterface */ - private $decoder; - /** @var CollectionFactory */ private $collectionFactory; public function __construct( - ModelToArrayConverter $modelToArrayConverter, ModelCollectionFactory $modelCollectionFactory, - string $formatType, - DecoderInterface $decoder, CollectionFactory $collectionFactory, ApiClient $apiClient ) { - $this->modelToArrayConverter = $modelToArrayConverter; - $this->formatType = $formatType; $this->modelCollectionFactory = $modelCollectionFactory; - $this->decoder = $decoder; $this->collectionFactory = $collectionFactory; $this->apiClient = $apiClient; } - /** - * @inheritDoc - */ - protected function getModelToArrayConverter(): ModelToArrayConverter - { - return $this->modelToArrayConverter; - } - - /** - * @inheritDoc - */ - protected function getFormatType(): string - { - return $this->formatType; - } - /** * @inheritDoc */ @@ -75,24 +44,13 @@ protected function getModelCollectionFactory(): ModelCollectionFactory return $this->modelCollectionFactory; } - /** - * @inheritDoc - */ - protected function getDecoder(): DecoderInterface - { - return $this->decoder; - } - /** * @param ResponseInterface $response * @return array */ protected function decodeBody(ResponseInterface $response): array { - /** @var array $body */ - $body = $this->getDecoder()->decode((string) $response->getBody(), $this->getFormatType()); - - return $body; + return json_decode((string) $response->getBody(), true); } /** diff --git a/src/Api/ApiAware.php b/src/Api/ApiAware.php index 82c8e6e2..500630bc 100644 --- a/src/Api/ApiAware.php +++ b/src/Api/ApiAware.php @@ -2,11 +2,8 @@ namespace SupportPal\ApiClient\Api; -use Psr\Http\Message\ResponseInterface; -use SupportPal\ApiClient\Converter\ModelToArrayConverter; use SupportPal\ApiClient\Factory\Collection\CollectionFactory; use SupportPal\ApiClient\Factory\ModelCollectionFactory; -use Symfony\Component\Serializer\Encoder\DecoderInterface; /** * Contains all required method definitions and attribute dependencies in Api traits @@ -20,27 +17,6 @@ trait ApiAware */ abstract protected function getModelCollectionFactory(): ModelCollectionFactory; - /** - * @return DecoderInterface - */ - abstract protected function getDecoder(): DecoderInterface; - - /** - * @return string - */ - abstract protected function getFormatType(): string; - - /** - * @return ModelToArrayConverter - */ - abstract protected function getModelToArrayConverter(): ModelToArrayConverter; - - /** - * @param ResponseInterface $response - * @return array - */ - abstract protected function decodeBody(ResponseInterface $response): array; - /** * @return CollectionFactory */ diff --git a/src/Api/SelfService/CommentApis.php b/src/Api/SelfService/CommentApis.php index d264c4dd..edd38adb 100644 --- a/src/Api/SelfService/CommentApis.php +++ b/src/Api/SelfService/CommentApis.php @@ -9,7 +9,6 @@ use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\SelfService\Comment; use SupportPal\ApiClient\Model\SelfService\Request\CreateComment; -use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException; use function array_map; @@ -26,21 +25,10 @@ trait CommentApis * @param CreateComment $comment * @return Comment * @throws HttpResponseException - * @throws InvalidArgumentException */ public function postComment(CreateComment $comment): Comment { - try { - $commentArray = $this->getModelToArrayConverter()->convertOne($comment); - } catch (UninitializedPropertyException $exception) { - throw new InvalidArgumentException( - $exception->getMessage(), - $exception->getCode(), - $exception->getPrevious() - ); - } - - $response = $this->getApiClient()->postComment($commentArray); + $response = $this->getApiClient()->postComment($comment->toArray()); return $this->createComment($this->decodeBody($response)['data']); } diff --git a/src/Api/Ticket/AttachmentApis.php b/src/Api/Ticket/AttachmentApis.php index d68399cd..65ef6126 100644 --- a/src/Api/Ticket/AttachmentApis.php +++ b/src/Api/Ticket/AttachmentApis.php @@ -2,7 +2,6 @@ namespace SupportPal\ApiClient\Api\Ticket; -use Error; use Psr\Http\Message\StreamInterface; use SupportPal\ApiClient\Api\ApiAware; use SupportPal\ApiClient\ApiClient\TicketApiClient; @@ -11,10 +10,8 @@ use SupportPal\ApiClient\Exception\MissingIdentifierException; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Ticket\Attachment; -use TypeError; use function array_map; -use function sprintf; trait AttachmentApis { @@ -55,19 +52,11 @@ public function getAttachment(int $attachmentId): Attachment */ public function downloadAttachment(Attachment $attachment): StreamInterface { - try { - $attachmentId = $attachment->getId(); - } catch (TypeError $typeError) { + if (! isset($attachment->id)) { throw new MissingIdentifierException('missing attachment identifier'); - } catch (Error $error) { - if ($error->getMessage() === sprintf('Typed property %s::$id must not be accessed before initialization', Attachment::class)) { - throw new MissingIdentifierException('missing attachment identifier'); - } - - throw $error; } - return $this->getApiClient()->downloadAttachment($attachmentId)->getBody(); + return $this->getApiClient()->downloadAttachment($attachment->id)->getBody(); } /** diff --git a/src/Api/Ticket/MessageApis.php b/src/Api/Ticket/MessageApis.php index 26ac1762..8e6427ef 100644 --- a/src/Api/Ticket/MessageApis.php +++ b/src/Api/Ticket/MessageApis.php @@ -9,7 +9,6 @@ use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Ticket\Message; use SupportPal\ApiClient\Model\Ticket\Request\CreateMessage; -use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException; use function array_map; @@ -25,17 +24,7 @@ trait MessageApis */ public function postMessage(CreateMessage $message): Message { - try { - $messageArray = $this->getModelToArrayConverter()->convertOne($message); - } catch (UninitializedPropertyException $exception) { - throw new InvalidArgumentException( - $exception->getMessage(), - $exception->getCode(), - $exception->getPrevious() - ); - } - - $response = $this->getApiClient()->postMessage($messageArray); + $response = $this->getApiClient()->postMessage($message->toArray()); return $this->createMessage($this->decodeBody($response)['data']); } diff --git a/src/Api/Ticket/TicketApis.php b/src/Api/Ticket/TicketApis.php index 04de91e8..54af429f 100644 --- a/src/Api/Ticket/TicketApis.php +++ b/src/Api/Ticket/TicketApis.php @@ -2,7 +2,6 @@ namespace SupportPal\ApiClient\Api\Ticket; -use Error; use SupportPal\ApiClient\Api\ApiAware; use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; @@ -11,11 +10,8 @@ use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Ticket\Request\CreateTicket; use SupportPal\ApiClient\Model\Ticket\Ticket; -use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException; -use TypeError; use function array_map; -use function sprintf; trait TicketApis { @@ -57,19 +53,11 @@ public function getTicket(int $ticketId): Ticket */ public function updateTicket(Ticket $ticket, array $data): Ticket { - try { - $ticketId = $ticket->getId(); - } catch (TypeError $typeError) { + if (! isset($ticket->id)) { throw new MissingIdentifierException('missing ticket identifier'); - } catch (Error $error) { - if ($error->getMessage() === sprintf('Typed property %s::$id must not be accessed before initialization', Ticket::class)) { - throw new MissingIdentifierException('missing ticket identifier'); - } - - throw $error; } - $response = $this->getApiClient()->updateTicket($ticketId, $data); + $response = $this->getApiClient()->updateTicket($ticket->id, $data); return $this->createTicket($this->decodeBody($response)['data']); } @@ -78,21 +66,10 @@ public function updateTicket(Ticket $ticket, array $data): Ticket * @param CreateTicket $createTicket * @return Ticket * @throws HttpResponseException - * @throws InvalidArgumentException */ public function postTicket(CreateTicket $createTicket): Ticket { - try { - $ticketArray = $this->getModelToArrayConverter()->convertOne($createTicket); - } catch (UninitializedPropertyException $exception) { - throw new InvalidArgumentException( - $exception->getMessage(), - $exception->getCode(), - $exception->getPrevious() - ); - } - - $response = $this->getApiClient()->postTicket($ticketArray); + $response = $this->getApiClient()->postTicket($createTicket->toArray()); return $this->createTicket($this->decodeBody($response)['data']); } diff --git a/src/Api/User/UserApis.php b/src/Api/User/UserApis.php index 07788319..e24b2d89 100644 --- a/src/Api/User/UserApis.php +++ b/src/Api/User/UserApis.php @@ -2,7 +2,6 @@ namespace SupportPal\ApiClient\Api\User; -use Error; use SupportPal\ApiClient\Api\ApiAware; use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; @@ -11,11 +10,8 @@ use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\User\Request\CreateUser; use SupportPal\ApiClient\Model\User\User; -use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException; -use TypeError; use function array_map; -use function sprintf; trait UserApis { @@ -57,19 +53,11 @@ public function getUser(int $userId): User */ public function updateUser(User $user, array $data): User { - try { - $userId = $user->getId(); - } catch (TypeError $typeError) { + if (! isset($user->id)) { throw new MissingIdentifierException('missing user identifier'); - } catch (Error $error) { - if ($error->getMessage() === sprintf('Typed property %s::$id must not be accessed before initialization', User::class)) { - throw new MissingIdentifierException('missing user identifier'); - } - - throw $error; } - $response = $this->getApiClient()->updateUser($userId, $data); + $response = $this->getApiClient()->updateUser($user->id, $data); return $this->createUser($this->decodeBody($response)['data']); } @@ -78,21 +66,10 @@ public function updateUser(User $user, array $data): User * @param CreateUser $createUser * @return User * @throws HttpResponseException - * @throws InvalidArgumentException */ public function postUser(CreateUser $createUser): User { - try { - $userArray = $this->getModelToArrayConverter()->convertOne($createUser); - } catch (UninitializedPropertyException $exception) { - throw new InvalidArgumentException( - $exception->getMessage(), - $exception->getCode(), - $exception->getPrevious() - ); - } - - $response = $this->getApiClient()->postUser($userArray); + $response = $this->getApiClient()->postUser($createUser->toArray()); return $this->createUser($this->decodeBody($response)['data']); } diff --git a/src/ApiClient.php b/src/ApiClient.php index 7e3b7284..7d9cd701 100644 --- a/src/ApiClient.php +++ b/src/ApiClient.php @@ -2,6 +2,7 @@ namespace SupportPal\ApiClient; +use JsonException; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; @@ -9,10 +10,11 @@ use SupportPal\ApiClient\ApiClient\ApiClientAware; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Factory\RequestFactory; -use Symfony\Component\Serializer\Encoder\DecoderInterface; -use Symfony\Component\Serializer\Exception\NotEncodableValueException; use function is_array; +use function json_decode; + +use const JSON_THROW_ON_ERROR; /** * This class includes all the API calls @@ -29,29 +31,17 @@ class ApiClient /** @var RequestFactory */ private $requestFactory; - /** @var DecoderInterface */ - private $decoder; - - /** @var string */ - private $formatType; - /** * ApiClient constructor. * @param ClientInterface $httpClient * @param RequestFactory $requestFactory - * @param DecoderInterface $decoder - * @param string $formatType */ public function __construct( ClientInterface $httpClient, - RequestFactory $requestFactory, - DecoderInterface $decoder, - string $formatType + RequestFactory $requestFactory ) { $this->httpClient = $httpClient; $this->requestFactory = $requestFactory; - $this->decoder = $decoder; - $this->formatType = $formatType; } /** @@ -107,14 +97,14 @@ protected function prepareAndSendGetRequest(string $endpoint, array $queryParame protected function assertRequestSuccessful(RequestInterface $request, ResponseInterface $response): void { try { - $body = $this->decoder->decode((string) $response->getBody(), $this->formatType); - } catch (NotEncodableValueException $notEncodableValueException) { + $body = json_decode((string) $response->getBody(), true, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $e) { throw new HttpResponseException( $request, $response, $response->getReasonPhrase(), - $notEncodableValueException->getCode(), - $notEncodableValueException + $e->getCode(), + $e ); } diff --git a/src/Converter/ModelToArrayConverter.php b/src/Converter/ModelToArrayConverter.php deleted file mode 100644 index 08a198b0..00000000 --- a/src/Converter/ModelToArrayConverter.php +++ /dev/null @@ -1,42 +0,0 @@ - array - * Class ModelToArrayConverter - * @package SupportPal\ApiClient\Converter - */ -class ModelToArrayConverter -{ - /** @var SerializerInterface */ - private $serializer; - - /** @var DecoderInterface */ - private $decoder; - - /** @var string */ - private $format; - - public function __construct(SerializerInterface $serializer, DecoderInterface $decoder, string $format) - { - $this->serializer = $serializer; - $this->decoder = $decoder; - $this->format = $format; - } - - /** - * @param Model $model - * @throws UninitializedPropertyException - * @return array - */ - public function convertOne(Model $model): array - { - return $this->decoder->decode($this->serializer->serialize($model, $this->format), $this->format); - } -} diff --git a/src/Factory/BaseModelFactory.php b/src/Factory/BaseModelFactory.php deleted file mode 100644 index 13c728e1..00000000 --- a/src/Factory/BaseModelFactory.php +++ /dev/null @@ -1,63 +0,0 @@ -serializer = $serializer; - $this->formatType = $formatType; - $this->encoder = $encoder; - } - - /** - * @inheritDoc - */ - public function create(array $data): Model - { - try { - /** @var Model $model */ - $model = $this->serializer->deserialize( - $this->encoder->encode($data, $this->formatType), - $this->getModel(), - $this->formatType - ); - } catch (Exception $invalidArgumentException) { - throw new InvalidDataException( - $data, - $invalidArgumentException->getMessage(), - $invalidArgumentException->getCode(), - $invalidArgumentException - ); - } - - return $model; - } -} diff --git a/src/Factory/Core/BrandFactory.php b/src/Factory/Core/BrandFactory.php index 7a295161..11a5ec9f 100644 --- a/src/Factory/Core/BrandFactory.php +++ b/src/Factory/Core/BrandFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\Core; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Core\Brand; -class BrandFactory extends BaseModelFactory +class BrandFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/ModelFactory.php b/src/Factory/ModelFactory.php index bfeb56f5..87686c79 100644 --- a/src/Factory/ModelFactory.php +++ b/src/Factory/ModelFactory.php @@ -2,26 +2,22 @@ namespace SupportPal\ApiClient\Factory; -use SupportPal\ApiClient\Exception\InvalidDataException; use SupportPal\ApiClient\Model\Model; /** - * Interface ModelFactory + * An abstract model factory that is the main base for all model factories + * Class AbstractModelFactory * @package SupportPal\ApiClient\Factory */ -interface ModelFactory +abstract class ModelFactory { /** - * This method creates an instance of a SupportPalModel - * @param array $data - * @throws InvalidDataException - * @return Model + * @inheritDoc */ - public function create(array $data): Model; + public function create(array $data): Model + { + return (new ($this->getModel))->fill($data); + } - /** - * This function returns the model name related to the relevant factory - * @return string - */ - public function getModel(): string; + abstract public function getModel(): string; } diff --git a/src/Factory/RequestFactory.php b/src/Factory/RequestFactory.php index e94c7fff..be14e0ac 100644 --- a/src/Factory/RequestFactory.php +++ b/src/Factory/RequestFactory.php @@ -6,11 +6,11 @@ use GuzzleHttp\Psr7\Uri; use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\RequestInterface; -use Symfony\Component\Serializer\Encoder\EncoderInterface; use function array_merge; use function base64_encode; use function http_build_query; +use function json_encode; /** * Class RequestFactory @@ -35,12 +35,6 @@ class RequestFactory */ private $contentType; - /** @var string */ - private $formatType; - - /** @var EncoderInterface */ - private $encoder; - /** @var array */ private $defaultParameters; @@ -52,8 +46,6 @@ class RequestFactory * @param string $apiUrl * @param string $apiToken * @param string $contentType - * @param string $formatType - * @param EncoderInterface $encoder * @param array $defaultBodyContent Body content that are always passed in the body of the result request * @param array $defaultParameters Parameters that are always appended to the result request */ @@ -61,16 +53,12 @@ public function __construct( string $apiUrl, string $apiToken, string $contentType, - string $formatType, - EncoderInterface $encoder, array $defaultBodyContent = [], array $defaultParameters = [] ) { $this->apiUrl = $apiUrl; $this->apiToken = $apiToken; $this->contentType = $contentType; - $this->formatType = $formatType; - $this->encoder = $encoder; $this->defaultBodyContent = $defaultBodyContent; $this->defaultParameters = $defaultParameters; } @@ -94,7 +82,7 @@ public function create( $headers['Authorization'] = $headers['Authorization'] ?? 'Basic ' . base64_encode($this->apiToken . ':X'); $bodyArray = array_merge($this->defaultBodyContent, $body); - $body = ! empty($bodyArray) ? Utils::streamFor($this->encoder->encode($bodyArray, $this->formatType)) : null; + $body = ! empty($bodyArray) ? Utils::streamFor(json_encode($bodyArray)) : null; $uri = new Uri($this->apiUrl . $endpoint); diff --git a/src/Factory/SelfService/ArticleFactory.php b/src/Factory/SelfService/ArticleFactory.php index c3fa9f20..c507ee20 100644 --- a/src/Factory/SelfService/ArticleFactory.php +++ b/src/Factory/SelfService/ArticleFactory.php @@ -2,14 +2,14 @@ namespace SupportPal\ApiClient\Factory\SelfService; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\SelfService\Article; /** * Class ArticleFactory * @package SupportPal\ApiClient\Factory\SelfService */ -class ArticleFactory extends BaseModelFactory +class ArticleFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/SelfService/CategoryFactory.php b/src/Factory/SelfService/CategoryFactory.php index 93c1444d..666ac8d4 100644 --- a/src/Factory/SelfService/CategoryFactory.php +++ b/src/Factory/SelfService/CategoryFactory.php @@ -2,14 +2,14 @@ namespace SupportPal\ApiClient\Factory\SelfService; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\SelfService\Category; /** * Class CategoryFactory * @package SupportPal\ApiClient\Factory\SelfService */ -class CategoryFactory extends BaseModelFactory +class CategoryFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/SelfService/CommentFactory.php b/src/Factory/SelfService/CommentFactory.php index 93d2a59b..c3d1c7cc 100644 --- a/src/Factory/SelfService/CommentFactory.php +++ b/src/Factory/SelfService/CommentFactory.php @@ -2,14 +2,14 @@ namespace SupportPal\ApiClient\Factory\SelfService; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\SelfService\Comment; /** * Class CommentFactory * @package SupportPal\ApiClient\Factory */ -class CommentFactory extends BaseModelFactory +class CommentFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/SelfService/TagFactory.php b/src/Factory/SelfService/TagFactory.php index 5ecdaecf..ec5e097e 100644 --- a/src/Factory/SelfService/TagFactory.php +++ b/src/Factory/SelfService/TagFactory.php @@ -2,14 +2,14 @@ namespace SupportPal\ApiClient\Factory\SelfService; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\SelfService\Tag; /** * Class TagFactory * @package SupportPal\ApiClient\Factory\SelfService */ -class TagFactory extends BaseModelFactory +class TagFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/SelfService/TypeFactory.php b/src/Factory/SelfService/TypeFactory.php index da897f57..caf3d25b 100644 --- a/src/Factory/SelfService/TypeFactory.php +++ b/src/Factory/SelfService/TypeFactory.php @@ -2,14 +2,14 @@ namespace SupportPal\ApiClient\Factory\SelfService; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\SelfService\Type; /** * Class ArticleTypeFactory * @package SupportPal\ApiClient\Factory */ -class TypeFactory extends BaseModelFactory +class TypeFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Shared/SettingsFactory.php b/src/Factory/Shared/SettingsFactory.php index d3fdc656..ac22fe66 100644 --- a/src/Factory/Shared/SettingsFactory.php +++ b/src/Factory/Shared/SettingsFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\Shared; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Shared\Settings; -class SettingsFactory extends BaseModelFactory +class SettingsFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Ticket/AttachmentFactory.php b/src/Factory/Ticket/AttachmentFactory.php index d6cc1ceb..285b3ec4 100644 --- a/src/Factory/Ticket/AttachmentFactory.php +++ b/src/Factory/Ticket/AttachmentFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\Ticket; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Ticket\Attachment; -class AttachmentFactory extends BaseModelFactory +class AttachmentFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Ticket/ChannelSettingsFactory.php b/src/Factory/Ticket/ChannelSettingsFactory.php index 4234042a..51c0da1a 100644 --- a/src/Factory/Ticket/ChannelSettingsFactory.php +++ b/src/Factory/Ticket/ChannelSettingsFactory.php @@ -2,14 +2,14 @@ namespace SupportPal\ApiClient\Factory\Ticket; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Ticket\ChannelSettings; /** * Class ChannelSettingsFactory * @package SupportPal\ApiClient\Factory\Ticket */ -class ChannelSettingsFactory extends BaseModelFactory +class ChannelSettingsFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Ticket/CustomFieldFactory.php b/src/Factory/Ticket/CustomFieldFactory.php index 6557965b..57b9a605 100644 --- a/src/Factory/Ticket/CustomFieldFactory.php +++ b/src/Factory/Ticket/CustomFieldFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\Ticket; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Ticket\TicketCustomField; -class CustomFieldFactory extends BaseModelFactory +class CustomFieldFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Ticket/DepartmentFactory.php b/src/Factory/Ticket/DepartmentFactory.php index 7d231e4f..8f5b85b5 100644 --- a/src/Factory/Ticket/DepartmentFactory.php +++ b/src/Factory/Ticket/DepartmentFactory.php @@ -2,14 +2,14 @@ namespace SupportPal\ApiClient\Factory\Ticket; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Department\Department; /** * Class DepartmentFactory * @package SupportPal\ApiClient\Factory\Ticket */ -class DepartmentFactory extends BaseModelFactory +class DepartmentFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Ticket/MessageFactory.php b/src/Factory/Ticket/MessageFactory.php index 358315a1..61105cc8 100644 --- a/src/Factory/Ticket/MessageFactory.php +++ b/src/Factory/Ticket/MessageFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\Ticket; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Ticket\Message; -class MessageFactory extends BaseModelFactory +class MessageFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Ticket/PriorityFactory.php b/src/Factory/Ticket/PriorityFactory.php index ee59ef86..75d43052 100644 --- a/src/Factory/Ticket/PriorityFactory.php +++ b/src/Factory/Ticket/PriorityFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\Ticket; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Ticket\Priority; -class PriorityFactory extends BaseModelFactory +class PriorityFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Ticket/StatusFactory.php b/src/Factory/Ticket/StatusFactory.php index f61bd6e5..0cadb7c1 100644 --- a/src/Factory/Ticket/StatusFactory.php +++ b/src/Factory/Ticket/StatusFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\Ticket; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Ticket\Status; -class StatusFactory extends BaseModelFactory +class StatusFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/Ticket/TicketFactory.php b/src/Factory/Ticket/TicketFactory.php index 9c233fb5..554bc2c5 100644 --- a/src/Factory/Ticket/TicketFactory.php +++ b/src/Factory/Ticket/TicketFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\Ticket; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Ticket\Ticket; -class TicketFactory extends BaseModelFactory +class TicketFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/User/GroupFactory.php b/src/Factory/User/GroupFactory.php index 5463365d..65afa6e2 100644 --- a/src/Factory/User/GroupFactory.php +++ b/src/Factory/User/GroupFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\User; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\User\Group; -class GroupFactory extends BaseModelFactory +class GroupFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/User/UserCustomFieldFactory.php b/src/Factory/User/UserCustomFieldFactory.php index ae51727f..ccffb195 100644 --- a/src/Factory/User/UserCustomFieldFactory.php +++ b/src/Factory/User/UserCustomFieldFactory.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Factory\User; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\User\UserCustomField; -class UserCustomFieldFactory extends BaseModelFactory +class UserCustomFieldFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Factory/User/UserFactory.php b/src/Factory/User/UserFactory.php index fc124066..e6feb45c 100644 --- a/src/Factory/User/UserFactory.php +++ b/src/Factory/User/UserFactory.php @@ -2,14 +2,14 @@ namespace SupportPal\ApiClient\Factory\User; -use SupportPal\ApiClient\Factory\BaseModelFactory; +use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\User\User; /** * Class UserFactory * @package SupportPal\ApiClient\Factory */ -class UserFactory extends BaseModelFactory +class UserFactory extends ModelFactory { /** * @inheritDoc diff --git a/src/Model/Core/Brand.php b/src/Model/Core/Brand.php index 3e655766..11813391 100644 --- a/src/Model/Core/Brand.php +++ b/src/Model/Core/Brand.php @@ -2,591 +2,46 @@ namespace SupportPal\ApiClient\Model\Core; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Brand extends BaseModel +class Brand extends Model { - public const REQUIRED_FIELDS = [ - 'default_language', - 'default_country', - 'frontend_template_mode', - 'enabled', - 'email_method', - 'system_url', - 'name', - 'default_email', - 'created_at', - 'frontend_template', - 'date_format', - 'time_format', - 'global_email_header', - 'global_email_footer', - 'default_timezone', - 'language_toggle', - 'operator_template_mode', - 'updated_at' + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'enabled' => 'int', + 'system_url' => 'string', + 'enable_ssl' => 'int', + 'brand_colour' => 'string', + 'frontend_logo' => 'string', + 'frontend_logo_dark_mode' => 'string', + 'website_url' => 'string', + 'favicon' => 'string', + 'favicon_dark_mode' => 'string', + 'frontend_template' => 'string', + 'operator_icon' => 'string', + 'operator_template' => 'string', + 'default_email' => 'string', + 'global_email_header' => 'string', + 'global_email_footer' => 'string', + 'email_method' => 'string', + 'smtp_host' => 'string', + 'smtp_port' => 'int', + 'smtp_encryption' => 'string', + 'smtp_requires_auth' => 'int', + 'smtp_auth_mech' => 'string', + 'smtp_username' => 'string', + 'smtp_password' => 'string', + 'smtp_oauth' => 'string', + 'default_country' => 'string', + 'default_timezone' => 'string', + 'date_format' => 'string', + 'time_format' => 'string', + 'default_language' => 'string', + 'language_toggle' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'translations' => 'array:' . BrandTranslation::class, ]; - - #[SerializedName('operator_template')] - private ?string $operatorTemplate; - - #[SerializedName('default_language')] - private string $defaultLanguage; - - #[SerializedName('favicon')] - private ?string $favicon; - - #[SerializedName('favicon_dark_mode')] - private ?string $faviconDarkMode; - - #[SerializedName('smtp_username')] - private ?string $smtpUsername; - - #[SerializedName('default_country')] - private string $defaultCountry; - - #[SerializedName('frontend_template_mode')] - private ?int $frontendTemplateMode; - - #[SerializedName('operator_icon')] - private ?string $operatorIcon; - - #[SerializedName('enabled')] - private bool $enabled; - - #[SerializedName('email_method')] - private string $emailMethod; - - #[SerializedName('system_url')] - private string $systemUrl; - - #[SerializedName('smtp_port')] - private ?int $smtpPort; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('smtp_password')] - private ?string $smtpPassword; - - #[SerializedName('smtp_requires_auth')] - private ?bool $smtpRequiresAuth; - - #[SerializedName('enable_ssl')] - private ?int $enableSsl; - - #[SerializedName('frontend_logo_dark_mode')] - private ?string $frontendLogoDarkMode; - - #[SerializedName('default_email')] - private string $defaultEmail; - - #[SerializedName('brand_colour')] - private ?string $brandColour; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('frontend_template')] - private string $frontendTemplate; - - #[SerializedName('website_url')] - private ?string $websiteUrl; - - #[SerializedName('smtp_host')] - private ?string $smtpHost; - - #[SerializedName('date_format')] - private string $dateFormat; - - #[SerializedName('time_format')] - private string $timeFormat; - - #[SerializedName('frontend_logo')] - private ?string $frontendLogo; - - #[SerializedName('global_email_header')] - private string $globalEmailHeader; - - #[SerializedName('global_email_footer')] - private string $globalEmailFooter; - - #[SerializedName('smtp_encryption')] - private ?string $smtpEncryption; - - #[SerializedName('default_timezone')] - private string $defaultTimezone; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('language_toggle')] - private int $languageToggle; - - #[SerializedName('operator_template_mode')] - private ?int $operatorTemplateMode; - - #[SerializedName('updated_at')] - private int $updatedAt; - - /** @var BrandTranslation[]|null */ - #[SerializedName('translations')] - private ?array $translations; - - #[SerializedName('smtp_auth_mech')] - private ?string $smtpAuthMech = null; - - #[SerializedName('smtp_oauth')] - private ?string $smtpOauth = null; - - public function getOperatorTemplate(): ?string - { - return $this->operatorTemplate; - } - - public function setOperatorTemplate(?string $operatorTemplate): self - { - $this->operatorTemplate = $operatorTemplate; - - return $this; - } - - public function getDefaultLanguage(): string - { - return $this->defaultLanguage; - } - - public function setDefaultLanguage(string $defaultLanguage): self - { - $this->defaultLanguage = $defaultLanguage; - - return $this; - } - - public function getFavicon(): ?string - { - return $this->favicon; - } - - public function setFavicon(?string $favicon): self - { - $this->favicon = $favicon; - - return $this; - } - - public function getFaviconDarkMode(): ?string - { - return $this->faviconDarkMode; - } - - public function setFaviconDarkMode(?string $favicon): self - { - $this->faviconDarkMode = $favicon; - - return $this; - } - - public function getSmtpUsername(): ?string - { - return $this->smtpUsername; - } - - public function setSmtpUsername(?string $smtpUsername): self - { - $this->smtpUsername = $smtpUsername; - - return $this; - } - - public function getDefaultCountry(): string - { - return $this->defaultCountry; - } - - public function setDefaultCountry(string $defaultCountry): self - { - $this->defaultCountry = $defaultCountry; - - return $this; - } - - public function getFrontendTemplateMode(): ?int - { - return $this->frontendTemplateMode; - } - - public function setFrontendTemplateMode(?int $frontendTemplateMode): self - { - $this->frontendTemplateMode = $frontendTemplateMode; - - return $this; - } - - public function getOperatorIcon(): ?string - { - return $this->operatorIcon; - } - - public function setOperatorIcon(?string $operatorIcon): self - { - $this->operatorIcon = $operatorIcon; - - return $this; - } - - public function getEnabled(): bool - { - return $this->enabled; - } - - public function setEnabled(bool $enabled): self - { - $this->enabled = $enabled; - - return $this; - } - - public function getEmailMethod(): string - { - return $this->emailMethod; - } - - public function setEmailMethod(string $emailMethod): self - { - $this->emailMethod = $emailMethod; - - return $this; - } - - public function getSystemUrl(): string - { - return $this->systemUrl; - } - - public function setSystemUrl(string $systemUrl): self - { - $this->systemUrl = $systemUrl; - - return $this; - } - - public function getSmtpPort(): ?int - { - return $this->smtpPort; - } - - public function setSmtpPort(?int $smtpPort): self - { - $this->smtpPort = $smtpPort; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getSmtpPassword(): ?string - { - return $this->smtpPassword; - } - - public function setSmtpPassword(?string $smtpPassword): self - { - $this->smtpPassword = $smtpPassword; - - return $this; - } - - public function getSmtpRequiresAuth(): ?bool - { - return $this->smtpRequiresAuth; - } - - public function setSmtpRequiresAuth(?bool $smtpRequiresAuth): self - { - $this->smtpRequiresAuth = $smtpRequiresAuth; - - return $this; - } - - public function getEnableSsl(): ?int - { - return $this->enableSsl; - } - - public function setEnableSsl(?int $enableSsl): self - { - $this->enableSsl = $enableSsl; - - return $this; - } - - public function getFrontendLogoDarkMode(): ?string - { - return $this->frontendLogoDarkMode; - } - - public function setFrontendLogoDarkMode(?string $frontendLogoDarkMode): self - { - $this->frontendLogoDarkMode = $frontendLogoDarkMode; - - return $this; - } - - public function getDefaultEmail(): string - { - return $this->defaultEmail; - } - - public function setDefaultEmail(string $defaultEmail): self - { - $this->defaultEmail = $defaultEmail; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getFrontendTemplate(): string - { - return $this->frontendTemplate; - } - - public function setFrontendTemplate(string $frontendTemplate): self - { - $this->frontendTemplate = $frontendTemplate; - - return $this; - } - - public function getWebsiteUrl(): ?string - { - return $this->websiteUrl; - } - - public function setWebsiteUrl(?string $websiteUrl): self - { - $this->websiteUrl = $websiteUrl; - - return $this; - } - - public function getSmtpHost(): ?string - { - return $this->smtpHost; - } - - public function setSmtpHost(?string $smtpHost): self - { - $this->smtpHost = $smtpHost; - - return $this; - } - - public function getDateFormat(): string - { - return $this->dateFormat; - } - - public function setDateFormat(string $dateFormat): self - { - $this->dateFormat = $dateFormat; - - return $this; - } - - public function getTimeFormat(): string - { - return $this->timeFormat; - } - - public function setTimeFormat(string $timeFormat): self - { - $this->timeFormat = $timeFormat; - - return $this; - } - - public function getFrontendLogo(): ?string - { - return $this->frontendLogo; - } - - public function setFrontendLogo(?string $frontendLogo): self - { - $this->frontendLogo = $frontendLogo; - - return $this; - } - - public function getGlobalEmailHeader(): string - { - return $this->globalEmailHeader; - } - - public function setGlobalEmailHeader(string $globalEmailHeader): self - { - $this->globalEmailHeader = $globalEmailHeader; - - return $this; - } - - public function getGlobalEmailFooter(): string - { - return $this->globalEmailFooter; - } - - public function setGlobalEmailFooter(string $globalEmailFooter): self - { - $this->globalEmailFooter = $globalEmailFooter; - - return $this; - } - - public function getSmtpEncryption(): ?string - { - return $this->smtpEncryption; - } - - public function setSmtpEncryption(?string $smtpEncryption): self - { - $this->smtpEncryption = $smtpEncryption; - - return $this; - } - - public function getDefaultTimezone(): string - { - return $this->defaultTimezone; - } - - public function setDefaultTimezone(string $defaultTimezone): self - { - $this->defaultTimezone = $defaultTimezone; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getLanguageToggle(): int - { - return $this->languageToggle; - } - - public function setLanguageToggle(int $languageToggle): self - { - $this->languageToggle = $languageToggle; - - return $this; - } - - public function getOperatorTemplateMode(): ?int - { - return $this->operatorTemplateMode; - } - - public function setOperatorTemplateMode(?int $operatorTemplateMode): self - { - $this->operatorTemplateMode = $operatorTemplateMode; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getBrandColour(): ?string - { - return $this->brandColour; - } - - public function setBrandColour(?string $brandColour): Brand - { - $this->brandColour = $brandColour; - - return $this; - } - - /** - * @return BrandTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param BrandTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } - - public function getSmtpAuthMech(): ?string - { - return $this->smtpAuthMech; - } - - public function setSmtpAuthMech(?string $smtpAuthMech): self - { - $this->smtpAuthMech = $smtpAuthMech; - - return $this; - } - - public function getSmtpOauth(): ?string - { - return $this->smtpOauth; - } - - public function setSmtpOauth(?string $smtpOauth): self - { - $this->smtpOauth = $smtpOauth; - - return $this; - } } diff --git a/src/Model/Core/BrandTranslation.php b/src/Model/Core/BrandTranslation.php index a5ee2960..5169367d 100644 --- a/src/Model/Core/BrandTranslation.php +++ b/src/Model/Core/BrandTranslation.php @@ -2,56 +2,14 @@ namespace SupportPal\ApiClient\Model\Core; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class BrandTranslation extends BaseTranslation +class BrandTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('brand_id')] - private int $brandId; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): BrandTranslation - { - $this->name = $name; - - return $this; - } - - public function getBrandId(): int - { - return $this->brandId; - } - - public function setBrandId(int $brandId): self - { - $this->brandId = $brandId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'brand_id' => 'int', + ]; } diff --git a/src/Model/Core/Upload.php b/src/Model/Core/Upload.php index c10d7150..0205b976 100644 --- a/src/Model/Core/Upload.php +++ b/src/Model/Core/Upload.php @@ -2,160 +2,20 @@ namespace SupportPal\ApiClient\Model\Core; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; -use Symfony\Contracts\Service\Attribute\Required; +use SupportPal\ApiClient\Model\Model; -class Upload extends BaseModel +class Upload extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('hash')] - private string $hash; - - #[SerializedName('filename')] - private string $filename; - - #[SerializedName('folder')] - private string $folder; - - #[SerializedName('mime')] - private string $mime; - - #[SerializedName('size')] - private string $size; - - #[SerializedName('token')] - private ?string $token; - - #[Required] - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('session_id')] - private ?string $sessionId = null; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getHash(): string - { - return $this->hash; - } - - public function setHash(string $hash): self - { - $this->hash = $hash; - - return $this; - } - - public function getFilename(): string - { - return $this->filename; - } - - public function setFilename(string $filename): self - { - $this->filename = $filename; - - return $this; - } - - public function getFolder(): string - { - return $this->folder; - } - - public function setFolder(string $folder): self - { - $this->folder = $folder; - - return $this; - } - - public function getMime(): string - { - return $this->mime; - } - - public function setMime(string $mime): self - { - $this->mime = $mime; - - return $this; - } - - public function getSize(): string - { - return $this->size; - } - - public function setSize(string $size): self - { - $this->size = $size; - - return $this; - } - - public function getToken(): ?string - { - return $this->token; - } - - public function setToken(?string $token): self - { - $this->token = $token; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getSessionId(): ?string - { - return $this->sessionId; - } - - public function setSessionId(?string $sessionId): self - { - $this->sessionId = $sessionId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'hash' => 'string', + 'filename' => 'string', + 'folder' => 'string', + 'mime' => 'string', + 'size' => 'string', + 'token' => 'string', + 'session_id' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + ]; } diff --git a/src/Model/Department/Department.php b/src/Model/Department/Department.php index 77d6a6f9..d7263571 100644 --- a/src/Model/Department/Department.php +++ b/src/Model/Department/Department.php @@ -2,372 +2,34 @@ namespace SupportPal\ApiClient\Model\Department; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; +use SupportPal\ApiClient\Model\User\Group; -class Department extends BaseModel +class Department extends Model { - #[SerializedName('disable_user_email_replies')] - private bool $disableUserEmailReplies; - - #[SerializedName('public')] - private bool $public; - - #[SerializedName('ticket_number_format')] - private ?string $ticketNumberFormat; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('notify_frontend_ticket')] - private bool $notifyFrontendTicket; - - #[SerializedName('order')] - private ?int $order; - - #[SerializedName('description')] - private ?string $description; - - #[SerializedName('notify_email_ticket')] - private bool $notifyEmailTicket; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('from_name')] - private ?string $fromName; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('registered_only')] - private int $registeredOnly; - - #[SerializedName('parent_id')] - private ?int $parentId; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('notify_operators')] - private bool $notifyOperators; - - /** @var string[] */ - #[SerializedName('default_assignedto')] - private array $defaultAssignedto; - - #[SerializedName('email_templates')] - private ?EmailTemplates $emailTemplates; - - /** @var Email[]|null */ - #[SerializedName('emails')] - private ?array $emails; - - /** @var array|null */ - #[SerializedName('groups')] - private ?array $groups; - - /** @var Operator[]|null */ - #[SerializedName('operators')] - private ?array $operators; - - /** @var DepartmentTranslation[]|null */ - #[SerializedName('translations')] - private ?array $translations; - - private ?Department $parent = null; - - public function getDisableUserEmailReplies(): bool - { - return $this->disableUserEmailReplies; - } - - public function setDisableUserEmailReplies(bool $disableUserEmailReplies): self - { - $this->disableUserEmailReplies = $disableUserEmailReplies; - - return $this; - } - - public function getPublic(): bool - { - return $this->public; - } - - public function setPublic(bool $public): self - { - $this->public = $public; - - return $this; - } - - public function getTicketNumberFormat(): ?string - { - return $this->ticketNumberFormat; - } - - public function setTicketNumberFormat(?string $ticketNumberFormat): self - { - $this->ticketNumberFormat = $ticketNumberFormat; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getNotifyFrontendTicket(): bool - { - return $this->notifyFrontendTicket; - } - - public function setNotifyFrontendTicket(bool $notifyFrontendTicket): self - { - $this->notifyFrontendTicket = $notifyFrontendTicket; - - return $this; - } - - public function getOrder(): ?int - { - return $this->order; - } - - public function setOrder(?int $order): self - { - $this->order = $order; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } - - public function getNotifyEmailTicket(): bool - { - return $this->notifyEmailTicket; - } - - public function setNotifyEmailTicket(bool $notifyEmailTicket): self - { - $this->notifyEmailTicket = $notifyEmailTicket; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getFromName(): ?string - { - return $this->fromName; - } - - public function setFromName(?string $fromName): self - { - $this->fromName = $fromName; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getRegisteredOnly(): int - { - return $this->registeredOnly; - } - - public function setRegisteredOnly(int $registeredOnly): self - { - $this->registeredOnly = $registeredOnly; - - return $this; - } - - public function getParentId(): ?int - { - return $this->parentId; - } - - public function setParentId(?int $parentId): self - { - $this->parentId = $parentId; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getNotifyOperators(): bool - { - return $this->notifyOperators; - } - - public function setNotifyOperators(bool $notifyOperators): self - { - $this->notifyOperators = $notifyOperators; - - return $this; - } - - /** - * @return string[] - */ - public function getDefaultAssignedto(): array - { - return $this->defaultAssignedto; - } - - /** - * @param string[] $defaultAssignedto - */ - public function setDefaultAssignedto(array $defaultAssignedto): self - { - $this->defaultAssignedto = $defaultAssignedto; - - return $this; - } - - public function getEmailTemplates(): ?EmailTemplates - { - return $this->emailTemplates; - } - - public function setEmailTemplates(?EmailTemplates $emailTemplates): self - { - $this->emailTemplates = $emailTemplates; - - return $this; - } - - /** - * @return Email[]|null - */ - public function getEmails(): ?array - { - return $this->emails; - } - - /** - * @param Email[]|null $emails - */ - public function setEmails(?array $emails): self - { - $this->emails = $emails; - - return $this; - } - - /** - * @return array|null - */ - public function getGroups(): ?array - { - return $this->groups; - } - - /** - * @param array|null $groups - */ - public function setGroups(?array $groups): self - { - $this->groups = $groups; - - return $this; - } - - /** - * @return Operator[]|null - */ - public function getOperators(): ?array - { - return $this->operators; - } - - /** - * @param Operator[]|null $operators - */ - public function setOperators(?array $operators): self - { - $this->operators = $operators; - - return $this; - } - - /** - * @return DepartmentTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param DepartmentTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } - - public function getParent(): ?Department - { - return $this->parent; - } - - public function setParent(?Department $parent): self - { - $this->parent = $parent; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'description' => 'string', + 'order' => 'int', + 'parent_id' => 'int', + 'public' => 'int', + 'ticket_number_format' => 'string', + 'from_name' => 'string', + 'notify_frontend_ticket' => 'int', + 'notify_email_ticket' => 'int', + 'notify_operators' => 'int', + 'disable_user_email_replies' => 'int', + 'registered_only' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'email_templates' => 'array:' . EmailTemplates::class, + 'emails' => 'array:' . Email::class, + 'translations' => 'array:' . DepartmentTranslation::class, + 'groups' => 'array:' . Group::class, + 'operators' => 'array:' . Operator::class, + 'parent' => 'array:' . self::class, + 'default_assignedto' => 'array:' . Operator::class, + ]; } diff --git a/src/Model/Department/DepartmentTranslation.php b/src/Model/Department/DepartmentTranslation.php index 3b34e03f..224af8ba 100644 --- a/src/Model/Department/DepartmentTranslation.php +++ b/src/Model/Department/DepartmentTranslation.php @@ -2,71 +2,15 @@ namespace SupportPal\ApiClient\Model\Department; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class DepartmentTranslation extends BaseTranslation +class DepartmentTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('description')] - private ?string $description; - - #[SerializedName('department_id')] - private int $departmentId; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } - - public function getDepartmentId(): int - { - return $this->departmentId; - } - - public function setDepartmentId(int $departmentId): self - { - $this->departmentId = $departmentId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'description' => 'string', + 'department_id' => 'int', + ]; } diff --git a/src/Model/Department/Email.php b/src/Model/Department/Email.php index b1d8fb26..792fd9cc 100644 --- a/src/Model/Department/Email.php +++ b/src/Model/Department/Email.php @@ -2,275 +2,27 @@ namespace SupportPal\ApiClient\Model\Department; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; -use TypeError; +use SupportPal\ApiClient\Model\Model; -use function filter_var; -use function is_int; - -use const FILTER_VALIDATE_INT; - -class Email extends BaseModel +class Email extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('port')] - private ?string $port; - - #[SerializedName('department_id')] - private int|string $departmentId; - - #[SerializedName('type')] - private int $type; - - #[SerializedName('server')] - private ?string $server; - - #[SerializedName('username')] - private ?string $username; - - #[SerializedName('encryption')] - private ?int $encryption; - - #[SerializedName('delete_downloaded')] - private ?bool $deleteDownloaded; - - #[SerializedName('address')] - private string $address; - - #[SerializedName('protocol')] - private ?int $protocol; - - #[SerializedName('brand_id')] - private int $brandId; - - #[SerializedName('password')] - private ?string $password; - - #[SerializedName('consume_all')] - private ?bool $consumeAll; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('oauth')] - private ?string $oauth; - - #[SerializedName('auth_mech')] - private ?string $authMech; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getPort(): ?string - { - return $this->port; - } - - public function setPort(?string $port): self - { - $this->port = $port; - - return $this; - } - - public function getDepartmentId(): int - { - return (int) $this->departmentId; - } - - public function setDepartmentId(string|int $departmentId): self - { - $departmentId = filter_var($departmentId, FILTER_VALIDATE_INT); - - if (! is_int($departmentId)) { - throw new TypeError('Passed DepartmentId value must be an int'); - } - - $this->departmentId = $departmentId; - - return $this; - } - - public function getType(): int - { - return $this->type; - } - - public function setType(int $type): self - { - $this->type = $type; - - return $this; - } - - public function getServer(): ?string - { - return $this->server; - } - - public function setServer(?string $server): self - { - $this->server = $server; - - return $this; - } - - public function getUsername(): ?string - { - return $this->username; - } - - public function setUsername(?string $username): self - { - $this->username = $username; - - return $this; - } - - public function getEncryption(): ?int - { - return $this->encryption; - } - - public function setEncryption(?int $encryption): self - { - $this->encryption = $encryption; - - return $this; - } - - public function getDeleteDownloaded(): ?bool - { - return $this->deleteDownloaded; - } - - public function setDeleteDownloaded(?bool $deleteDownloaded): self - { - $this->deleteDownloaded = $deleteDownloaded; - - return $this; - } - - public function getAddress(): string - { - return $this->address; - } - - public function setAddress(string $address): self - { - $this->address = $address; - - return $this; - } - - public function getProtocol(): ?int - { - return $this->protocol; - } - - public function setProtocol(?int $protocol): self - { - $this->protocol = $protocol; - - return $this; - } - - public function getBrandId(): int - { - return $this->brandId; - } - - public function setBrandId(int $brandId): self - { - $this->brandId = $brandId; - - return $this; - } - - public function getPassword(): ?string - { - return $this->password; - } - - public function setPassword(?string $password): self - { - $this->password = $password; - - return $this; - } - - public function getConsumeAll(): ?bool - { - return $this->consumeAll; - } - - public function setConsumeAll(?bool $consumeAll): self - { - $this->consumeAll = $consumeAll; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getOauth(): ?string - { - return $this->oauth; - } - - public function setOauth(?string $oauth): self - { - $this->oauth = $oauth; - - return $this; - } - - public function getAuthMech(): ?string - { - return $this->authMech; - } - - public function setAuthMech(?string $authMech): self - { - $this->authMech = $authMech; - - return $this; - } + /** @var array */ + protected $casts = [ + 'department_id' => 'int', + 'brand_id' => 'int', + 'address' => 'string', + 'type' => 'int', + 'protocol' => 'int', + 'server' => 'string', + 'username' => 'string', + 'auth_mech' => 'string', + 'password' => 'string', + 'oauth' => 'string', + 'port' => 'string', + 'encryption' => 'int', + 'consume_all' => 'int', + 'delete_downloaded' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + ]; } diff --git a/src/Model/Department/EmailTemplates.php b/src/Model/Department/EmailTemplates.php index 81e7a9b8..eaab20cb 100644 --- a/src/Model/Department/EmailTemplates.php +++ b/src/Model/Department/EmailTemplates.php @@ -2,263 +2,28 @@ namespace SupportPal\ApiClient\Model\Department; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class EmailTemplates extends BaseModel +class EmailTemplates extends Model { - #[SerializedName('operator_department_changed')] - private int $operatorDepartmentChanged; - - #[SerializedName('operator_internal_opened')] - private int $operatorInternalOpened; - - #[SerializedName('user_ticket_locked')] - private int $userTicketLocked; - - #[SerializedName('user_ticket_reply')] - private int $userTicketReply; - - #[SerializedName('operator_assigned')] - private int $operatorAssigned; - - #[SerializedName('operator_ticket_note')] - private int $operatorTicketNote; - - #[SerializedName('user_ticket_opened')] - private int $userTicketOpened; - - #[SerializedName('user_ticket_operatorclose')] - private int $userTicketOperatorclose; - - #[SerializedName('operator_ticket_opened')] - private int $operatorTicketOpened; - - #[SerializedName('user_ticket_registeredonly')] - private int $userTicketRegisteredonly; - - #[SerializedName('user_ticket_autoclose')] - private int $userTicketAutoclose; - - #[SerializedName('user_email_attachmentrejected')] - private int $userEmailAttachmentrejected; - - #[SerializedName('operator_operator_ticket_reply')] - private int $operatorOperatorTicketReply; - - #[SerializedName('user_ticket_waitingresponse')] - private int $userTicketWaitingresponse; - - #[SerializedName('user_user_ticket_reply')] - private int $userUserTicketReply; - - #[SerializedName('user_ticket_disablereplies')] - private int $userTicketDisablereplies; - - #[SerializedName('operator_user_ticket_reply')] - private int $operatorUserTicketReply; - - public function getOperatorDepartmentChanged(): int - { - return $this->operatorDepartmentChanged; - } - - public function setOperatorDepartmentChanged(int $operatorDepartmentChanged): self - { - $this->operatorDepartmentChanged = $operatorDepartmentChanged; - - return $this; - } - - public function getOperatorInternalOpened(): int - { - return $this->operatorInternalOpened; - } - - public function setOperatorInternalOpened(int $operatorInternalOpened): self - { - $this->operatorInternalOpened = $operatorInternalOpened; - - return $this; - } - - public function getUserTicketLocked(): int - { - return $this->userTicketLocked; - } - - public function setUserTicketLocked(int $userTicketLocked): self - { - $this->userTicketLocked = $userTicketLocked; - - return $this; - } - - public function getUserTicketReply(): int - { - return $this->userTicketReply; - } - - public function setUserTicketReply(int $userTicketReply): self - { - $this->userTicketReply = $userTicketReply; - - return $this; - } - - public function getOperatorAssigned(): int - { - return $this->operatorAssigned; - } - - public function setOperatorAssigned(int $operatorAssigned): self - { - $this->operatorAssigned = $operatorAssigned; - - return $this; - } - - public function getOperatorTicketNote(): int - { - return $this->operatorTicketNote; - } - - public function setOperatorTicketNote(int $operatorTicketNote): self - { - $this->operatorTicketNote = $operatorTicketNote; - - return $this; - } - - public function getUserTicketOpened(): int - { - return $this->userTicketOpened; - } - - public function setUserTicketOpened(int $userTicketOpened): self - { - $this->userTicketOpened = $userTicketOpened; - - return $this; - } - - public function getUserTicketOperatorclose(): int - { - return $this->userTicketOperatorclose; - } - - public function setUserTicketOperatorclose(int $userTicketOperatorclose): self - { - $this->userTicketOperatorclose = $userTicketOperatorclose; - - return $this; - } - - public function getOperatorTicketOpened(): int - { - return $this->operatorTicketOpened; - } - - public function setOperatorTicketOpened(int $operatorTicketOpened): self - { - $this->operatorTicketOpened = $operatorTicketOpened; - - return $this; - } - - public function getUserTicketRegisteredonly(): int - { - return $this->userTicketRegisteredonly; - } - - public function setUserTicketRegisteredonly(int $userTicketRegisteredonly): self - { - $this->userTicketRegisteredonly = $userTicketRegisteredonly; - - return $this; - } - - public function getUserTicketAutoclose(): int - { - return $this->userTicketAutoclose; - } - - public function setUserTicketAutoclose(int $userTicketAutoclose): self - { - $this->userTicketAutoclose = $userTicketAutoclose; - - return $this; - } - - public function getUserEmailAttachmentrejected(): int - { - return $this->userEmailAttachmentrejected; - } - - public function setUserEmailAttachmentrejected(int $userEmailAttachmentrejected): self - { - $this->userEmailAttachmentrejected = $userEmailAttachmentrejected; - - return $this; - } - - public function getOperatorOperatorTicketReply(): int - { - return $this->operatorOperatorTicketReply; - } - - public function setOperatorOperatorTicketReply(int $operatorOperatorTicketReply): self - { - $this->operatorOperatorTicketReply = $operatorOperatorTicketReply; - - return $this; - } - - public function getUserTicketWaitingresponse(): int - { - return $this->userTicketWaitingresponse; - } - - public function setUserTicketWaitingresponse(int $userTicketWaitingresponse): self - { - $this->userTicketWaitingresponse = $userTicketWaitingresponse; - - return $this; - } - - public function getUserUserTicketReply(): int - { - return $this->userUserTicketReply; - } - - public function setUserUserTicketReply(int $userUserTicketReply): self - { - $this->userUserTicketReply = $userUserTicketReply; - - return $this; - } - - public function getUserTicketDisablereplies(): int - { - return $this->userTicketDisablereplies; - } - - public function setUserTicketDisablereplies(int $userTicketDisablereplies): self - { - $this->userTicketDisablereplies = $userTicketDisablereplies; - - return $this; - } - - public function getOperatorUserTicketReply(): int - { - return $this->operatorUserTicketReply; - } - - public function setOperatorUserTicketReply(int $operatorUserTicketReply): self - { - $this->operatorUserTicketReply = $operatorUserTicketReply; - - return $this; - } + /** @var array */ + protected $casts = [ + 'operator_department_changed' => 'int', + 'operator_internal_opened' => 'int', + 'user_ticket_locked' => 'int', + 'user_ticket_reply' => 'int', + 'operator_assigned' => 'int', + 'operator_ticket_note' => 'int', + 'user_ticket_opened' => 'int', + 'user_ticket_operatorclose' => 'int', + 'operator_ticket_opened' => 'int', + 'user_ticket_registeredonly' => 'int', + 'user_ticket_autoclose' => 'int', + 'user_email_attachmentrejected' => 'int', + 'operator_operator_ticket_reply' => 'int', + 'user_ticket_waitingresponse' => 'int', + 'user_user_ticket_reply' => 'int', + 'user_ticket_disablereplies' => 'int', + 'operator_user_ticket_reply' => 'int', + ]; } diff --git a/src/Model/BaseModel.php b/src/Model/Model.php similarity index 61% rename from src/Model/BaseModel.php rename to src/Model/Model.php index 47ef9728..a15c6a1c 100644 --- a/src/Model/BaseModel.php +++ b/src/Model/Model.php @@ -2,9 +2,7 @@ namespace SupportPal\ApiClient\Model; -use Illuminate\Database\Eloquent\Model; - -abstract class BaseModel extends Model +abstract class Model extends \Jenssegers\Model\Model { /** @var string[] */ protected $guarded = []; diff --git a/src/Model/SelfService/Article.php b/src/Model/SelfService/Article.php index 14f0ab67..1600b092 100644 --- a/src/Model/SelfService/Article.php +++ b/src/Model/SelfService/Article.php @@ -2,401 +2,33 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Article extends BaseModel +class Article extends Model { - public const REQUIRED_FIELDS = [ - 'pinned', - 'text', - 'protected', - 'title', - 'created_at', - 'plain_text', - 'published', - 'purified_text', - 'updated_at', - 'slug', + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'author_id' => 'int', + 'title' => 'string', + 'slug' => 'string', + 'excerpt' => 'string', + 'plain_text' => 'string', + 'text' => 'string', + 'purified_text' => 'string', + 'published' => 'int', + 'published_at' => 'int', + 'protected' => 'int', + 'pinned' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'views' => 'int', + 'positive_rating' => 'int', + 'total_rating' => 'int', + 'translations' => 'array:' . ArticleTranslation::class, + 'categories' => 'array:' . Category::class, + 'types' => 'array:' . Type::class, + 'attachments' => 'array:' . ArticleAttachment::class, + 'tags' => 'array:' . Tag::class, ]; - - #[SerializedName('purified_text')] - private string $purifiedText; - - #[SerializedName('pinned')] - private bool $pinned; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('text')] - private string $text; - - #[SerializedName('protected')] - private bool $protected; - - #[SerializedName('title')] - private string $title; - - #[SerializedName('author_id')] - private int|null $authorId; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('excerpt')] - private string|null $excerpt; - - #[SerializedName('plain_text')] - private string $plainText; - - #[SerializedName('published_at')] - private int|null $publishedAt; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('keywords')] - private string|null $keywords; - - #[SerializedName('slug')] - private string $slug; - - #[SerializedName('published')] - private bool $published; - - /** @var Category[]|null */ - #[SerializedName('categories')] - private array|null $categories; - - /** @var Type[]|null */ - #[SerializedName('types')] - private array|null $types; - - /** @var ArticleAttachment[]|null */ - #[SerializedName('attachments')] - private array|null $attachments; - - #[SerializedName('views')] - private int|null $views = null; - - /** @var Tag[]|null */ - #[SerializedName('tags')] - private array|null $tags; - - /** @var ArticleTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - #[SerializedName('positive_rating')] - private int|null $positiveRating = null; - - #[SerializedName('total_rating')] - private int|null $totalRating = null; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getAuthorId(): ?int - { - return $this->authorId; - } - - public function setAuthorId(?int $authorId): self - { - $this->authorId = $authorId; - - return $this; - } - - public function getPinned(): bool - { - return $this->pinned; - } - - public function setPinned(bool $pinned): self - { - $this->pinned = $pinned; - - return $this; - } - - public function getText(): string - { - return $this->text; - } - - public function setText(string $text): self - { - $this->text = $text; - - return $this; - } - - public function getProtected(): bool - { - return $this->protected; - } - - public function setProtected(bool $protected): self - { - $this->protected = $protected; - - return $this; - } - - public function getPublishedAt(): ?int - { - return $this->publishedAt; - } - - public function setPublishedAt(?int $publishedAt): self - { - $this->publishedAt = $publishedAt; - - return $this; - } - - public function getTitle(): string - { - return $this->title; - } - - public function setTitle(string $title): self - { - $this->title = $title; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getPlainText(): string - { - return $this->plainText; - } - - public function setPlainText(string $plainText): self - { - $this->plainText = $plainText; - - return $this; - } - - public function getKeywords(): ?string - { - return $this->keywords; - } - - public function setKeywords(?string $keywords): self - { - $this->keywords = $keywords; - - return $this; - } - - public function getPublished(): bool - { - return $this->published; - } - - public function setPublished(bool $published): self - { - $this->published = $published; - - return $this; - } - - public function getExcerpt(): ?string - { - return $this->excerpt; - } - - public function setExcerpt(?string $excerpt): self - { - $this->excerpt = $excerpt; - - return $this; - } - - public function getPurifiedText(): string - { - return $this->purifiedText; - } - - public function setPurifiedText(string $purifiedText): self - { - $this->purifiedText = $purifiedText; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getSlug(): string - { - return $this->slug; - } - - public function setSlug(string $slug): self - { - $this->slug = $slug; - - return $this; - } - - /** - * @return Category[]|null - */ - public function getCategories(): ?array - { - return $this->categories; - } - - /** - * @param Category[]|null $categories - */ - public function setCategories(?array $categories): self - { - $this->categories = $categories; - - return $this; - } - - /** - * @return Type[]|null - */ - public function getTypes(): ?array - { - return $this->types; - } - - /** - * @param Type[]|null $types - */ - public function setTypes(?array $types): Article - { - $this->types = $types; - - return $this; - } - - /** - * @return ArticleAttachment[]|null - */ - public function getAttachments(): ?array - { - return $this->attachments; - } - - /** - * @param ArticleAttachment[]|null $attachments - */ - public function setAttachments(?array $attachments): self - { - $this->attachments = $attachments; - - return $this; - } - - public function getViews(): ?int - { - return $this->views; - } - - public function setViews(?int $views): self - { - $this->views = $views; - - return $this; - } - - /** - * @return Tag[]|null -1 */ - public function getTags(): ?array - { - return $this->tags; - } - - /** - * @param Tag[]|null $tags - */ - public function setTags(?array $tags): self - { - $this->tags = $tags; - - return $this; - } - - /** - * @return ArticleTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param ArticleTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } - - public function getPositiveRating(): ?int - { - return $this->positiveRating; - } - - public function setPositiveRating(?int $positiveRating): self - { - $this->positiveRating = $positiveRating; - - return $this; - } - - public function getTotalRating(): ?int - { - return $this->totalRating; - } - - public function setTotalRating(?int $totalRating): self - { - $this->totalRating = $totalRating; - - return $this; - } } diff --git a/src/Model/SelfService/ArticleAttachment.php b/src/Model/SelfService/ArticleAttachment.php index cd1a7dcc..85642d17 100644 --- a/src/Model/SelfService/ArticleAttachment.php +++ b/src/Model/SelfService/ArticleAttachment.php @@ -2,129 +2,19 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseModel; use SupportPal\ApiClient\Model\Core\Upload; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class ArticleAttachment extends BaseModel +class ArticleAttachment extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('upload_hash')] - private string $uploadHash; - - #[SerializedName('article_id')] - private int $articleId; - - #[SerializedName('locale')] - private ?string $locale; - - #[SerializedName('original_name')] - private string $originalName; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('upload')] - private Upload $upload; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getUploadHash(): string - { - return $this->uploadHash; - } - - public function setUploadHash(string $uploadHash): self - { - $this->uploadHash = $uploadHash; - - return $this; - } - - public function getArticleId(): int - { - return $this->articleId; - } - - public function setArticleId(int $articleId): self - { - $this->articleId = $articleId; - - return $this; - } - - public function getLocale(): ?string - { - return $this->locale; - } - - public function setLocale(?string $locale): self - { - $this->locale = $locale; - - return $this; - } - - public function getOriginalName(): string - { - return $this->originalName; - } - - public function setOriginalName(string $originalName): self - { - $this->originalName = $originalName; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getUpload(): Upload - { - return $this->upload; - } - - public function setUpload(Upload $upload): self - { - $this->upload = $upload; - - return $this; - } + /** @var array */ + protected $casts = [ + 'upload_hash' => 'string', + 'article_id' => 'int', + 'locale' => 'string', + 'original_name' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'upload' => Upload::class + ]; } diff --git a/src/Model/SelfService/ArticleTranslation.php b/src/Model/SelfService/ArticleTranslation.php index db3f330a..5d233de1 100644 --- a/src/Model/SelfService/ArticleTranslation.php +++ b/src/Model/SelfService/ArticleTranslation.php @@ -2,146 +2,18 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class ArticleTranslation extends BaseTranslation +class ArticleTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('text')] - private string $text; - - #[SerializedName('title')] - private string $title; - - #[SerializedName('plain_text')] - private string $plainText; - - #[SerializedName('keywords')] - private string|null $keywords; - - #[SerializedName('excerpt')] - private string|null $excerpt; - - #[SerializedName('article_id')] - private int $articleId; - - #[SerializedName('purified_text')] - private string $purifiedText; - - #[SerializedName('slug')] - private string $slug; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getText(): string - { - return $this->text; - } - - public function setText(string $text): self - { - $this->text = $text; - - return $this; - } - - public function getTitle(): string - { - return $this->title; - } - - public function setTitle(string $title): self - { - $this->title = $title; - - return $this; - } - - public function getPlainText(): string - { - return $this->plainText; - } - - public function setPlainText(string $plainText): self - { - $this->plainText = $plainText; - - return $this; - } - - public function getKeywords(): ?string - { - return $this->keywords; - } - - public function setKeywords(?string $keywords): self - { - $this->keywords = $keywords; - - return $this; - } - - public function getExcerpt(): ?string - { - return $this->excerpt; - } - - public function setExcerpt(?string $excerpt): self - { - $this->excerpt = $excerpt; - - return $this; - } - - public function getArticleId(): int - { - return $this->articleId; - } - - public function setArticleId(int $articleId): self - { - $this->articleId = $articleId; - - return $this; - } - - public function getPurifiedText(): string - { - return $this->purifiedText; - } - - public function setPurifiedText(string $purifiedText): self - { - $this->purifiedText = $purifiedText; - - return $this; - } - - public function getSlug(): string - { - return $this->slug; - } - - public function setSlug(string $slug): self - { - $this->slug = $slug; - - return $this; - } + /** @var array */ + protected $casts = [ + 'article_id' => 'int', + 'title' => 'string', + 'slug' => 'string', + 'excerpt' => 'string', + 'plain_text' => 'string', + 'text' => 'string', + 'purified_text' => 'string', + ]; } diff --git a/src/Model/SelfService/Category.php b/src/Model/SelfService/Category.php index 314b9105..27e8a522 100644 --- a/src/Model/SelfService/Category.php +++ b/src/Model/SelfService/Category.php @@ -2,210 +2,24 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Category extends BaseModel +class Category extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('type_id')] - private int $typeId; - - #[SerializedName('parent_id')] - private int|null $parentId; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('slug')] - private string $slug; - - #[SerializedName('public')] - private bool $public; - - #[SerializedName('parent_public')] - private bool $parentPublic; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('frontend_url')] - private string $frontendUrl; - - #[SerializedName('type')] - private Type $type; - - /** @var CategoryTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - #[SerializedName('pinned')] - private int|null $pinned = null; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getTypeId(): int - { - return $this->typeId; - } - - public function setTypeId(int $typeId): self - { - $this->typeId = $typeId; - - return $this; - } - - public function getParentId(): ?int - { - return $this->parentId; - } - - public function setParentId(?int $parentId): self - { - $this->parentId = $parentId; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getSlug(): string - { - return $this->slug; - } - - public function setSlug(string $slug): self - { - $this->slug = $slug; - - return $this; - } - - public function getPublic(): bool - { - return $this->public; - } - - public function setPublic(bool $public): self - { - $this->public = $public; - - return $this; - } - - public function getParentPublic(): bool - { - return $this->parentPublic; - } - - public function setParentPublic(bool $parentPublic): self - { - $this->parentPublic = $parentPublic; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getFrontendUrl(): string - { - return $this->frontendUrl; - } - - public function setFrontendUrl(string $frontendUrl): self - { - $this->frontendUrl = $frontendUrl; - - return $this; - } - - public function getType(): Type - { - return $this->type; - } - - public function setType(Type $type): self - { - $this->type = $type; - - return $this; - } - - /** - * @return CategoryTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param CategoryTranslation[]|null $translations - */ - public function setTranslations(?array $translations): Category - { - $this->translations = $translations; - - return $this; - } - - public function getPinned(): ?int - { - return $this->pinned; - } - - public function setPinned(?int $pinned): self - { - $this->pinned = $pinned; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'type_id' => 'int', + 'parent_id' => 'int', + 'name' => 'string', + 'slug' => 'string', + 'public' => 'int', + 'parent_public' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'frontend_url' => 'string', + 'type' => Type::class, + 'translations' => 'array:' . CategoryTranslation::class, + 'pinned' => 'int' + ]; } diff --git a/src/Model/SelfService/CategoryTranslation.php b/src/Model/SelfService/CategoryTranslation.php index 0a8de0a8..efed7a0d 100644 --- a/src/Model/SelfService/CategoryTranslation.php +++ b/src/Model/SelfService/CategoryTranslation.php @@ -2,108 +2,14 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class CategoryTranslation extends BaseTranslation +class CategoryTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('category_id')] - private int $categoryId; - - #[SerializedName('slug')] - private string $slug; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - /** - * @deprecated - */ - public function getTypeId(): int - { - return $this->categoryId; - } - - /** - * @param int $categoryId - *@deprecated - */ - public function setTypeId(int $categoryId): self - { - $this->categoryId = $categoryId; - - return $this; - } - - public function getSlug(): string - { - return $this->slug; - } - - public function setSlug(string $slug): self - { - $this->slug = $slug; - - return $this; - } - - /** - * Invalid property in the model, this getter will be removed in the next major release - * @deprecated - */ - public function getDescription(): ?string - { - return null; - } - - /** - * Invalid property in the model, this setter will be removed in the next major release - * @deprecated - */ - public function setDescription(): self - { - return $this; - } - - public function getCategoryId(): int - { - return $this->categoryId; - } - - public function setCategoryId(int $categoryId): self - { - $this->categoryId = $categoryId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'category_id' => 'int', + 'name' => 'string', + 'slug' => 'string', + ]; } diff --git a/src/Model/SelfService/Comment.php b/src/Model/SelfService/Comment.php index 40c6d353..58309b1f 100644 --- a/src/Model/SelfService/Comment.php +++ b/src/Model/SelfService/Comment.php @@ -2,270 +2,27 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseModel; +use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\User\User; -use Symfony\Component\Serializer\Attribute\SerializedName; -class Comment extends BaseModel +class Comment extends Model { - public const REQUIRED_FIELDS = [ - 'article_id', - 'type_id', - 'text', + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'article_id' => 'int', + 'type_id' => 'int', + 'author_id' => 'int', + 'text' => 'string', + 'purified_text' => 'string', + 'parent_id' => 'int', + 'root_parent_id' => 'int', + 'rating' => 'int', + 'status' => 'int', + 'notify_reply' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'deleted_at' => 'int', + 'author' => User::class, ]; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('text')] - private string $text; - - #[SerializedName('article_id')] - private int $articleId; - - #[SerializedName('type_id')] - private int $typeId; - - #[SerializedName('parent_id')] - private int|null $parentId; - - #[SerializedName('status')] - private int $status = 0; - - #[SerializedName('notify_reply')] - private bool $notifyReply = false; - - #[SerializedName('author_id')] - private int|null $authorId; - - #[SerializedName('purified_text')] - private string|null $purifiedText; - - #[SerializedName('name')] - private string|null $name; - - #[SerializedName('author')] - private User|null $author; - - #[SerializedName('article')] - private Article|null $article; - - #[SerializedName('type')] - private Type|null $type; - - #[SerializedName('created_at')] - private int|null $createdAt; - - #[SerializedName('updated_at')] - private int|null $updatedAt; - - #[SerializedName('root_parent_id')] - private int|null $rootParentId; - - #[SerializedName('rating')] - private int|null $rating; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getText(): string - { - return $this->text; - } - - public function setText(string $text): self - { - $this->text = $text; - - return $this; - } - - public function getArticleId(): int - { - return $this->articleId; - } - - public function setArticleId(int $articleId): self - { - $this->articleId = $articleId; - - return $this; - } - - public function getTypeId(): int - { - return $this->typeId; - } - - public function setTypeId(int $typeId): self - { - $this->typeId = $typeId; - - return $this; - } - - public function getParentId(): ?int - { - return $this->parentId; - } - - public function setParentId(?int $parentId): self - { - $this->parentId = $parentId; - - return $this; - } - - public function getStatus(): int - { - return $this->status; - } - - public function setStatus(int $status): self - { - $this->status = $status; - - return $this; - } - - public function getNotifyReply(): bool - { - return $this->notifyReply; - } - - public function setNotifyReply(bool $notifyReply): self - { - $this->notifyReply = $notifyReply; - - return $this; - } - - public function getAuthorId(): ?int - { - return $this->authorId; - } - - public function setAuthorId(?int $authorId): self - { - $this->authorId = $authorId; - - return $this; - } - - public function getPurifiedText(): ?string - { - return $this->purifiedText; - } - - public function setPurifiedText(?string $purifiedText): self - { - $this->purifiedText = $purifiedText; - - return $this; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(?string $name): self - { - $this->name = $name; - - return $this; - } - - public function getAuthor(): ?User - { - return $this->author; - } - - public function setAuthor(User $author): self - { - $this->author = $author; - - return $this; - } - - public function getArticle(): ?Article - { - return $this->article; - } - - public function setArticle(Article $article): self - { - $this->article = $article; - - return $this; - } - - public function getType(): ?Type - { - return $this->type; - } - - public function setType(Type $type): self - { - $this->type = $type; - - return $this; - } - - public function getCreatedAt(): ?int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getUpdatedAt(): ?int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getRootParentId(): ?int - { - return $this->rootParentId; - } - - public function setRootParentId(?int $rootParentId): self - { - $this->rootParentId = $rootParentId; - - return $this; - } - - public function getRating(): ?int - { - return $this->rating; - } - - public function setRating(?int $rating): self - { - $this->rating = $rating; - - return $this; - } } diff --git a/src/Model/SelfService/Request/CreateComment.php b/src/Model/SelfService/Request/CreateComment.php index c469e273..0a10f200 100644 --- a/src/Model/SelfService/Request/CreateComment.php +++ b/src/Model/SelfService/Request/CreateComment.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Model\SelfService\Request; -use SupportPal\ApiClient\Model\BaseModel; +use SupportPal\ApiClient\Model\Model; use Symfony\Component\Serializer\Attribute\SerializedName; -class CreateComment extends BaseModel +class CreateComment extends Model { public const REQUIRED_FIELDS = [ 'article_id', @@ -14,122 +14,66 @@ class CreateComment extends BaseModel ]; #[SerializedName('article_id')] - private int $articleId; + protected int $articleId; #[SerializedName('type_id')] - private int $typeId; + protected int $typeId; #[SerializedName('parent_id')] - private ?int $parentId; + protected ?int $parentId; #[SerializedName('author_id')] - private ?int $authorId; + protected ?int $authorId; #[SerializedName('name')] - private ?string $name; + protected ?string $name; #[SerializedName('text')] - private string $text; + protected string $text; #[SerializedName('status')] - private ?int $status; + protected ?int $status; #[SerializedName('notify_reply')] - private ?bool $notifyReply; + protected ?bool $notifyReply; public function getArticleId(): int { return $this->articleId; } - public function setArticleId(int $articleId): self - { - $this->articleId = $articleId; - - return $this; - } - public function getTypeId(): int { return $this->typeId; } - public function setTypeId(int $typeId): self - { - $this->typeId = $typeId; - - return $this; - } - public function getParentId(): ?int { return $this->parentId; } - public function setParentId(?int $parentId): self - { - $this->parentId = $parentId; - - return $this; - } - public function getAuthorId(): ?int { return $this->authorId; } - public function setAuthorId(?int $authorId): self - { - $this->authorId = $authorId; - - return $this; - } - public function getName(): ?string { return $this->name; } - public function setName(?string $name): self - { - $this->name = $name; - - return $this; - } - public function getText(): string { return $this->text; } - public function setText(string $text): self - { - $this->text = $text; - - return $this; - } - public function getStatus(): ?int { return $this->status; } - public function setStatus(?int $status): self - { - $this->status = $status; - - return $this; - } - public function getNotifyReply(): ?bool { return $this->notifyReply; } - - public function setNotifyReply(?bool $notifyReply): self - { - $this->notifyReply = $notifyReply; - - return $this; - } } diff --git a/src/Model/SelfService/Tag.php b/src/Model/SelfService/Tag.php index 2163ccd5..1ca9c857 100644 --- a/src/Model/SelfService/Tag.php +++ b/src/Model/SelfService/Tag.php @@ -2,105 +2,17 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Tag extends BaseModel +class Tag extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('slug')] - private string $slug; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('updated_at')] - private int $updatedAt; - - /** @var TagTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getSlug(): string - { - return $this->slug; - } - - public function setSlug(string $slug): self - { - $this->slug = $slug; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - /** - * @return TagTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param TagTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'slug' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'translations' => 'array:' . TagTranslation::class, + ]; } diff --git a/src/Model/SelfService/TagTranslation.php b/src/Model/SelfService/TagTranslation.php index 280dc436..d89767ec 100644 --- a/src/Model/SelfService/TagTranslation.php +++ b/src/Model/SelfService/TagTranslation.php @@ -2,68 +2,15 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class TagTranslation extends BaseTranslation +class TagTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('slug')] - private string $slug; - - #[SerializedName('tag_id')] - private int $tagId; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getSlug(): string - { - return $this->slug; - } - - public function setSlug(string $slug): self - { - $this->slug = $slug; - - return $this; - } - - public function getTagId(): int - { - return $this->tagId; - } - - public function setTagId(int $tagId): self - { - $this->tagId = $tagId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'tag_id' => 'int', + 'name' => 'string', + 'slug' => 'string', + ]; } diff --git a/src/Model/SelfService/Type.php b/src/Model/SelfService/Type.php index cb490be0..76f3ad9a 100644 --- a/src/Model/SelfService/Type.php +++ b/src/Model/SelfService/Type.php @@ -2,313 +2,31 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseModel; use SupportPal\ApiClient\Model\Core\Brand; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Type extends BaseModel +class Type extends Model { - public const REQUIRED_FIELDS = [ - 'brand_id', - 'description', - 'content', - 'enabled', - 'name', - 'created_at', - 'protected', - 'updated_at', - 'internal', + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'brand_id' => 'int', + 'name' => 'string', + 'slug' => 'string', + 'description' => 'string', + 'order' => 'int', + 'enabled' => 'int', + 'protected' => 'int', + 'internal' => 'int', + 'content' => 'int', + 'view' => 'int', + 'icon' => 'string', + 'article_ordering' => 'int', + 'show_on_dashboard' => 'int', + 'external_link' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'translations' => 'array:' . TypeTranslation::class, + 'brand' => Brand::class, ]; - - #[SerializedName('icon')] - private string|null $icon; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('description')] - private string $description; - - #[SerializedName('brand_id')] - private int $brandId; - - #[SerializedName('article_ordering')] - private int|null $articleOrdering; - - #[SerializedName('slug')] - private string|null $slug; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('internal')] - private bool $internal; - - #[SerializedName('show_on_dashboard')] - private int|null $showOnDashboard; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('view')] - private int|null $view; - - #[SerializedName('protected')] - private bool $protected; - - #[SerializedName('order')] - private int|null $order; - - #[SerializedName('external_link')] - private string|null $externalLink; - - #[SerializedName('enabled')] - private bool $enabled; - - #[SerializedName('content')] - private int $content; - - #[SerializedName('brand')] - private Brand|null $brand; - - /** @var TypeTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - public function getIcon(): ?string - { - return $this->icon; - } - - public function setIcon(?string $icon): self - { - $this->icon = $icon; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getDescription(): string - { - return $this->description; - } - - public function setDescription(string $description): self - { - $this->description = $description; - - return $this; - } - - public function getBrandId(): int - { - return $this->brandId; - } - - public function setBrandId(int $brandId): self - { - $this->brandId = $brandId; - - return $this; - } - - public function getArticleOrdering(): ?int - { - return $this->articleOrdering; - } - - public function setArticleOrdering(?int $articleOrdering): self - { - $this->articleOrdering = $articleOrdering; - - return $this; - } - - public function getSlug(): ?string - { - return $this->slug; - } - - public function setSlug(?string $slug): self - { - $this->slug = $slug; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getInternal(): bool - { - return $this->internal; - } - - public function setInternal(bool $internal): self - { - $this->internal = $internal; - - return $this; - } - - public function getShowOnDashboard(): ?int - { - return $this->showOnDashboard; - } - - public function setShowOnDashboard(?int $showOnDashboard): self - { - $this->showOnDashboard = $showOnDashboard; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getView(): ?int - { - return $this->view; - } - - public function setView(?int $view): self - { - $this->view = $view; - - return $this; - } - - public function getProtected(): bool - { - return $this->protected; - } - - public function setProtected(bool $protected): self - { - $this->protected = $protected; - - return $this; - } - - public function getOrder(): ?int - { - return $this->order; - } - - public function setOrder(?int $order): self - { - $this->order = $order; - - return $this; - } - - public function getExternalLink(): ?string - { - return $this->externalLink; - } - - public function setExternalLink(?string $externalLink): self - { - $this->externalLink = $externalLink; - - return $this; - } - - public function getEnabled(): bool - { - return $this->enabled; - } - - public function setEnabled(bool $enabled): self - { - $this->enabled = $enabled; - - return $this; - } - - public function getContent(): int - { - return $this->content; - } - - public function setContent(int $content): self - { - $this->content = $content; - - return $this; - } - - public function getBrand(): ?Brand - { - return $this->brand; - } - - public function setBrand(Brand $brand): self - { - $this->brand = $brand; - - return $this; - } - - /** - * @return TypeTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param TypeTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } } diff --git a/src/Model/SelfService/TypeTranslation.php b/src/Model/SelfService/TypeTranslation.php index 7398c20e..a844121b 100644 --- a/src/Model/SelfService/TypeTranslation.php +++ b/src/Model/SelfService/TypeTranslation.php @@ -2,83 +2,16 @@ namespace SupportPal\ApiClient\Model\SelfService; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class TypeTranslation extends BaseTranslation +class TypeTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('type_id')] - private int $typeId; - - #[SerializedName('description')] - private string $description; - - #[SerializedName('slug')] - private string|null $slug; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getTypeId(): int - { - return $this->typeId; - } - - public function setTypeId(int $typeId): self - { - $this->typeId = $typeId; - - return $this; - } - - public function getDescription(): string - { - return $this->description; - } - - public function setDescription(string $description): self - { - $this->description = $description; - - return $this; - } - - public function getSlug(): ?string - { - return $this->slug; - } - - public function setSlug(?string $slug): self - { - $this->slug = $slug; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'type_id' => 'int', + 'name' => 'string', + 'description' => 'string', + 'slug' => 'string', + ]; } diff --git a/src/Model/SettingsModel.php b/src/Model/SettingsModel.php deleted file mode 100644 index cc814d00..00000000 --- a/src/Model/SettingsModel.php +++ /dev/null @@ -1,15 +0,0 @@ -regexErrorMessage; - } - - public function setRegexErrorMessage(?string $regexErrorMessage): self - { - $this->regexErrorMessage = $regexErrorMessage; - - return $this; - } - - public function getDependsOnFieldId(): ?int - { - return $this->dependsOnFieldId; - } - - public function setDependsOnFieldId(?int $dependsOnFieldId): self - { - $this->dependsOnFieldId = $dependsOnFieldId; - - return $this; - } - - public function getRegex(): ?string - { - return $this->regex; - } - - public function setRegex(?string $regex): self - { - $this->regex = $regex; - - return $this; - } - - public function getLocked(): ?bool - { - return $this->locked; - } - - public function setLocked(bool $locked): self - { - $this->locked = $locked; - - return $this; - } - - public function getUpdatedAt(): ?int - { - return $this->updatedAt; - } - - public function setUpdatedAt(?int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getCreatedAt(): ?int - { - return $this->createdAt; - } - - public function setCreatedAt(?int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getDependsOnOptionId(): ?int - { - return $this->dependsOnOptionId; - } - - public function setDependsOnOptionId(?int $dependsOnOptionId): self - { - $this->dependsOnOptionId = $dependsOnOptionId; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(?string $name): self - { - $this->name = $name; - - return $this; - } - - public function getRequired(): ?bool - { - return $this->required; - } - - public function setRequired(?bool $required): self - { - $this->required = $required; - - return $this; - } - - public function getPublic(): ?bool - { - return $this->public; - } - - public function setPublic(?bool $public): self - { - $this->public = $public; - - return $this; - } - - public function getOrder(): ?int - { - return $this->order; - } - - public function setOrder(?int $order): self - { - $this->order = $order; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } - - public function getType(): ?int - { - return $this->type; - } - - public function setType(?int $type): self - { - $this->type = $type; - - return $this; - } - - public function getEncrypted(): ?int - { - return $this->encrypted; - } - - public function setEncrypted(?int $encrypted): self - { - $this->encrypted = $encrypted; - - return $this; - } - - /** - * @return Option[]|null - */ - public function getOptions(): ?array - { - return $this->options; - } - - /** - * @param Option[]|null $options - */ - public function setOptions(?array $options): self - { - $this->options = $options; - - return $this; - } - - /** - * @return Brand[]|null - */ - public function getBrands(): ?array - { - return $this->brands; - } - - /** - * @param Brand[]|null $brands - */ - public function setBrands(?array $brands): self - { - $this->brands = $brands; - - return $this; - } - - public function getFieldId(): ?int - { - return $this->fieldId; - } - - public function setFieldId(?int $fieldId): self - { - $this->fieldId = $fieldId; - - return $this; - } - - public function getValue(): ?string - { - return $this->value; - } - - public function setValue(?string $value): self - { - $this->value = $value; - - return $this; - } + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'description' => 'string', + 'type' => 'int', + 'depends_on_field_id' => 'int', + 'depends_on_option_id' => 'int', + 'order' => 'int', + 'required' => 'int', + 'public' => 'int', + 'encrypted' => 'int', + 'locked' => 'int', + 'regex' => 'string', + 'regex_error_message' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'options' => 'array:' . Option::class, + 'brands' => 'array:' . Brand::class, + ]; } diff --git a/src/Model/Shared/Option.php b/src/Model/Shared/Option.php index 071b1187..54fa9783 100644 --- a/src/Model/Shared/Option.php +++ b/src/Model/Shared/Option.php @@ -2,120 +2,18 @@ namespace SupportPal\ApiClient\Model\Shared; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Option extends BaseModel +class Option extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('order')] - private int|null $order; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('field_id')] - private int $fieldId; - - #[SerializedName('value')] - private string $value; - - /** @var OptionTranslation[]|null */ - #[SerializedName('translations')] - private ?array $translations; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getOrder(): ?int - { - return $this->order; - } - - public function setOrder(?int $order): self - { - $this->order = $order; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getFieldId(): int - { - return $this->fieldId; - } - - public function setFieldId(int $fieldId): self - { - $this->fieldId = $fieldId; - - return $this; - } - - public function getValue(): string - { - return $this->value; - } - - public function setValue(string $value): self - { - $this->value = $value; - - return $this; - } - - /** - * @return OptionTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param OptionTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'field_id' => 'int', + 'order' => 'int', + 'value' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'translations' => 'array:' . OptionTranslation::class, + ]; } diff --git a/src/Model/Shared/OptionTranslation.php b/src/Model/Shared/OptionTranslation.php index bbae1d81..a49ac24a 100644 --- a/src/Model/Shared/OptionTranslation.php +++ b/src/Model/Shared/OptionTranslation.php @@ -2,60 +2,13 @@ namespace SupportPal\ApiClient\Model\Shared; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class OptionTranslation extends BaseTranslation +class OptionTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - /** @deprecated This value is not set in all options and will be removed in later versions. */ - #[SerializedName('ticket_custom_field_option_id')] - private ?int $ticketCustomFieldOptionId; - - #[SerializedName('value')] - private string $value; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - /** - * @deprecated - */ - public function getTicketCustomFieldOptionId(): ?int - { - return $this->ticketCustomFieldOptionId; - } - - /** - * @deprecated - */ - public function setTicketCustomFieldOptionId(?int $ticketCustomFieldOptionId): self - { - $this->ticketCustomFieldOptionId = $ticketCustomFieldOptionId; - - return $this; - } - - public function getValue(): string - { - return $this->value; - } - - public function setValue(string $value): self - { - $this->value = $value; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'value' => 'string', + ]; } diff --git a/src/Model/Shared/Settings.php b/src/Model/Shared/Settings.php index 9bb9d44a..d8dac475 100644 --- a/src/Model/Shared/Settings.php +++ b/src/Model/Shared/Settings.php @@ -3,44 +3,7 @@ namespace SupportPal\ApiClient\Model\Shared; use SupportPal\ApiClient\Model\Model; -use SupportPal\ApiClient\Model\SettingsModel; -class Settings implements SettingsModel +class Settings extends Model { - /** @var string[] */ - private array $settings; - - /** - * @inheritDoc - */ - public function __set(mixed $property, mixed $value): void - { - $this->settings[$property] = $value; - } - - /** - * @inheritDoc - */ - public function get(string $name, mixed $default = null): ?string - { - return $this->settings[$name] ?? $default; - } - - /** - * @inheritDoc - */ - public function all(): array - { - return $this->settings; - } - - /** - * @inheritDoc - */ - public function fill(array $data): Model - { - $this->settings = $data; - - return $this; - } } diff --git a/src/Model/Ticket/Attachment.php b/src/Model/Ticket/Attachment.php index 110316e7..0e7705b6 100644 --- a/src/Model/Ticket/Attachment.php +++ b/src/Model/Ticket/Attachment.php @@ -2,204 +2,25 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; use SupportPal\ApiClient\Model\Core\Upload; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Attachment extends BaseModel +class Attachment extends Model { - #[SerializedName('original_name')] - private string $originalName; - - #[SerializedName('upload_hash')] - private string $uploadHash; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('ticket_id')] - private int $ticketId; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('message_id')] - private int $messageId; - - #[SerializedName('operator_url')] - private string $operatorUrl; - - #[SerializedName('frontend_url')] - private string $frontendUrl; - - #[SerializedName('direct_operator_url')] - private string $directOperatorUrl; - - #[SerializedName('direct_frontend_url')] - private string $directFrontendUrl; - - #[SerializedName('upload')] - private Upload $upload; - - #[SerializedName('ticket')] - private Ticket $ticket; - - public function getOriginalName(): string - { - return $this->originalName; - } - - public function setOriginalName(string $originalName): self - { - $this->originalName = $originalName; - - return $this; - } - - public function getUploadHash(): string - { - return $this->uploadHash; - } - - public function setUploadHash(string $uploadHash): self - { - $this->uploadHash = $uploadHash; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getTicketId(): int - { - return $this->ticketId; - } - - public function setTicketId(int $ticketId): self - { - $this->ticketId = $ticketId; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getMessageId(): int - { - return $this->messageId; - } - - public function setMessageId(int $messageId): self - { - $this->messageId = $messageId; - - return $this; - } - - public function getOperatorUrl(): string - { - return $this->operatorUrl; - } - - public function setOperatorUrl(string $operatorUrl): self - { - $this->operatorUrl = $operatorUrl; - - return $this; - } - - public function getFrontendUrl(): string - { - return $this->frontendUrl; - } - - public function setFrontendUrl(string $frontendUrl): self - { - $this->frontendUrl = $frontendUrl; - - return $this; - } - - public function getDirectOperatorUrl(): string - { - return $this->directOperatorUrl; - } - - public function setDirectOperatorUrl(string $directOperatorUrl): self - { - $this->directOperatorUrl = $directOperatorUrl; - - return $this; - } - - public function getDirectFrontendUrl(): string - { - return $this->directFrontendUrl; - } - - public function setDirectFrontendUrl(string $directFrontendUrl): self - { - $this->directFrontendUrl = $directFrontendUrl; - - return $this; - } - - public function getUpload(): Upload - { - return $this->upload; - } - - public function setUpload(Upload $upload): self - { - $this->upload = $upload; - - return $this; - } - - public function getTicket(): Ticket - { - return $this->ticket; - } - - public function setTicket(Ticket $ticket): self - { - $this->ticket = $ticket; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'upload_hash' => 'string', + 'ticket_id' => 'int', + 'message_id' => 'int', + 'original_name' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'operator_url' => 'string', + 'frontend_url' => 'string', + 'direct_operator_url' => 'string', + 'direct_frontend_url' => 'string', + 'upload' => Upload::class, + 'ticket' => Ticket::class, + ]; } diff --git a/src/Model/Ticket/Channel.php b/src/Model/Ticket/Channel.php index 05988258..2d1b81ed 100644 --- a/src/Model/Ticket/Channel.php +++ b/src/Model/Ticket/Channel.php @@ -2,143 +2,20 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Channel extends BaseModel +class Channel extends Model { - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('version')] - private string|null $version; - - #[SerializedName('enabled')] - private bool $enabled; - - #[SerializedName('upgrade_available')] - private bool $upgradeAvailable; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('formatted_name')] - private string $formattedName; - - #[SerializedName('show_on_frontend')] - private bool|null $showOnFrontend; - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getVersion(): ?string - { - return $this->version; - } - - public function setVersion(?string $version): self - { - $this->version = $version; - - return $this; - } - - public function getEnabled(): bool - { - return $this->enabled; - } - - public function setEnabled(bool $enabled): self - { - $this->enabled = $enabled; - - return $this; - } - - public function getUpgradeAvailable(): bool - { - return $this->upgradeAvailable; - } - - public function setUpgradeAvailable(bool $upgradeAvailable): self - { - $this->upgradeAvailable = $upgradeAvailable; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getFormattedName(): string - { - return $this->formattedName; - } - - public function setFormattedName(string $formattedName): self - { - $this->formattedName = $formattedName; - - return $this; - } - - public function getShowOnFrontend(): ?bool - { - return $this->showOnFrontend; - } - - public function setShowOnFrontend(bool $value): self - { - $this->showOnFrontend = $value; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'enabled' => 'int', + 'upgrade_available' => 'int', + 'version' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'show_on_frontend' => 'int', + 'formatted_name' => 'string', + ]; } diff --git a/src/Model/Ticket/ChannelSettings.php b/src/Model/Ticket/ChannelSettings.php index e6bb530f..42f0d103 100644 --- a/src/Model/Ticket/ChannelSettings.php +++ b/src/Model/Ticket/ChannelSettings.php @@ -2,68 +2,15 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class ChannelSettings extends BaseModel +class ChannelSettings extends Model { - #[SerializedName('unauthenticated_users')] - private string $unauthenticatedUsers; - - #[SerializedName('show_captcha')] - private string $showCaptcha; - - #[SerializedName('append_ip_address')] - private string $appendIpAddress; - - #[SerializedName('show_related_articles')] - private string $showRelatedArticles; - - public function getUnauthenticatedUsers(): string - { - return $this->unauthenticatedUsers; - } - - public function setUnauthenticatedUsers(string $unauthenticatedUsers): self - { - $this->unauthenticatedUsers = $unauthenticatedUsers; - - return $this; - } - - public function getShowCaptcha(): string - { - return $this->showCaptcha; - } - - public function setShowCaptcha(string $showCaptcha): self - { - $this->showCaptcha = $showCaptcha; - - return $this; - } - - public function getAppendIpAddress(): string - { - return $this->appendIpAddress; - } - - public function setAppendIpAddress(string $appendIpAddress): self - { - $this->appendIpAddress = $appendIpAddress; - - return $this; - } - - public function getShowRelatedArticles(): string - { - return $this->showRelatedArticles; - } - - public function setShowRelatedArticles(string $showRelatedArticles): self - { - $this->showRelatedArticles = $showRelatedArticles; - - return $this; - } + /** @var array */ + protected $casts = [ + 'unauthenticated_users' => 'string', + 'show_captcha' => 'string', + 'append_ip_address' => 'string', + 'show_related_articles' => 'string', + ]; } diff --git a/src/Model/Ticket/Extra.php b/src/Model/Ticket/Extra.php index 1cb60422..85632898 100644 --- a/src/Model/Ticket/Extra.php +++ b/src/Model/Ticket/Extra.php @@ -2,74 +2,14 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Extra extends BaseModel +class Extra extends Model { - /** @var string[]|null */ - #[SerializedName('bcc_address')] - private array|null $bccAddress; - - /** @var string[]|null */ - #[SerializedName('to_address')] - private array|null $toAddress; - - /** @var string[]|null */ - #[SerializedName('cc_address')] - private array|null $ccAddress; - - /** - * @return string[]|null - */ - public function getBccAddress(): ?array - { - return $this->bccAddress; - } - - /** - * @param string[]|null $bccAddress - */ - public function setBccAddress(?array $bccAddress): self - { - $this->bccAddress = $bccAddress; - - return $this; - } - - /** - * @return string[]|null - */ - public function getToAddress(): ?array - { - return $this->toAddress; - } - - /** - * @param string[]|null $toAddress - */ - public function setToAddress(?array $toAddress): self - { - $this->toAddress = $toAddress; - - return $this; - } - - /** - * @return string[]|null - */ - public function getCcAddress(): ?array - { - return $this->ccAddress; - } - - /** - * @param string[]|null $ccAddress - */ - public function setCcAddress(?array $ccAddress): self - { - $this->ccAddress = $ccAddress; - - return $this; - } + /** @var array */ + protected $casts = [ + 'bcc_address' => 'array', + 'to_address' => 'array', + 'cc_address' => 'array', + ]; } diff --git a/src/Model/Ticket/Message.php b/src/Model/Ticket/Message.php index f50a4636..d812f058 100644 --- a/src/Model/Ticket/Message.php +++ b/src/Model/Ticket/Message.php @@ -2,291 +2,30 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; +use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\User\User; -use Symfony\Component\Serializer\Attribute\SerializedName; -class Message extends BaseModel +class Message extends Model { - public const REQUIRED_FIELDS = [ - 'ticket_id', - 'user_id', - 'text', + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'ticket_id' => 'int', + 'channel_id' => 'int', + 'user_id' => 'int', + 'user_name' => 'string', + 'user_ip_address' => 'string', + 'by' => 'int', + 'type' => 'int', + 'excerpt' => 'string', + 'text' => 'string', + 'purified_text' => 'string', + 'is_draft' => 'int', + 'social_id' => 'string', + 'extra' => Extra::class, + 'created_at' => 'int', + 'updated_at' => 'int', + 'attachments' => 'array:' . Attachment::class, + 'user' => User::class, ]; - - #[SerializedName('user_id')] - private int|null $userId = null; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('created_at')] - private int|null $createdAt; - - #[SerializedName('purified_text')] - private string|null $purifiedText; - - #[SerializedName('social_id')] - private string|null $socialId; - - #[SerializedName('ticket_id')] - private int $ticketId; - - #[SerializedName('channel_id')] - private int|null $channelId = null; - - #[SerializedName('user_ip_address')] - private string|null $userIpAddress = null; - - #[SerializedName('by')] - private int|null $by = null; - - #[SerializedName('excerpt')] - private string|null $excerpt = null; - - #[SerializedName('type')] - private int|null $type = null; - - #[SerializedName('extra')] - private Extra|null $extra = null; - - #[SerializedName('user_name')] - private string|null $userName = null; - - #[SerializedName('updated_at')] - private int|null $updatedAt = null; - - #[SerializedName('is_draft')] - private bool|null $isDraft = null; - - #[SerializedName('text')] - private string $text; - - /** @var Attachment[]|null */ - #[SerializedName('attachments')] - private array|null $attachments = null; - - private ?User $user = null; - - public function getUserId(): ?int - { - return $this->userId; - } - - public function setUserId(?int $userId): self - { - $this->userId = $userId; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getCreatedAt(): ?int - { - return $this->createdAt; - } - - public function setCreatedAt(?int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getPurifiedText(): ?string - { - return $this->purifiedText; - } - - public function setPurifiedText(?string $purifiedText): self - { - $this->purifiedText = $purifiedText; - - return $this; - } - - public function getSocialId(): ?string - { - return $this->socialId; - } - - public function setSocialId(?string $socialId): self - { - $this->socialId = $socialId; - - return $this; - } - - public function getTicketId(): int - { - return $this->ticketId; - } - - public function setTicketId(int $ticketId): self - { - $this->ticketId = $ticketId; - - return $this; - } - - public function getChannelId(): ?int - { - return $this->channelId; - } - - public function setChannelId(?int $channelId): self - { - $this->channelId = $channelId; - - return $this; - } - - public function getUserIpAddress(): ?string - { - return $this->userIpAddress; - } - - public function setUserIpAddress(?string $userIpAddress): self - { - $this->userIpAddress = $userIpAddress; - - return $this; - } - - public function getBy(): ?int - { - return $this->by; - } - - public function setBy(?int $by): self - { - $this->by = $by; - - return $this; - } - - public function getExcerpt(): ?string - { - return $this->excerpt; - } - - public function setExcerpt(?string $excerpt): self - { - $this->excerpt = $excerpt; - - return $this; - } - - public function getType(): ?int - { - return $this->type; - } - - public function setType(?int $type): self - { - $this->type = $type; - - return $this; - } - - public function getExtra(): ?Extra - { - return $this->extra; - } - - public function setExtra(?Extra $extra): self - { - $this->extra = $extra; - - return $this; - } - - public function getUserName(): ?string - { - return $this->userName; - } - - public function setUserName(?string $userName): self - { - $this->userName = $userName; - - return $this; - } - - public function getUpdatedAt(): ?int - { - return $this->updatedAt; - } - - public function setUpdatedAt(?int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getIsDraft(): ?bool - { - return $this->isDraft; - } - - public function setIsDraft(?bool $isDraft): self - { - $this->isDraft = $isDraft; - - return $this; - } - - public function getText(): string - { - return $this->text; - } - - public function setText(string $text): self - { - $this->text = $text; - - return $this; - } - - /** - * @return Attachment[]|null - */ - public function getAttachments(): ?array - { - return $this->attachments; - } - - /** - * @param Attachment[]|null $attachments - */ - public function setAttachments(?array $attachments): self - { - $this->attachments = $attachments; - - return $this; - } - - public function getUser(): ?User - { - return $this->user; - } - - public function setUser(?User $user): self - { - $this->user = $user; - - return $this; - } } diff --git a/src/Model/Ticket/Priority.php b/src/Model/Ticket/Priority.php index 5caba216..8bbbbef5 100644 --- a/src/Model/Ticket/Priority.php +++ b/src/Model/Ticket/Priority.php @@ -2,172 +2,22 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; use SupportPal\ApiClient\Model\Department\Department; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Priority extends BaseModel +class Priority extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('colour')] - private string $colour; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('order')] - private int|null $order; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('icon')] - private string $icon; - - #[SerializedName('icon_without_tooltip')] - private string $iconWithoutTooltip; - - /** @var Department[]|null */ - private ?array $departments; - - /** @var PriorityTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getColour(): string - { - return $this->colour; - } - - public function setColour(string $colour): self - { - $this->colour = $colour; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getOrder(): ?int - { - return $this->order; - } - - public function setOrder(?int $order): self - { - $this->order = $order; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getIcon(): string - { - return $this->icon; - } - - public function setIcon(string $icon): self - { - $this->icon = $icon; - - return $this; - } - - public function getIconWithoutTooltip(): string - { - return $this->iconWithoutTooltip; - } - - public function setIconWithoutTooltip(string $iconWithoutTooltip): self - { - $this->iconWithoutTooltip = $iconWithoutTooltip; - - return $this; - } - - /** - * @return Department[]|null - */ - public function getDepartments(): ?array - { - return $this->departments; - } - - /** - * @param Department[]|null $departments - */ - public function setDepartments(?array $departments): self - { - $this->departments = $departments; - - return $this; - } - - /** - * @return PriorityTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param PriorityTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'colour' => 'string', + 'order' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'icon' => 'string', + 'icon_without_tooltip' => 'string', + 'departments' => 'array:' . Department::class, + 'translations' => 'array:' . PriorityTranslation::class, + ]; } diff --git a/src/Model/Ticket/PriorityTranslation.php b/src/Model/Ticket/PriorityTranslation.php index b34dd7d6..ed340e4d 100644 --- a/src/Model/Ticket/PriorityTranslation.php +++ b/src/Model/Ticket/PriorityTranslation.php @@ -2,56 +2,14 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class PriorityTranslation extends BaseTranslation +class PriorityTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('priority_id')] - private int $priorityId; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getPriorityId(): int - { - return $this->priorityId; - } - - public function setPriorityId(int $priorityId): self - { - $this->priorityId = $priorityId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'priority_id' => 'int', + 'name' => 'string', + ]; } diff --git a/src/Model/Ticket/Request/CreateMessage.php b/src/Model/Ticket/Request/CreateMessage.php index 84695da2..3d0f52e2 100644 --- a/src/Model/Ticket/Request/CreateMessage.php +++ b/src/Model/Ticket/Request/CreateMessage.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Model\Ticket\Request; -use SupportPal\ApiClient\Model\BaseModel; +use SupportPal\ApiClient\Model\Model; use Symfony\Component\Serializer\Attribute\SerializedName; -class CreateMessage extends BaseModel +class CreateMessage extends Model { public const REQUIRED_FIELDS = [ 'ticket_id', @@ -14,97 +14,62 @@ class CreateMessage extends BaseModel ]; #[SerializedName('ticket_id')] - private int $ticketId; + protected int $ticketId; #[SerializedName('user_id')] - private int $userId; + protected int $userId; #[SerializedName('user_ip_address')] - private string|null $userIpAddress; + protected string|null $userIpAddress; #[SerializedName('message_type')] - private int|null $messageType; + protected int|null $messageType; #[SerializedName('text')] - private string $text; + protected string $text; /** @var string[]|null */ #[SerializedName('cc')] - private array|null $cc; + protected array|null $cc; #[SerializedName('is_draft')] - private bool|null $isDraft; + protected bool|null $isDraft; #[SerializedName('send_user_email')] - private bool|null $sendUserEmail; + protected bool|null $sendUserEmail; #[SerializedName('send_operators_email')] - private bool|null $sendOperatorsEmail; + protected bool|null $sendOperatorsEmail; /** @var string[]|null */ #[SerializedName('attachment')] - private array|null $attachment; + protected array|null $attachment; public function getTicketId(): int { return $this->ticketId; } - public function setTicketId(int $ticketId): self - { - $this->ticketId = $ticketId; - - return $this; - } - public function getUserId(): int { return $this->userId; } - public function setUserId(int $userId): self - { - $this->userId = $userId; - - return $this; - } - public function getUserIpAddress(): ?string { return $this->userIpAddress; } - public function setUserIpAddress(?string $userIpAddress): self - { - $this->userIpAddress = $userIpAddress; - - return $this; - } - public function getMessageType(): ?int { return $this->messageType; } - public function setMessageType(?int $messageType): self - { - $this->messageType = $messageType; - - return $this; - } - public function getText(): string { return $this->text; } - public function setText(string $text): self - { - $this->text = $text; - - return $this; - } - /** * @return string[]|null */ @@ -113,52 +78,21 @@ public function getCc(): ?array return $this->cc; } - /** - * @param string[]|null $cc - */ - public function setCc(?array $cc): self - { - $this->cc = $cc; - - return $this; - } - public function getIsDraft(): ?bool { return $this->isDraft; } - public function setIsDraft(?bool $isDraft): self - { - $this->isDraft = $isDraft; - - return $this; - } - public function getSendUserEmail(): ?bool { return $this->sendUserEmail; } - public function setSendUserEmail(?bool $sendUserEmail): self - { - $this->sendUserEmail = $sendUserEmail; - - return $this; - } - public function getSendOperatorsEmail(): ?bool { return $this->sendOperatorsEmail; } - public function setSendOperatorsEmail(?bool $sendOperatorsEmail): self - { - $this->sendOperatorsEmail = $sendOperatorsEmail; - - return $this; - } - /** * @return string[]|null */ @@ -166,14 +100,4 @@ public function getAttachment(): ?array { return $this->attachment; } - - /** - * @param string[]|null $attachment - */ - public function setAttachment(?array $attachment): self - { - $this->attachment = $attachment; - - return $this; - } } diff --git a/src/Model/Ticket/Request/CreateTicket.php b/src/Model/Ticket/Request/CreateTicket.php index e650a1cd..7f8c699d 100644 --- a/src/Model/Ticket/Request/CreateTicket.php +++ b/src/Model/Ticket/Request/CreateTicket.php @@ -2,10 +2,10 @@ namespace SupportPal\ApiClient\Model\Ticket\Request; -use SupportPal\ApiClient\Model\BaseModel; +use SupportPal\ApiClient\Model\Model; use Symfony\Component\Serializer\Attribute\SerializedName; -class CreateTicket extends BaseModel +class CreateTicket extends Model { public const REQUIRED_FIELDS = [ 'department', @@ -16,248 +16,150 @@ class CreateTicket extends BaseModel ]; #[SerializedName('user')] - private int|null $user; + protected int|null $user; #[SerializedName('on_behalf_of')] - private int|null $onBehalfOf; + protected int|null $onBehalfOf; #[SerializedName('user_firstname')] - private string|null $userFirstname; + protected string|null $userFirstname; #[SerializedName('user_lastname')] - private string|null $userLastname; + protected string|null $userLastname; #[SerializedName('user_email')] - private string|null $userEmail; + protected string|null $userEmail; #[SerializedName('user_organisation')] - private string|null $userOrganisation; + protected string|null $userOrganisation; #[SerializedName('user_ip_address')] - private string|null $userIpAddress; + protected string|null $userIpAddress; #[SerializedName('department')] - private int $department; + protected int $department; #[SerializedName('brand')] - private int|null $brand; + protected int|null $brand; #[SerializedName('status')] - private int $status; + protected int $status; #[SerializedName('priority')] - private int $priority; + protected int $priority; #[SerializedName('internal')] - private bool|null $internal; + protected bool|null $internal; #[SerializedName('subject')] - private string $subject; + protected string $subject; #[SerializedName('text')] - private string $text; + protected string $text; /** @var int[]|null */ #[SerializedName('tag')] - private array|null $tag; + protected array|null $tag; /** @var int[]|null */ #[SerializedName('assignedto')] - private array|null $assignedto; + protected array|null $assignedto; /** @var int[]|null */ #[SerializedName('watching')] - private array|null $watching; + protected array|null $watching; /** @var int[]|null */ #[SerializedName('customfield')] - private array|null $customfield; + protected array|null $customfield; /** @var string[]|null */ #[SerializedName('cc')] - private array|null $cc; + protected array|null $cc; #[SerializedName('send_user_email')] - private int|null $sendUserEmail; + protected int|null $sendUserEmail; #[SerializedName('send_operators_email')] - private int|null $sendOperatorsEmail; + protected int|null $sendOperatorsEmail; /** @var string[]|null */ #[SerializedName('attachment')] - private array|null $attachment; + protected array|null $attachment; #[SerializedName('created_at')] - private int|null $createdAt; + protected int|null $createdAt; public function getUser(): ?int { return $this->user; } - public function setUser(?int $user): self - { - $this->user = $user; - - return $this; - } - public function getOnBehalfOf(): ?int { return $this->onBehalfOf; } - public function setOnBehalfOf(?int $onBehalfOf): self - { - $this->onBehalfOf = $onBehalfOf; - - return $this; - } - public function getUserFirstname(): ?string { return $this->userFirstname; } - public function setUserFirstname(?string $userFirstname): self - { - $this->userFirstname = $userFirstname; - - return $this; - } - public function getUserLastname(): ?string { return $this->userLastname; } - public function setUserLastname(?string $userLastname): self - { - $this->userLastname = $userLastname; - - return $this; - } - public function getUserEmail(): ?string { return $this->userEmail; } - public function setUserEmail(?string $userEmail): self - { - $this->userEmail = $userEmail; - - return $this; - } - public function getUserOrganisation(): ?string { return $this->userOrganisation; } - public function setUserOrganisation(?string $userOrganisation): self - { - $this->userOrganisation = $userOrganisation; - - return $this; - } - public function getUserIpAddress(): ?string { return $this->userIpAddress; } - public function setUserIpAddress(?string $userIpAddress): self - { - $this->userIpAddress = $userIpAddress; - - return $this; - } - public function getDepartment(): int { return $this->department; } - public function setDepartment(int $department): self - { - $this->department = $department; - - return $this; - } - public function getBrand(): ?int { return $this->brand; } - public function setBrand(?int $brand): self - { - $this->brand = $brand; - - return $this; - } - public function getStatus(): int { return $this->status; } - public function setStatus(int $status): self - { - $this->status = $status; - - return $this; - } - public function getPriority(): int { return $this->priority; } - public function setPriority(int $priority): self - { - $this->priority = $priority; - - return $this; - } - public function getInternal(): ?bool { return $this->internal; } - public function setInternal(?bool $internal): self - { - $this->internal = $internal; - - return $this; - } - public function getSubject(): string { return $this->subject; } - public function setSubject(string $subject): self - { - $this->subject = $subject; - - return $this; - } - public function getText(): string { return $this->text; } - public function setText(string $text): self - { - $this->text = $text; - - return $this; - } - /** * @return int[]|null */ @@ -266,16 +168,6 @@ public function getTag(): ?array return $this->tag; } - /** - * @param int[]|null $tag - */ - public function setTag(?array $tag): self - { - $this->tag = $tag; - - return $this; - } - /** * @return int[]|null */ @@ -284,16 +176,6 @@ public function getAssignedto(): ?array return $this->assignedto; } - /** - * @param int[]|null $assignedto - */ - public function setAssignedto(?array $assignedto): self - { - $this->assignedto = $assignedto; - - return $this; - } - /** * @return int[]|null */ @@ -302,16 +184,6 @@ public function getWatching(): ?array return $this->watching; } - /** - * @param int[]|null $watching - */ - public function setWatching(?array $watching): self - { - $this->watching = $watching; - - return $this; - } - /** * @return int[]|null */ @@ -320,16 +192,6 @@ public function getCustomfield(): ?array return $this->customfield; } - /** - * @param int[]|null $customfield - */ - public function setCustomfield(?array $customfield): self - { - $this->customfield = $customfield; - - return $this; - } - /** * @return string[]|null */ @@ -338,40 +200,16 @@ public function getCc(): ?array return $this->cc; } - /** - * @param string[]|null $cc - */ - public function setCc(?array $cc): self - { - $this->cc = $cc; - - return $this; - } - public function getSendUserEmail(): ?int { return $this->sendUserEmail; } - public function setSendUserEmail(?int $sendUserEmail): self - { - $this->sendUserEmail = $sendUserEmail; - - return $this; - } - public function getSendOperatorsEmail(): ?int { return $this->sendOperatorsEmail; } - public function setSendOperatorsEmail(?int $sendOperatorsEmail): self - { - $this->sendOperatorsEmail = $sendOperatorsEmail; - - return $this; - } - /** * @return string[]|null */ @@ -380,25 +218,8 @@ public function getAttachment(): ?array return $this->attachment; } - /** - * @param string[]|null $attachment - */ - public function setAttachment(?array $attachment): self - { - $this->attachment = $attachment; - - return $this; - } - public function getCreatedAt(): ?int { return $this->createdAt; } - - public function setCreatedAt(?int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } } diff --git a/src/Model/Ticket/SlaPlan.php b/src/Model/Ticket/SlaPlan.php index 2e0356ab..0a0e68bd 100644 --- a/src/Model/Ticket/SlaPlan.php +++ b/src/Model/Ticket/SlaPlan.php @@ -2,150 +2,20 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class SlaPlan extends BaseModel +class SlaPlan extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('condition_group_type')] - private int $conditionGroupType; - - #[SerializedName('description')] - private string|null $description; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('order')] - private int|null $order; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('all_hours')] - private int $allHours; - - #[SerializedName('name')] - private string $name; - - /** @var SlaPlanTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getConditionGroupType(): int - { - return $this->conditionGroupType; - } - - public function setConditionGroupType(int $conditionGroupType): self - { - $this->conditionGroupType = $conditionGroupType; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getOrder(): ?int - { - return $this->order; - } - - public function setOrder(?int $order): self - { - $this->order = $order; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getAllHours(): int - { - return $this->allHours; - } - - public function setAllHours(int $allHours): self - { - $this->allHours = $allHours; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - /** - * @return SlaPlanTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param SlaPlanTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'description' => 'string', + 'order' => 'int', + 'all_hours' => 'int', + 'condition_group_type' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'translations' => 'array:' . SlaPlanTranslation::class, + ]; } diff --git a/src/Model/Ticket/SlaPlanTranslation.php b/src/Model/Ticket/SlaPlanTranslation.php index 4158ae59..ec77957f 100644 --- a/src/Model/Ticket/SlaPlanTranslation.php +++ b/src/Model/Ticket/SlaPlanTranslation.php @@ -2,71 +2,15 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class SlaPlanTranslation extends BaseTranslation +class SlaPlanTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('sla_plan_id')] - private int $slaPlanId; - - #[SerializedName('name')] - private string|null $name; - - #[SerializedName('description')] - private string|null $description; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getSlaPlanId(): int - { - return $this->slaPlanId; - } - - public function setSlaPlanId(int $slaPlanId): self - { - $this->slaPlanId = $slaPlanId; - - return $this; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(?string $name): self - { - $this->name = $name; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'sla_plan_id' => 'int', + 'name' => 'string', + 'description' => 'string', + ]; } diff --git a/src/Model/Ticket/Status.php b/src/Model/Ticket/Status.php index cbbadcd9..d223f2c1 100644 --- a/src/Model/Ticket/Status.php +++ b/src/Model/Ticket/Status.php @@ -2,165 +2,25 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Status extends BaseModel +class Status extends Model { - #[SerializedName('colour')] - private string $colour; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('order')] - private int|null $order; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('icon_without_tooltip')] - private string $iconWithoutTooltip; - - #[SerializedName('icon')] - private string $icon; - - #[SerializedName('auto_close')] - private bool $autoClose; - - /** @var StatusTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - public function getColour(): string - { - return $this->colour; - } - - public function setColour(string $colour): self - { - $this->colour = $colour; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getOrder(): ?int - { - return $this->order; - } - - public function setOrder(?int $order): self - { - $this->order = $order; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getIconWithoutTooltip(): string - { - return $this->iconWithoutTooltip; - } - - public function setIconWithoutTooltip(string $iconWithoutTooltip): self - { - $this->iconWithoutTooltip = $iconWithoutTooltip; - - return $this; - } - - public function getIcon(): string - { - return $this->icon; - } - - public function setIcon(string $icon): self - { - $this->icon = $icon; - - return $this; - } - - public function getAutoClose(): bool - { - return $this->autoClose; - } - - public function setAutoClose(bool $autoClose): self - { - $this->autoClose = $autoClose; - - return $this; - } - /** - * @return StatusTranslation[]|null + * The attributes that should be cast to native types. + * + * @var array */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param StatusTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'colour' => 'string', + 'auto_close' => 'int', + 'order' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'icon' => 'string', + 'icon_without_tooltip' => 'string', + 'translations' => 'array:' . StatusTranslation::class, + ]; } diff --git a/src/Model/Ticket/StatusTranslation.php b/src/Model/Ticket/StatusTranslation.php index 24ba8a49..93bc03e1 100644 --- a/src/Model/Ticket/StatusTranslation.php +++ b/src/Model/Ticket/StatusTranslation.php @@ -2,56 +2,14 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class StatusTranslation extends BaseTranslation +class StatusTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('status_id')] - private int $statusId; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getStatusId(): int - { - return $this->statusId; - } - - public function setStatusId(int $statusId): self - { - $this->statusId = $statusId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'status_id' => 'int', + 'name' => 'string', + ]; } diff --git a/src/Model/Ticket/Tag.php b/src/Model/Ticket/Tag.php index c6f6219d..546eb52a 100644 --- a/src/Model/Ticket/Tag.php +++ b/src/Model/Ticket/Tag.php @@ -2,135 +2,19 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Tag extends BaseModel +class Tag extends Model { - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('colour')] - private string $colour; - - #[SerializedName('colour_text')] - private string $colourText; - - #[SerializedName('original_name')] - private string $originalName; - - /** @var TagTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations = null; - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getColour(): string - { - return $this->colour; - } - - public function setColour(string $colour): self - { - $this->colour = $colour; - - return $this; - } - - public function getColourText(): string - { - return $this->colourText; - } - - public function setColourText(string $colourText): self - { - $this->colourText = $colourText; - - return $this; - } - - public function getOriginalName(): string - { - return $this->originalName; - } - - public function setOriginalName(string $originalName): self - { - $this->originalName = $originalName; - - return $this; - } - - /** - * @return TagTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param TagTranslation[]|null $translations - */ - public function setTranslations(?array $translations): self - { - $this->translations = $translations; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'colour' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'colour_text' => 'string', + 'original_name' => 'string', + 'translations' => 'array:' . TagTranslation::class, + ]; } diff --git a/src/Model/Ticket/TagTranslation.php b/src/Model/Ticket/TagTranslation.php index c7117cee..67ebc64a 100644 --- a/src/Model/Ticket/TagTranslation.php +++ b/src/Model/Ticket/TagTranslation.php @@ -2,56 +2,14 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class TagTranslation extends BaseTranslation +class TagTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('tag_id')] - private int $tagId; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getTagId(): int - { - return $this->tagId; - } - - public function setTagId(int $tagId): self - { - $this->tagId = $tagId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'tag_id' => 'int', + 'name' => 'string', + ]; } diff --git a/src/Model/Ticket/Ticket.php b/src/Model/Ticket/Ticket.php index e04dc437..903adc43 100644 --- a/src/Model/Ticket/Ticket.php +++ b/src/Model/Ticket/Ticket.php @@ -2,793 +2,71 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseModel; use SupportPal\ApiClient\Model\Core\Brand; use SupportPal\ApiClient\Model\Department\Department; use SupportPal\ApiClient\Model\Department\Operator; +use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\User\User; -use Symfony\Component\Serializer\Attribute\SerializedName; /** * Class self * @package SupportPal\ApiClient\Model */ -class Ticket extends BaseModel +class Ticket extends Model { - #[SerializedName('department_email_id')] - private int|null $departmentEmailId; - - #[SerializedName('last_reply_id')] - private int|null $lastReplyId; - - #[SerializedName('response_email_sent')] - private bool $responseEmailSent; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('last_reply_time')] - private int $lastReplyTime; - - /** @var string */ - #[SerializedName('subject')] - private string $subject; - - #[SerializedName('last_message_by')] - private int|null $lastMessageBy; - - #[SerializedName('status_id')] - private int $statusId; - - #[SerializedName('locked')] - private int $locked; - - #[SerializedName('messages_count')] - private int|null $messagesCount; - - #[SerializedName('user_id')] - private int $userId; - - #[SerializedName('paused_time')] - private int|null $pausedTime; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('internal')] - private int $internal; - - #[SerializedName('priority_id')] - private int $priorityId; - - #[SerializedName('deleted_at')] - private int|null $deletedAt; - - #[SerializedName('sla_plan_id')] - private int|null $slaPlanId; - - #[SerializedName('department_id')] - private int $departmentId; - - #[SerializedName('last_reply_by')] - private int|null $lastReplyBy; - - #[SerializedName('reopened_time')] - private int|null $reopenedTime; - - #[SerializedName('last_message_id')] - private int|null $lastMessageId; - - #[SerializedName('notes_count')] - private int|null $notesCount; - - #[SerializedName('last_message_time')] - private int $lastMessageTime; - - #[SerializedName('brand_id')] - private int $brandId; - - #[SerializedName('has_draft')] - private bool $hasDraft; - - #[SerializedName('resolved_time')] - private int|null $resolvedTime; - - #[SerializedName('number')] - private string $number; - - /** @var mixed[] */ - #[SerializedName('cc')] - private array $cc; - - #[SerializedName('merged')] - private int $merged; - - #[SerializedName('due_time')] - private int|null $dueTime; - - #[SerializedName('time_while_paused')] - private int $timeWhilePaused; - - #[SerializedName('has_attachments')] - private int|null $hasAttachments; - - #[SerializedName('id')] - private int $id; - - #[SerializedName('channel_id')] - private int $channelId; - - #[SerializedName('channel')] - private Channel|null $channel; - - #[SerializedName('department')] - private Department|null $department; - - /** @var Tag[]|null */ - #[SerializedName('tags')] - private array|null $tags; - - #[SerializedName('user')] - private User|null $user; - - #[SerializedName('token')] - private string $token; - - /** @var Operator[]|null */ - #[SerializedName('watching')] - private array|null $watching; - - /** @var Operator[]|null */ - #[SerializedName('assigned')] - private array|null $assigned; - - #[SerializedName('brand')] - private Brand|null $brand; - - #[SerializedName('last_reply')] - private Message|null $lastReply; - - #[SerializedName('slaplan')] - private SlaPlan|null $slaplan; - - /** @var TicketCustomField[]|null */ - #[SerializedName('customfields')] - private array|null $customfields; - - #[SerializedName('status')] - private Status|null $status; - - #[SerializedName('priority')] - private Priority|null $priority; - - #[SerializedName('frontend_url')] - private string|null $frontendUrl; - - #[SerializedName('operator_url')] - private string|null $operatorUrl; - - public function getDepartmentEmailId(): ?int - { - return $this->departmentEmailId; - } - - public function setDepartmentEmailId(?int $departmentEmailId): self - { - $this->departmentEmailId = $departmentEmailId; - - return $this; - } - - public function getLastReplyId(): ?int - { - return $this->lastReplyId; - } - - public function setLastReplyId(?int $lastReplyId): self - { - $this->lastReplyId = $lastReplyId; - - return $this; - } - - public function getResponseEmailSent(): bool - { - return $this->responseEmailSent; - } - - public function setResponseEmailSent(bool $responseEmailSent): self - { - $this->responseEmailSent = $responseEmailSent; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getLastReplyTime(): int - { - return $this->lastReplyTime; - } - - public function setLastReplyTime(int $lastReplyTime): self - { - $this->lastReplyTime = $lastReplyTime; - - return $this; - } - - public function getSubject(): string - { - return $this->subject; - } - - public function setSubject(string $subject): self - { - $this->subject = $subject; - - return $this; - } - - public function getLastMessageBy(): ?int - { - return $this->lastMessageBy; - } - - public function setLastMessageBy(?int $lastMessageBy): self - { - $this->lastMessageBy = $lastMessageBy; - - return $this; - } - - public function getStatusId(): int - { - return $this->statusId; - } - - public function setStatusId(int $statusId): self - { - $this->statusId = $statusId; - - return $this; - } - - public function getLocked(): int - { - return $this->locked; - } - - public function setLocked(int $locked): self - { - $this->locked = $locked; - - return $this; - } - - public function getMessagesCount(): ?int - { - return $this->messagesCount; - } - - public function setMessagesCount(?int $messagesCount): self - { - $this->messagesCount = $messagesCount; - - return $this; - } - - public function getUserId(): int - { - return $this->userId; - } - - public function setUserId(int $userId): self - { - $this->userId = $userId; - - return $this; - } - - public function getPausedTime(): ?int - { - return $this->pausedTime; - } - - public function setPausedTime(?int $pausedTime): self - { - $this->pausedTime = $pausedTime; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getInternal(): int - { - return $this->internal; - } - - public function setInternal(int $internal): self - { - $this->internal = $internal; - - return $this; - } - - public function getPriorityId(): int - { - return $this->priorityId; - } - - public function setPriorityId(int $priorityId): self - { - $this->priorityId = $priorityId; - - return $this; - } - - public function getDeletedAt(): ?int - { - return $this->deletedAt; - } - - public function setDeletedAt(?int $deletedAt): self - { - $this->deletedAt = $deletedAt; - - return $this; - } - - public function getSlaPlanId(): ?int - { - return $this->slaPlanId; - } - - public function setSlaPlanId(?int $slaPlanId): self - { - $this->slaPlanId = $slaPlanId; - - return $this; - } - - public function getDepartmentId(): int - { - return $this->departmentId; - } - - public function setDepartmentId(int $departmentId): self - { - $this->departmentId = $departmentId; - - return $this; - } - - public function getLastReplyBy(): ?int - { - return $this->lastReplyBy; - } - - public function setLastReplyBy(?int $lastReplyBy): self - { - $this->lastReplyBy = $lastReplyBy; - - return $this; - } - - public function getReopenedTime(): ?int - { - return $this->reopenedTime; - } - - public function setReopenedTime(?int $reopenedTime): self - { - $this->reopenedTime = $reopenedTime; - - return $this; - } - - public function getLastMessageId(): ?int - { - return $this->lastMessageId; - } - - public function setLastMessageId(?int $lastMessageId): self - { - $this->lastMessageId = $lastMessageId; - - return $this; - } - - public function getNotesCount(): ?int - { - return $this->notesCount; - } - - public function setNotesCount(?int $notesCount): self - { - $this->notesCount = $notesCount; - - return $this; - } - - public function getLastMessageTime(): int - { - return $this->lastMessageTime; - } - - public function setLastMessageTime(int $lastMessageTime): self - { - $this->lastMessageTime = $lastMessageTime; - - return $this; - } - - public function getBrandId(): int - { - return $this->brandId; - } - - public function setBrandId(int $brandId): self - { - $this->brandId = $brandId; - - return $this; - } - - public function getHasDraft(): bool - { - return $this->hasDraft; - } - - public function setHasDraft(bool $hasDraft): self - { - $this->hasDraft = $hasDraft; - - return $this; - } - - public function getResolvedTime(): ?int - { - return $this->resolvedTime; - } - - public function setResolvedTime(?int $resolvedTime): self - { - $this->resolvedTime = $resolvedTime; - - return $this; - } - - public function getNumber(): string - { - return $this->number; - } - - public function setNumber(string $number): self - { - $this->number = $number; - - return $this; - } - - /** - * @return array - */ - public function getCc(): array - { - return $this->cc; - } - - /** - * @param array $cc - */ - public function setCc(array $cc): self - { - $this->cc = $cc; - - return $this; - } - - public function getMerged(): int - { - return $this->merged; - } - - public function setMerged(int $merged): self - { - $this->merged = $merged; - - return $this; - } - - public function getDueTime(): ?int - { - return $this->dueTime; - } - - public function setDueTime(?int $dueTime): self - { - $this->dueTime = $dueTime; - - return $this; - } - - public function getTimeWhilePaused(): int - { - return $this->timeWhilePaused; - } - - public function setTimeWhilePaused(int $timeWhilePaused): self - { - $this->timeWhilePaused = $timeWhilePaused; - - return $this; - } - - public function getHasAttachments(): ?int - { - return $this->hasAttachments; - } - - public function setHasAttachments(?int $hasAttachments): self - { - $this->hasAttachments = $hasAttachments; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getChannelId(): int - { - return $this->channelId; - } - - public function setChannelId(int $channelId): self - { - $this->channelId = $channelId; - - return $this; - } - - public function getChannel(): ?Channel - { - return $this->channel; - } - - public function setChannel(?Channel $channel): self - { - $this->channel = $channel; - - return $this; - } - - public function getDepartment(): ?Department - { - return $this->department; - } - - public function setDepartment(?Department $department): self - { - $this->department = $department; - - return $this; - } - - /** - * @return Tag[]|null - */ - public function getTags(): ?array - { - return $this->tags; - } - - /** - * @param Tag[]|null $tags - */ - public function setTags(?array $tags): self - { - $this->tags = $tags; - - return $this; - } - - public function getUser(): ?User - { - return $this->user; - } - - public function setUser(?User $user): self - { - $this->user = $user; - - return $this; - } - - public function getToken(): string - { - return $this->token; - } - - public function setToken(string $token): self - { - $this->token = $token; - - return $this; - } - - /** - * @return Operator[]|null - */ - public function getWatching(): ?array - { - return $this->watching; - } - - /** - * @param Operator[]|null $watching - */ - public function setWatching(?array $watching): self - { - $this->watching = $watching; - - return $this; - } - - /** - * @return Operator[]|null - */ - public function getAssigned(): ?array - { - return $this->assigned; - } - - /** - * @param Operator[]|null $assigned - */ - public function setAssigned(?array $assigned): self - { - $this->assigned = $assigned; - - return $this; - } - - public function getBrand(): ?Brand - { - return $this->brand; - } - - public function setBrand(?Brand $brand): self - { - $this->brand = $brand; - - return $this; - } - - public function getLastReply(): ?Message - { - return $this->lastReply; - } - - public function setLastReply(?Message $lastReply): self - { - $this->lastReply = $lastReply; - - return $this; - } - - public function getSlaplan(): ?SlaPlan - { - return $this->slaplan; - } - - public function setSlaplan(?SlaPlan $slaplan): self - { - $this->slaplan = $slaplan; - - return $this; - } - /** - * @return TicketCustomField[]|null + * The attributes that should be cast to native types. + * + * @var array */ - public function getCustomfields(): ?array - { - return $this->customfields; - } - - /** - * @param TicketCustomField[]|null $customfields - */ - public function setCustomfields(?array $customfields): self - { - $this->customfields = $customfields; - - return $this; - } - - public function getStatus(): ?Status - { - return $this->status; - } - - public function setStatus(?Status $status): self - { - $this->status = $status; - - return $this; - } - - public function getPriority(): ?Priority - { - return $this->priority; - } - - public function setPriority(?Priority $priority): self - { - $this->priority = $priority; - - return $this; - } - - public function getFrontendUrl(): ?string - { - return $this->frontendUrl; - } - - /** - * @return $this - */ - public function setFrontendUrl(string $url): self - { - $this->frontendUrl = $url; - - return $this; - } - - public function getOperatorUrl(): ?string - { - return $this->operatorUrl; - } - - /** - * @return $this - */ - public function setOperatorUrl(string $url): self - { - $this->operatorUrl = $url; - - return $this; - } + protected $casts = [ + 'id' => 'int', + 'number' => 'string', + 'department_id' => 'int', + 'department_email_id' => 'int', + 'brand_id' => 'int', + 'channel_id' => 'int', + 'user_id' => 'int', + 'status_id' => 'int', + 'priority_id' => 'int', + 'sla_plan_id' => 'int', + 'subject' => 'string', + 'due_time' => 'int', + 'paused_time' => 'int', + 'time_while_paused' => 'int', + 'resolved_time' => 'int', + 'reopened_time' => 'int', + 'cc' => 'array', + 'locked' => 'int', + 'merged' => 'int', + 'internal' => 'int', + 'response_email_sent' => 'int', + 'messages_count' => 'int', + 'notes_count' => 'int', + 'has_attachments' => 'int', + 'has_draft' => 'boolean', + 'last_reply_time' => 'int', + 'last_message_time' => 'int', + 'last_reply_id' => 'int', + 'last_message_id' => 'int', + 'last_reply_by' => 'int', + 'last_message_by' => 'int', + 'deleted_at' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'frontend_url' => 'string', + 'operator_url' => 'string', + 'channel' => Channel::class, + 'department' => Department::class, + 'tags' => 'array:' . Tag::class, + 'user' => User::class, + 'watching' => 'array:' . Operator::class, + 'assigned' => 'array:' . Operator::class, + 'brand' => Brand::class, + 'last_reply' => Message::class, + 'slaplan' => SlaPlan::class, + 'customfields' => 'array:' . TicketCustomField::class, + 'status' => Status::class, + 'priority' => Priority::class, + ]; } diff --git a/src/Model/Ticket/TicketCustomField.php b/src/Model/Ticket/TicketCustomField.php index b335eec3..fdbb91c5 100644 --- a/src/Model/Ticket/TicketCustomField.php +++ b/src/Model/Ticket/TicketCustomField.php @@ -4,81 +4,23 @@ use SupportPal\ApiClient\Model\Department\Department; use SupportPal\ApiClient\Model\Shared\CustomField; -use Symfony\Component\Serializer\Attribute\SerializedName; + +use function array_merge; class TicketCustomField extends CustomField { - #[SerializedName('purge')] - private int|null $purge = null; - - /** @var Department[]|null */ - #[SerializedName('departments')] - private array|null $departments = null; - - #[SerializedName('ticket_id')] - private int|null $ticketId = null; - - /** @var TicketCustomFieldTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations = null; - - public function getPurge(): ?int - { - return $this->purge; - } - - public function setPurge(?int $purge): self - { - $this->purge = $purge; - - return $this; - } - - /** - * @return Department[]|null - */ - public function getDepartments(): ?array - { - return $this->departments; - } - - /** - * @param Department[]|null $departments - */ - public function setDepartments(?array $departments): self - { - $this->departments = $departments; - - return $this; - } - - public function getTicketId(): ?int - { - return $this->ticketId; - } - - public function setTicketId(?int $ticketId): self - { - $this->ticketId = $ticketId; - - return $this; - } - - /** - * @return TicketCustomFieldTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - /** - * @param TicketCustomFieldTranslation[]|null $translations + * @param mixed[] $attributes */ - public function setTranslations(?array $translations): self + public function __construct(array $attributes = []) { - $this->translations = $translations; + $this->casts = array_merge($this->casts, [ + 'purge' => 'int', + 'ticket_id' => 'int', + 'departments' => 'array:' . Department::class, + 'translations' => 'array:' . TicketCustomFieldTranslation::class + ]); - return $this; + parent::__construct($attributes); } } diff --git a/src/Model/Ticket/TicketCustomFieldTranslation.php b/src/Model/Ticket/TicketCustomFieldTranslation.php index 76db6e50..1b0fc38b 100644 --- a/src/Model/Ticket/TicketCustomFieldTranslation.php +++ b/src/Model/Ticket/TicketCustomFieldTranslation.php @@ -2,86 +2,16 @@ namespace SupportPal\ApiClient\Model\Ticket; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class TicketCustomFieldTranslation extends BaseTranslation +class TicketCustomFieldTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('ticket_custom_field_id')] - private int $ticketCustomFieldId; - - #[SerializedName('description')] - private string|null $description; - - #[SerializedName('regex_error_message')] - private string|null $regexErrorMessage; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): TicketCustomFieldTranslation - { - $this->name = $name; - - return $this; - } - - public function getTicketCustomFieldId(): int - { - return $this->ticketCustomFieldId; - } - - public function setTicketCustomFieldId(int $ticketCustomFieldId): self - { - $this->ticketCustomFieldId = $ticketCustomFieldId; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } - - public function getRegexErrorMessage(): ?string - { - return $this->regexErrorMessage; - } - - public function setRegexErrorMessage(?string $regexErrorMessage): self - { - $this->regexErrorMessage = $regexErrorMessage; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'ticket_custom_field_id' => 'int', + 'name' => 'string', + 'description' => 'string', + 'regex_error_message' => 'string', + ]; } diff --git a/src/Model/BaseTranslation.php b/src/Model/Translation.php similarity index 75% rename from src/Model/BaseTranslation.php rename to src/Model/Translation.php index 0c15290d..3159f088 100644 --- a/src/Model/BaseTranslation.php +++ b/src/Model/Translation.php @@ -4,8 +4,11 @@ use function array_merge; -abstract class BaseTranslation extends BaseModel +abstract class Translation extends Model { + /** + * @param mixed[] $attributes + */ public function __construct(array $attributes = []) { $this->casts = array_merge($this->casts, ['locale' => 'string']); diff --git a/src/Model/User/Domain.php b/src/Model/User/Domain.php index 52ed4ab6..703a2bc6 100644 --- a/src/Model/User/Domain.php +++ b/src/Model/User/Domain.php @@ -2,38 +2,14 @@ namespace SupportPal\ApiClient\Model\User; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Domain extends BaseModel +class Domain extends Model { - #[SerializedName('organisation_id')] - private int $organisationId; - - #[SerializedName('domain')] - private string $domain; - - public function getOrganisationId(): int - { - return $this->organisationId; - } - - public function setOrganisationId(int $organisationId): self - { - $this->organisationId = $organisationId; - - return $this; - } - - public function getDomain(): string - { - return $this->domain; - } - - public function setDomain(string $domain): self - { - $this->domain = $domain; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'organisation_id' => 'int', + 'domain' => 'string', + ]; } diff --git a/src/Model/User/Group.php b/src/Model/User/Group.php index 3a704388..389cdf77 100644 --- a/src/Model/User/Group.php +++ b/src/Model/User/Group.php @@ -2,135 +2,19 @@ namespace SupportPal\ApiClient\Model\User; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Group extends BaseModel +class Group extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('description')] - private string|null $description; - - #[SerializedName('administrator')] - private int $administrator; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('colour')] - private string $colour; - - /** @var GroupTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } - - public function getAdministrator(): int - { - return $this->administrator; - } - - public function setAdministrator(int $administrator): self - { - $this->administrator = $administrator; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getColour(): string - { - return $this->colour; - } - - public function setColour(string $colour): self - { - $this->colour = $colour; - - return $this; - } - - /** - * @return GroupTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - - /** - * @param GroupTranslation[]|null $translations - */ - public function setTranslations(?array $translations): Group - { - $this->translations = $translations; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'name' => 'string', + 'description' => 'string', + 'colour' => 'string', + 'administrator' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'translations' => 'array:' . GroupTranslation::class, + ]; } diff --git a/src/Model/User/GroupTranslation.php b/src/Model/User/GroupTranslation.php index 186cfb7b..abfbe7a2 100644 --- a/src/Model/User/GroupTranslation.php +++ b/src/Model/User/GroupTranslation.php @@ -2,71 +2,15 @@ namespace SupportPal\ApiClient\Model\User; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class GroupTranslation extends BaseTranslation +class GroupTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('description')] - private string|null $description; - - #[SerializedName('user_group_id')] - private int $userGroupId; - - #[SerializedName('name')] - private string|null $name; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): ?string - { - return $this->name; - } - - public function setName(?string $name): self - { - $this->name = $name; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } - - public function getUserGroupId(): int - { - return $this->userGroupId; - } - - public function setUserGroupId(int $userGroupId): self - { - $this->userGroupId = $userGroupId; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'user_group_id' => 'int', + 'name' => 'string', + 'description' => 'string', + ]; } diff --git a/src/Model/User/Organisation.php b/src/Model/User/Organisation.php index d9345950..fb523532 100644 --- a/src/Model/User/Organisation.php +++ b/src/Model/User/Organisation.php @@ -2,224 +2,24 @@ namespace SupportPal\ApiClient\Model\User; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class Organisation extends BaseModel +class Organisation extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('notes')] - private string|null $notes; - - #[SerializedName('brand_id')] - private int $brandId; - - #[SerializedName('language_code')] - private string|null $languageCode; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('timezone')] - private string|null $timezone; - - #[SerializedName('country')] - private string|null $country; - - #[SerializedName('owner_id')] - private int|null $ownerId; - - /** @var User[]|null */ - #[SerializedName('users')] - private array|null $users; - - /** @var UserCustomField[]|null */ - #[SerializedName('customfields')] - private array|null $customfields; - - /** @var Domain[]|null */ - #[SerializedName('domains')] - private array|null $domains; - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): Organisation - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): Organisation - { - $this->name = $name; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): Organisation - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getNotes(): ?string - { - return $this->notes; - } - - public function setNotes(?string $notes): Organisation - { - $this->notes = $notes; - - return $this; - } - - public function getBrandId(): int - { - return $this->brandId; - } - - public function setBrandId(int $brandId): Organisation - { - $this->brandId = $brandId; - - return $this; - } - - public function getLanguageCode(): ?string - { - return $this->languageCode; - } - - public function setLanguageCode(?string $languageCode): Organisation - { - $this->languageCode = $languageCode; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): Organisation - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getTimezone(): ?string - { - return $this->timezone; - } - - public function setTimezone(?string $timezone): Organisation - { - $this->timezone = $timezone; - - return $this; - } - - public function getCountry(): ?string - { - return $this->country; - } - - public function setCountry(?string $country): Organisation - { - $this->country = $country; - - return $this; - } - - public function getOwnerId(): ?int - { - return $this->ownerId; - } - - public function setOwnerId(?int $ownerId): Organisation - { - $this->ownerId = $ownerId; - - return $this; - } - - /** - * @return User[]|null - */ - public function getUsers(): ?array - { - return $this->users; - } - - /** - * @param User[]|null $users - */ - public function setUsers(?array $users): Organisation - { - $this->users = $users; - - return $this; - } - - /** - * @return UserCustomField[]|null - */ - public function getCustomfields(): ?array - { - return $this->customfields; - } - - /** - * @param UserCustomField[]|null $customfields - */ - public function setCustomfields(?array $customfields): Organisation - { - $this->customfields = $customfields; - - return $this; - } - - /** - * @return Domain[]|null - */ - public function getDomains(): ?array - { - return $this->domains; - } - - /** - * @param Domain[]|null $domains - */ - public function setDomains(?array $domains): Organisation - { - $this->domains = $domains; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'brand_id' => 'int', + 'owner_id' => 'int', + 'name' => 'string', + 'country' => 'string', + 'language_code' => 'string', + 'timezone' => 'string', + 'notes' => 'string', + 'created_at' => 'int', + 'updated_at' => 'int', + 'users' => 'array:' . User::class, + 'customfields' => 'array:' . UserCustomField::class, + 'domains' => 'array:' . Domain::class, + ]; } diff --git a/src/Model/User/Request/CreateUser.php b/src/Model/User/Request/CreateUser.php index aca76c0c..ac8ba0b7 100644 --- a/src/Model/User/Request/CreateUser.php +++ b/src/Model/User/Request/CreateUser.php @@ -2,231 +2,133 @@ namespace SupportPal\ApiClient\Model\User\Request; -use SupportPal\ApiClient\Model\BaseModel; +use SupportPal\ApiClient\Model\Model; use Symfony\Component\Serializer\Attribute\SerializedName; -class CreateUser extends BaseModel +class CreateUser extends Model { public const REQUIRED_FIELDS = ['email']; #[SerializedName('brand_id')] - private int|null $brandId; + protected int|null $brandId; #[SerializedName('firstname')] - private string|null $firstname; + protected string|null $firstname; #[SerializedName('lastname')] - private string|null $lastname; + protected string|null $lastname; #[SerializedName('email')] - private string $email; + protected string $email; #[SerializedName('password')] - private string|null $password; + protected string|null $password; #[SerializedName('country')] - private string|null $country; + protected string|null $country; #[SerializedName('language_code')] - private string|null $languageCode; + protected string|null $languageCode; #[SerializedName('timezone')] - private string|null $timezone; + protected string|null $timezone; #[SerializedName('confirmed')] - private bool|null $confirmed; + protected bool|null $confirmed; #[SerializedName('active')] - private int|null $active; + protected int|null $active; #[SerializedName('organisation')] - private string|null $organisation; + protected string|null $organisation; #[SerializedName('organisation_id')] - private int|null $organisationId; + protected int|null $organisationId; #[SerializedName('organisation_access_level')] - private int|null $organisationAccessLevel; + protected int|null $organisationAccessLevel; #[SerializedName('organisation_notifications')] - private int|null $organisationNotifications; + protected int|null $organisationNotifications; /** @var int[]|null */ #[SerializedName('customfield')] - private array|null $customfield; + protected array|null $customfield; /** @var int[]|null */ #[SerializedName('groups')] - private array|null $groups; + protected array|null $groups; public function getBrandId(): ?int { return $this->brandId; } - public function setBrandId(?int $brandId): self - { - $this->brandId = $brandId; - - return $this; - } - public function getFirstname(): ?string { return $this->firstname; } - public function setFirstname(?string $firstname): self - { - $this->firstname = $firstname; - - return $this; - } - public function getLastname(): ?string { return $this->lastname; } - public function setLastname(?string $lastname): self - { - $this->lastname = $lastname; - - return $this; - } - public function getEmail(): string { return $this->email; } - public function setEmail(string $email): self - { - $this->email = $email; - - return $this; - } - public function getPassword(): ?string { return $this->password; } - public function setPassword(?string $password): self - { - $this->password = $password; - - return $this; - } - public function getCountry(): ?string { return $this->country; } - public function setCountry(?string $country): self - { - $this->country = $country; - - return $this; - } - public function getLanguageCode(): ?string { return $this->languageCode; } - public function setLanguageCode(?string $languageCode): self - { - $this->languageCode = $languageCode; - - return $this; - } - public function getTimezone(): ?string { return $this->timezone; } - public function setTimezone(?string $timezone): self - { - $this->timezone = $timezone; - - return $this; - } - public function getConfirmed(): ?bool { return $this->confirmed; } - public function setConfirmed(?bool $confirmed): self - { - $this->confirmed = $confirmed; - - return $this; - } - public function getActive(): ?int { return $this->active; } - public function setActive(?int $active): self - { - $this->active = $active; - - return $this; - } - public function getOrganisation(): ?string { return $this->organisation; } - public function setOrganisation(?string $organisation): self - { - $this->organisation = $organisation; - - return $this; - } - public function getOrganisationId(): ?int { return $this->organisationId; } - public function setOrganisationId(?int $organisationId): self - { - $this->organisationId = $organisationId; - - return $this; - } - public function getOrganisationAccessLevel(): ?int { return $this->organisationAccessLevel; } - public function setOrganisationAccessLevel(?int $organisationAccessLevel): self - { - $this->organisationAccessLevel = $organisationAccessLevel; - - return $this; - } - public function getOrganisationNotifications(): ?int { return $this->organisationNotifications; } - public function setOrganisationNotifications(?int $organisationNotifications): self - { - $this->organisationNotifications = $organisationNotifications; - - return $this; - } - /** * @return int[]|null */ @@ -235,16 +137,6 @@ public function getCustomfield(): ?array return $this->customfield; } - /** - * @param int[]|null $customfield - */ - public function setCustomfield(?array $customfield): self - { - $this->customfield = $customfield; - - return $this; - } - /** * @return int[]|null */ @@ -252,14 +144,4 @@ public function getGroups(): ?array { return $this->groups; } - - /** - * @param int[]|null $groups - */ - public function setGroups(?array $groups): self - { - $this->groups = $groups; - - return $this; - } } diff --git a/src/Model/User/User.php b/src/Model/User/User.php index 1d571107..d7433580 100644 --- a/src/Model/User/User.php +++ b/src/Model/User/User.php @@ -2,510 +2,45 @@ namespace SupportPal\ApiClient\Model\User; -use SupportPal\ApiClient\Model\BaseModel; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Model; -class User extends BaseModel +class User extends Model { - #[SerializedName('id')] - private int $id; - - #[SerializedName('country')] - private string|null $country; - - #[SerializedName('avatar')] - private string|null $avatar; - - #[SerializedName('twofa_enabled')] - private bool|null $twofaEnabled; - - /** @deprecated Use email_verified */ - #[SerializedName('confirmed')] - private ?bool $confirmed = null; - - #[SerializedName('email_verified')] - private bool|null $emailVerified; - - #[SerializedName('language_code')] - private string|null $languageCode; - - #[SerializedName('organisation_id')] - private int|null $organisationId; - - #[SerializedName('timezone')] - private string|null $timezone; - - #[SerializedName('organisation_notifications')] - private bool|null $organisationNotifications; - - #[SerializedName('twitter_handle')] - private string|null $twitterHandle; - - #[SerializedName('lastname')] - private string|null $lastname; - - #[SerializedName('brand_id')] - private int|null $brandId; - - #[SerializedName('active')] - private bool $active; - - #[SerializedName('email')] - private string|null $email; - - #[SerializedName('template_mode')] - private int|null $templateMode; - - #[SerializedName('updated_at')] - private int $updatedAt; - - #[SerializedName('notes')] - private string|null $notes; - - #[SerializedName('organisation_access_level')] - private int|null $organisationAccessLevel; - - #[SerializedName('facebook_id')] - private int|null $facebookId; - - #[SerializedName('last_active_at')] - private int|null $lastActiveAt; - - #[SerializedName('twofa_token')] - private string|null $twofaToken; - - #[SerializedName('firstname')] - private string|null $firstname; - - #[SerializedName('created_at')] - private int $createdAt; - - #[SerializedName('twitter_id')] - private int|null $twitterId = null; - - #[SerializedName('twofa_secret')] - private string|null $twofaSecret; - - #[SerializedName('role')] - private int $role; - - #[SerializedName('formatted_name')] - private string|null $formattedName = null; - - #[SerializedName('avatar_url')] - private string|null $avatarUrl = null; - - #[SerializedName('organisation')] - private Organisation|null $organisation = null; - - /** @var UserCustomField[]|null */ - #[SerializedName('customfields')] - private array|null $customfields = null; - - /** @var Group[]|null */ - #[SerializedName('groups')] - private array|null $groups = null; - - public function getTwofaToken(): ?string - { - return $this->twofaToken; - } - - public function setTwofaToken(?string $twofaToken): self - { - $this->twofaToken = $twofaToken; - - return $this; - } - - public function getTemplateMode(): ?int - { - return $this->templateMode; - } - - public function setTemplateMode(?int $templateMode): self - { - $this->templateMode = $templateMode; - - return $this; - } - - public function getEmail(): ?string - { - return $this->email; - } - - public function setEmail(?string $email): self - { - $this->email = $email; - - return $this; - } - - public function getActive(): bool - { - return $this->active; - } - - public function setActive(bool $active): self - { - $this->active = $active; - - return $this; - } - - public function getTimezone(): ?string - { - return $this->timezone; - } - - public function setTimezone(?string $timezone): self - { - $this->timezone = $timezone; - - return $this; - } - - public function getLastActiveAt(): ?int - { - return $this->lastActiveAt; - } - - public function setLastActiveAt(?int $lastActiveAt): self - { - $this->lastActiveAt = $lastActiveAt; - - return $this; - } - - public function getOrganisationId(): ?int - { - return $this->organisationId; - } - - public function setOrganisationId(?int $organisationId): self - { - $this->organisationId = $organisationId; - - return $this; - } - - public function getTwitterId(): ?int - { - return $this->twitterId; - } - - public function setTwitterId(?int $twitterId): self - { - $this->twitterId = $twitterId; - - return $this; - } - - public function getNotes(): ?string - { - return $this->notes; - } - - public function setNotes(?string $notes): self - { - $this->notes = $notes; - - return $this; - } - - public function getLanguageCode(): ?string - { - return $this->languageCode; - } - - public function setLanguageCode(?string $languageCode): self - { - $this->languageCode = $languageCode; - - return $this; - } - - public function getLastname(): ?string - { - return $this->lastname; - } - - public function setLastname(?string $lastname): self - { - $this->lastname = $lastname; - - return $this; - } - - public function getCreatedAt(): int - { - return $this->createdAt; - } - - public function setCreatedAt(int $createdAt): self - { - $this->createdAt = $createdAt; - - return $this; - } - - public function getFirstname(): ?string - { - return $this->firstname; - } - - public function setFirstname(?string $firstname): self - { - $this->firstname = $firstname; - - return $this; - } - - public function getId(): int - { - return $this->id; - } - - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getAvatar(): ?string - { - return $this->avatar; - } - - public function setAvatar(?string $avatar): self - { - $this->avatar = $avatar; - - return $this; - } - - public function getFacebookId(): ?int - { - return $this->facebookId; - } - - public function setFacebookId(?int $facebookId): self - { - $this->facebookId = $facebookId; - - return $this; - } - - public function getOrganisationAccessLevel(): ?int - { - return $this->organisationAccessLevel; - } - - public function setOrganisationAccessLevel(?int $organisationAccessLevel): self - { - $this->organisationAccessLevel = $organisationAccessLevel; - - return $this; - } - - public function getRole(): int - { - return $this->role; - } - - public function setRole(int $role): self - { - $this->role = $role; - - return $this; - } - - public function getTwofaSecret(): ?string - { - return $this->twofaSecret; - } - - public function setTwofaSecret(?string $twofaSecret): self - { - $this->twofaSecret = $twofaSecret; - - return $this; - } - - public function getTwitterHandle(): ?string - { - return $this->twitterHandle; - } - - public function setTwitterHandle(?string $twitterHandle): self - { - $this->twitterHandle = $twitterHandle; - - return $this; - } - - public function getBrandId(): ?int - { - return $this->brandId; - } - - public function setBrandId(?int $brandId): self - { - $this->brandId = $brandId; - - return $this; - } - - /** - * @deprecated Use getEmailVerified - */ - public function getConfirmed(): ?bool - { - return $this->confirmed; - } - - /** - * @param bool $confirmed - *@deprecated Use getEmailVerified - */ - public function setConfirmed(bool $confirmed): self - { - $this->confirmed = $confirmed; - - return $this; - } - - public function getEmailVerified(): ?bool - { - return $this->emailVerified; - } - - public function setEmailVerified(bool $verified): self - { - $this->emailVerified = $verified; - - return $this; - } - - public function getOrganisationNotifications(): ?bool - { - return $this->organisationNotifications; - } - - public function setOrganisationNotifications(?bool $organisationNotifications): self - { - $this->organisationNotifications = $organisationNotifications; - - return $this; - } - - public function getTwofaEnabled(): ?bool - { - return $this->twofaEnabled; - } - - public function setTwofaEnabled(?bool $twofaEnabled): self - { - $this->twofaEnabled = $twofaEnabled; - - return $this; - } - - public function getUpdatedAt(): int - { - return $this->updatedAt; - } - - public function setUpdatedAt(int $updatedAt): self - { - $this->updatedAt = $updatedAt; - - return $this; - } - - public function getCountry(): ?string - { - return $this->country; - } - - public function setCountry(?string $country): self - { - $this->country = $country; - - return $this; - } - - public function getFormattedName(): ?string - { - return $this->formattedName; - } - - public function setFormattedName(string $formattedName): self - { - $this->formattedName = $formattedName; - - return $this; - } - - public function getAvatarUrl(): ?string - { - return $this->avatarUrl; - } - - public function setAvatarUrl(string $avatarUrl): self - { - $this->avatarUrl = $avatarUrl; - - return $this; - } - - public function getOrganisation(): ?Organisation - { - return $this->organisation; - } - - public function setOrganisation(?Organisation $organisation): User - { - $this->organisation = $organisation; - - return $this; - } - - /** - * @return UserCustomField[]|null - */ - public function getCustomfields(): ?array - { - return $this->customfields; - } - - /** - * @param UserCustomField[]|null $customfields - */ - public function setCustomfields(?array $customfields): User - { - $this->customfields = $customfields; - - return $this; - } - - /** - * @return Group[]|null - */ - public function getGroups(): ?array - { - return $this->groups; - } - - /** - * @param Group[]|null $groups - */ - public function setGroups(?array $groups): self - { - $this->groups = $groups; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'brand_id' => 'int', + 'role' => 'int', + 'firstname' => 'string', + 'lastname' => 'string', + 'email' => 'string', + 'password' => 'string', + 'session' => 'string', + 'remember_token' => 'string', + 'email_verified' => 'int', + 'active' => 'int', + 'organisation_id' => 'int', + 'organisation_access_level' => 'int', + 'organisation_notifications' => 'int', + 'country' => 'string', + 'language_code' => 'string', + 'timezone' => 'string', + 'avatar' => 'string', + 'template_mode' => 'int', + 'notes' => 'string', + 'twofa_enabled' => 'int', + 'twofa_secret' => 'string', + 'twofa_token' => 'string', + 'twitter_id' => 'string', + 'twitter_handle' => 'string', + 'facebook_id' => 'string', + 'last_active_at' => 'int', + 'created_at' => 'int', + 'updated_at' => 'int', + 'avatar_url' => 'string', + 'formatted_name' => 'string', + 'groups' => 'array:' . Group::class, + 'customfields' => 'array:' . UserCustomField::class, + 'organisation' => Organisation::class, + ]; } diff --git a/src/Model/User/UserCustomField.php b/src/Model/User/UserCustomField.php index ab861333..2216173e 100644 --- a/src/Model/User/UserCustomField.php +++ b/src/Model/User/UserCustomField.php @@ -3,44 +3,21 @@ namespace SupportPal\ApiClient\Model\User; use SupportPal\ApiClient\Model\Shared\CustomField; -use Symfony\Component\Serializer\Attribute\SerializedName; + +use function array_merge; class UserCustomField extends CustomField { - #[SerializedName('user_id')] - private int|null $userId = null; - - /** @var UserCustomFieldTranslation[]|null */ - #[SerializedName('translations')] - private array|null $translations; - - public function getUserId(): ?int - { - return $this->userId; - } - - public function setUserId(?int $userId): self - { - $this->userId = $userId; - - return $this; - } - - /** - * @return UserCustomFieldTranslation[]|null - */ - public function getTranslations(): ?array - { - return $this->translations; - } - /** - * @param UserCustomFieldTranslation[]|null $translations + * @param mixed[] $attributes */ - public function setTranslations(?array $translations): self + public function __construct(array $attributes = []) { - $this->translations = $translations; + $this->casts = array_merge($this->casts, [ + 'user_id' => 'int', + 'translations' => 'array:' . UserCustomFieldTranslation::class + ]); - return $this; + parent::__construct($attributes); } } diff --git a/src/Model/User/UserCustomFieldTranslation.php b/src/Model/User/UserCustomFieldTranslation.php index 45d4c3e4..03468257 100644 --- a/src/Model/User/UserCustomFieldTranslation.php +++ b/src/Model/User/UserCustomFieldTranslation.php @@ -2,86 +2,16 @@ namespace SupportPal\ApiClient\Model\User; -use SupportPal\ApiClient\Model\BaseTranslation; -use Symfony\Component\Serializer\Attribute\SerializedName; +use SupportPal\ApiClient\Model\Translation; -class UserCustomFieldTranslation extends BaseTranslation +class UserCustomFieldTranslation extends Translation { - #[SerializedName('id')] - private int $id; - - #[SerializedName('name')] - private string $name; - - #[SerializedName('user_custom_field_id')] - private int $userCustomFieldId; - - #[SerializedName('description')] - private string|null $description; - - #[SerializedName('regex_error_message')] - private string|null $regexErrorMessage; - - public function getId(): int - { - return $this->id; - } - - /** - * @return $this - */ - public function setId(int $id): self - { - $this->id = $id; - - return $this; - } - - public function getName(): string - { - return $this->name; - } - - public function setName(string $name): self - { - $this->name = $name; - - return $this; - } - - public function getUserCustomFieldId(): int - { - return $this->userCustomFieldId; - } - - public function setUserCustomFieldId(int $userCustomFieldId): self - { - $this->userCustomFieldId = $userCustomFieldId; - - return $this; - } - - public function getDescription(): ?string - { - return $this->description; - } - - public function setDescription(?string $description): self - { - $this->description = $description; - - return $this; - } - - public function getRegexErrorMessage(): ?string - { - return $this->regexErrorMessage; - } - - public function setRegexErrorMessage(?string $regexErrorMessage): self - { - $this->regexErrorMessage = $regexErrorMessage; - - return $this; - } + /** @var array */ + protected $casts = [ + 'id' => 'int', + 'user_custom_field_id' => 'int', + 'name' => 'string', + 'description' => 'string', + 'regex_error_message' => 'string', + ]; } diff --git a/src/Resources/api.yml b/src/Resources/api.yml index 194c5244..52b4fa27 100644 --- a/src/Resources/api.yml +++ b/src/Resources/api.yml @@ -5,8 +5,7 @@ services: public: false SupportPal\ApiClient\Api\Api: - arguments: - $formatType: '%contentType%' + public: true SupportPal\ApiClient\Api\CoreApi: public: true diff --git a/src/Resources/api_client.yml b/src/Resources/api_client.yml index 237706fc..49ea04a0 100644 --- a/src/Resources/api_client.yml +++ b/src/Resources/api_client.yml @@ -8,7 +8,6 @@ services: public: true arguments: $httpClient: '@GuzzleHttp\Client' - $formatType: '%contentType%' SupportPal\ApiClient\ApiClient\CoreApiClient: parent: 'SupportPal\ApiClient\ApiClient' diff --git a/src/Resources/core_services.yml b/src/Resources/core_services.yml index e31ba636..56ec7b83 100644 --- a/src/Resources/core_services.yml +++ b/src/Resources/core_services.yml @@ -8,10 +8,6 @@ services: arguments: $factories: !tagged factory.model_factory - SupportPal\ApiClient\Converter\ModelToArrayConverter: - arguments: - $format: '%contentType%' - SupportPal\ApiClient\ApiClient\CoreApiClient: parent: 'SupportPal\ApiClient\ApiClient' diff --git a/src/Resources/factories.yml b/src/Resources/factories.yml index 0613fba6..1c4636e3 100644 --- a/src/Resources/factories.yml +++ b/src/Resources/factories.yml @@ -12,82 +12,80 @@ services: $contentType: '%apiContentType%' $defaultBodyContent: '%defaultBodyContent%' $defaultParameters: '%defaultParameters%' - $formatType: '%contentType%' - SupportPal\ApiClient\Factory\BaseModelFactory: - arguments: - $formatType: '%contentType%' + SupportPal\ApiClient\Factory\ModelFactory: + public: true SupportPal\ApiClient\Factory\Shared\SettingsFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\SelfService\CommentFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\SelfService\TypeFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\User\UserFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\SelfService\ArticleFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\SelfService\CategoryFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\SelfService\TagFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\DepartmentFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\ChannelSettingsFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\CustomFieldFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\PriorityFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\StatusFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\AttachmentFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\TicketFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\MessageFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Core\BrandFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\User\GroupFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\User\UserCustomFieldFactory: - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Collection\CollectionFactory: ~ diff --git a/src/Resources/library_services.yml b/src/Resources/library_services.yml deleted file mode 100644 index ebeaf722..00000000 --- a/src/Resources/library_services.yml +++ /dev/null @@ -1,42 +0,0 @@ -services: - Symfony\Component\Serializer\Normalizer\ObjectNormalizer: - arguments: - $classMetadataFactory: '@Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory' - $nameConverter: '@Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter' - $propertyAccessor: ~ - $propertyTypeExtractor: '@Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor' - $classDiscriminatorResolver: ~ - $objectClassResolver: ~ - $defaultContext: - skip_null_values: true - skip_uninitialized_values: false - - Symfony\Component\Serializer\Encoder\DecoderInterface: '@Symfony\Component\Serializer\Encoder\JsonEncoder' - - Symfony\Component\Serializer\Encoder\EncoderInterface: '@Symfony\Component\Serializer\Encoder\JsonEncoder' - - Symfony\Component\Serializer\NameConverter\MetadataAwareNameConverter: - arguments: - $metadataFactory: '@Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory' - - Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactory: - arguments: - - '@Symfony\Component\Serializer\Mapping\Loader\AttributeLoader' - - Symfony\Component\Serializer\Mapping\Loader\AttributeLoader: - - Symfony\Component\Serializer\SerializerInterface: '@Symfony\Component\Serializer\Serializer' - - Symfony\Component\Serializer\Serializer: - arguments: - - [ '@SupportPal\ApiClient\Normalizer\ModelNormalizer', '@Symfony\Component\Serializer\Normalizer\ObjectNormalizer', '@Symfony\Component\Serializer\Normalizer\ArrayDenormalizer' ] - - [ '@Symfony\Component\Serializer\Encoder\JsonEncoder' ] - - Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor: ~ - - Symfony\Component\Serializer\Normalizer\ArrayDenormalizer: ~ - - Symfony\Component\Serializer\Encoder\JsonEncoder: ~ - - Symfony\Component\PropertyInfo\PropertyTypeExtractorInterface: '@Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor' - diff --git a/src/Resources/services.yml b/src/Resources/services.yml index 10b30381..4649a347 100644 --- a/src/Resources/services.yml +++ b/src/Resources/services.yml @@ -1,6 +1,5 @@ imports: - { resource: factories.yml } - - { resource: library_services.yml } - { resource: core_services.yml } - { resource: api.yml } - { resource: api_client.yml } @@ -15,24 +14,5 @@ services: autoconfigure: true public: false - SupportPal\ApiClient\Normalizer\ModelNormalizer: - arguments: - $normalizer: '@Symfony\Component\Serializer\Normalizer\ObjectNormalizer' - $transformers: !tagged transformer.field_transformer - $attributeAwareTransformers: !tagged attribute_aware_transformer.field_transformer - tags: [ 'serializer.normalizer' ] - - SupportPal\ApiClient\Transformer\StringTrimTransformer: - tags: [ 'transformer.field_transformer' ] - - SupportPal\ApiClient\Transformer\EmptyModelToNullTransformer: - tags: [ 'transformer.field_transformer' ] - - SupportPal\ApiClient\Transformer\BooleanToIntTransformer: - tags: [ 'transformer.field_transformer' ] - - SupportPal\ApiClient\Transformer\IntToBooleanTransformer: - tags: [ 'attribute_aware_transformer.field_transformer' ] - diff --git a/test/ApiTestCase.php b/test/ApiTestCase.php index 841bf30d..d952c981 100644 --- a/test/ApiTestCase.php +++ b/test/ApiTestCase.php @@ -12,6 +12,7 @@ use function call_user_func_array; use function get_class; +use function json_encode; abstract class ApiTestCase extends ContainerAwareBaseTestCase { @@ -28,7 +29,7 @@ public function testGetEndpoint(array $data, string $functionName, array $parame new Response( 200, [], - (string) $this->getEncoder()->encode($data, $this->getFormatType()) + json_encode($data) ) ); @@ -48,7 +49,7 @@ public function testGetEndpoint(array $data, string $functionName, array $parame public function testSuccessfulPostModel(Model $model, array $responseData, string $functionName): void { /** @var string $jsonSuccessfulBody */ - $jsonSuccessfulBody = $this->getEncoder()->encode($responseData, $this->getFormatType()); + $jsonSuccessfulBody = json_encode($responseData); $this->appendRequestResponse(new Response(200, [], $jsonSuccessfulBody)); /** @var callable $callable */ $callable = [$this->getApi(), $functionName]; @@ -71,7 +72,7 @@ public function testSuccessfulPutModel( string $functionName ): void { /** @var string $jsonSuccessfulBody */ - $jsonSuccessfulBody = $this->getEncoder()->encode($responseData, $this->getFormatType()); + $jsonSuccessfulBody = json_encode($responseData); $this->appendRequestResponse(new Response(200, [], $jsonSuccessfulBody)); /** @var callable $callable */ $callable = [$this->getApi(), $functionName]; @@ -164,7 +165,7 @@ public function testMissingIdentifierPostModel( self::expectException(MissingIdentifierException::class); /** @var string $jsonSuccessfulBody */ - $jsonSuccessfulBody = $this->getEncoder()->encode($responseData, $this->getFormatType()); + $jsonSuccessfulBody = json_encode($responseData); $this->appendRequestResponse(new Response(200, [], $jsonSuccessfulBody)); /** @var callable $callable */ $callable = [$this->getApi(), $functionName]; diff --git a/test/ContainerAwareBaseTestCase.php b/test/ContainerAwareBaseTestCase.php index 2de721f7..0a02dc66 100644 --- a/test/ContainerAwareBaseTestCase.php +++ b/test/ContainerAwareBaseTestCase.php @@ -16,10 +16,8 @@ use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\Serializer\Encoder\DecoderInterface; -use Symfony\Component\Serializer\Encoder\EncoderInterface; -use Symfony\Component\Serializer\Encoder\JsonEncoder; +use function json_decode; use function json_encode; /** @@ -118,41 +116,6 @@ protected function getContainer(): ContainerBuilder return $this->container; } - /** - * @return EncoderInterface - * @throws Exception - */ - protected function getEncoder(): EncoderInterface - { - /** @var EncoderInterface $encoder */ - $encoder = $this->container->get(JsonEncoder::class); - - return $encoder; - } - - /** - * @return DecoderInterface - * @throws Exception - */ - protected function getDecoder(): DecoderInterface - { - /** @var DecoderInterface $decoder */ - $decoder = $this->container->get(JsonEncoder::class); - - return $decoder; - } - - /** - * @return string - */ - protected function getFormatType(): string - { - /** @var string $contentType */ - $contentType = $this->container->getParameter('contentType'); - - return $contentType; - } - /** * @param Response $response */ @@ -180,7 +143,7 @@ protected function prepareUnsuccessfulApiRequest(Response $response): void $this->appendRequestResponse($response); self::expectException(HttpResponseException::class); self::expectExceptionMessage( - $this->getDecoder()->decode((string) $response->getBody(), $this->getFormatType())['message'] + json_decode((string) $response->getBody(), true)['message'] ); } diff --git a/test/Functional/SupportPalTest.php b/test/Functional/SupportPalTest.php index c2295a0b..292d9593 100644 --- a/test/Functional/SupportPalTest.php +++ b/test/Functional/SupportPalTest.php @@ -13,6 +13,7 @@ use function base64_encode; use function current; +use function json_encode; /** * Class SupportPalTest @@ -30,7 +31,7 @@ public function testSendRequestSuccessful(): void $response = new Response( 200, [], - (string) $this->getEncoder()->encode((new CommentData)->getResponse(), $this->getFormatType()) + (string) json_encode((new CommentData)->getResponse()) ); $this->appendRequestResponse($response); $request = $this->getSupportPal()->getRequestFactory()->create('GET', 'test_endpoint'); @@ -43,7 +44,7 @@ public function testSendRequestUnSuccessful(): void $response = new Response( 200, [], - (string) $this->getEncoder()->encode($this->genericErrorResponse, $this->getFormatType()) + (string) json_encode($this->genericErrorResponse) ); $this->appendRequestResponse($response); $request = $this->getSupportPal()->getRequestFactory()->create('GET', 'test_endpoint'); diff --git a/test/Resources/services_test.yml b/test/Resources/services_test.yml index f605412c..c0bde52e 100644 --- a/test/Resources/services_test.yml +++ b/test/Resources/services_test.yml @@ -5,7 +5,6 @@ parameters: apiUrl: 'localhost:8080/api/' apiToken: 'test2' apiContentType: 'test3' - contentType: 'json' defaultBodyContent: test: 'test' defaultParameters: @@ -25,140 +24,105 @@ services: $contentType: '%apiContentType%' $defaultBodyContent: '%defaultBodyContent%' $defaultParameters: '%defaultParameters%' - $formatType: '%contentType%' SupportPal\ApiClient\ApiClient: public: true arguments: $httpClient: '@GuzzleHttp\Client' - $formatType: '%contentType%' - - Symfony\Component\Serializer\Encoder\JsonEncoder: - public: true SupportPal\ApiClient\Factory\SelfService\TypeFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\User\UserFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\SelfService\ArticleFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\SelfService\CategoryFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\Ticket\DepartmentFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\SelfService\CommentFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\Shared\SettingsFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\Ticket\ChannelSettingsFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\SelfService\TagFactory: public: true tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' SupportPal\ApiClient\Factory\Ticket\CustomFieldFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\PriorityFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\StatusFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\AttachmentFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\TicketFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Ticket\MessageFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Core\BrandFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\User\GroupFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\User\UserCustomFieldFactory: public: true - parent: 'SupportPal\ApiClient\Factory\BaseModelFactory' + parent: 'SupportPal\ApiClient\Factory\ModelFactory' tags: [ 'factory.model_factory' ] SupportPal\ApiClient\Factory\Collection\CollectionFactory: public: true - SupportPal\ApiClient\Converter\ModelToArrayConverter: - public: true - arguments: - $format: '%contentType%' - - Symfony\Component\Serializer\Serializer: - public: true - arguments: - - [ '@SupportPal\ApiClient\Normalizer\ModelNormalizer', '@Symfony\Component\Serializer\Normalizer\ObjectNormalizer', '@Symfony\Component\Serializer\Normalizer\ArrayDenormalizer' ] - - [ '@Symfony\Component\Serializer\Encoder\JsonEncoder' ] - - SupportPal\ApiClient\Normalizer\ModelNormalizer: - public: true - arguments: - $normalizer: '@Symfony\Component\Serializer\Normalizer\ObjectNormalizer' - $transformers: !tagged transformer.field_transformer - $attributeAwareTransformers: !tagged attribute_aware_transformer.field_transformer - - SupportPal\ApiClient\Transformer\StringTrimTransformer: - tags: [ 'transformer.field_transformer' ] - - SupportPal\ApiClient\Transformer\EmptyModelToNullTransformer: - tags: [ 'transformer.field_transformer' ] - - SupportPal\ApiClient\Transformer\BooleanToIntTransformer: - tags: [ 'transformer.field_transformer' ] - - SupportPal\ApiClient\Transformer\IntToBooleanTransformer: - tags: [ 'attribute_aware_transformer.field_transformer' ] - SupportPal\ApiClient\Factory\ModelCollectionFactory: public: true arguments: diff --git a/test/TestCase.php b/test/TestCase.php index b86e7483..a0336c55 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -30,8 +30,7 @@ class TestCase extends \PHPUnit\Framework\TestCase protected function assertArrayEqualsObjectFields(object $obj, array $array): void { foreach ($array as $key => $value) { - $method = 'get'.$this->snakeCaseToPascalCase($key); - $attributeValue = $obj->{$method}(); + $attributeValue = $obj->{$key}; /** * assert against nested objects recursively * @example @@ -103,11 +102,11 @@ protected function assertApiDataMatchesModels(Model|Collection $models, array $d return; } - if ($models instanceof Model) { - $this->assertArrayEqualsObjectFields($models, $data['data']); - + if (! ($models instanceof Model)) { return; } + + $this->assertArrayEqualsObjectFields($models, $data['data']); } /** diff --git a/test/Unit/Api/SelfService/CommentApisTest.php b/test/Unit/Api/SelfService/CommentApisTest.php index 724d5818..3f76dff8 100644 --- a/test/Unit/Api/SelfService/CommentApisTest.php +++ b/test/Unit/Api/SelfService/CommentApisTest.php @@ -4,7 +4,6 @@ use SupportPal\ApiClient\Api\SelfServiceApi; use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; -use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Model\SelfService\Comment; use SupportPal\ApiClient\Model\SelfService\Request\CreateComment; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; @@ -28,31 +27,20 @@ public function testPostComment(): void { $commentData = new CommentData; $arrayData = $commentData->getArrayData(); - [$response, $commentMock, $commentOutput] = $this->postCommonExpectations( + [$response, $commentOutput] = $this->postCommonExpectations( $commentData->getResponse(), - $arrayData, - CreateComment::class, Comment::class ); - $this - ->apiClient + $this->apiClient ->postComment($arrayData) ->shouldBeCalled() ->willReturn($response->reveal()); - $comment = $this->api->postComment($commentMock); + $comment = $this->api->postComment(new CreateComment($arrayData)); self::assertSame($commentOutput->reveal(), $comment); } - public function testPostCommentWithIncompleteData(): void - { - /** @var CreateComment $commentMock */ - $commentMock = $this->postIncompleteDataCommonExpectations(CreateComment::class); - self::expectException(InvalidArgumentException::class); - $this->api->postComment($commentMock); - } - public function testGetComments(): void { [$expectedOutput, $response] = $this->makeCommonExpectations( diff --git a/test/Unit/Api/Ticket/AttachmentApisTest.php b/test/Unit/Api/Ticket/AttachmentApisTest.php index 33b53a27..ab98f23b 100644 --- a/test/Unit/Api/Ticket/AttachmentApisTest.php +++ b/test/Unit/Api/Ticket/AttachmentApisTest.php @@ -57,16 +57,12 @@ public function testGetAttachment(): void public function testDownloadAttachment(): void { - $attachment = $this->prophesize(Attachment::class); - $attachment->getId()->shouldBeCalled()->willReturn(1); $response = $this->prophesize(ResponseInterface::class); $stream = $this->prophesize(StreamInterface::class); $response->getBody()->shouldBeCalled()->willReturn($stream->reveal()); $this->apiClient->downloadAttachment(1)->shouldBeCalled()->willReturn($response->reveal()); - /** @var Attachment $attachmentModel */ - $attachmentModel = $attachment->reveal(); - $this->api->downloadAttachment($attachmentModel); + $this->api->downloadAttachment(new Attachment(['id' => 1])); } /** diff --git a/test/Unit/Api/Ticket/MessageApisTest.php b/test/Unit/Api/Ticket/MessageApisTest.php index 2700fd8d..b8c34cd4 100644 --- a/test/Unit/Api/Ticket/MessageApisTest.php +++ b/test/Unit/Api/Ticket/MessageApisTest.php @@ -4,7 +4,6 @@ use SupportPal\ApiClient\Api\TicketApi; use SupportPal\ApiClient\ApiClient\TicketApiClient; -use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Model\Ticket\Message; use SupportPal\ApiClient\Model\Ticket\Request\CreateMessage; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\MessageData; @@ -63,10 +62,8 @@ public function testPostMessage(): void $messageData = new MessageData; $arrayData = $messageData->getArrayData(); - [$response, $messageMock, $messageOutput] = $this->postCommonExpectations( + [$response, $messageOutput] = $this->postCommonExpectations( $messageData->getResponse(), - $arrayData, - CreateMessage::class, Message::class ); @@ -76,18 +73,10 @@ public function testPostMessage(): void ->shouldBeCalled() ->willReturn($response->reveal()); - $message = $this->api->postMessage($messageMock); + $message = $this->api->postMessage(new CreateMessage($arrayData)); self::assertSame($messageOutput->reveal(), $message); } - public function testPostWithIncompleteData(): void - { - /** @var CreateMessage $messageMock */ - $messageMock = $this->postIncompleteDataCommonExpectations(CreateMessage::class); - self::expectException(InvalidArgumentException::class); - $this->api->postMessage($messageMock); - } - /** * @inheritDoc */ diff --git a/test/Unit/Api/Ticket/TicketApisTest.php b/test/Unit/Api/Ticket/TicketApisTest.php index ee274fb4..4edc5d2b 100644 --- a/test/Unit/Api/Ticket/TicketApisTest.php +++ b/test/Unit/Api/Ticket/TicketApisTest.php @@ -4,7 +4,6 @@ use SupportPal\ApiClient\Api\TicketApi; use SupportPal\ApiClient\ApiClient\TicketApiClient; -use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; use SupportPal\ApiClient\Model\Ticket\Request\CreateTicket; use SupportPal\ApiClient\Model\Ticket\Ticket; @@ -62,10 +61,8 @@ public function testPostTicket(): void $ticketData = new TicketData; $createTicketData = new CreateTicketData; $arrayData = $createTicketData::DATA; - [$response, $ticketMock, $ticketOutput] = $this->postCommonExpectations( + [$response, $ticketOutput] = $this->postCommonExpectations( $ticketData->getResponse(), - $arrayData, - CreateTicket::class, Ticket::class ); @@ -75,23 +72,15 @@ public function testPostTicket(): void ->shouldBeCalled() ->willReturn($response->reveal()); - $ticket = $this->api->postTicket($ticketMock); + $ticket = $this->api->postTicket(new CreateTicket($arrayData)); self::assertSame($ticketOutput->reveal(), $ticket); } - public function testPostWithIncompleteData(): void - { - /** @var CreateTicket $ticket */ - $ticket = $this->postIncompleteDataCommonExpectations(CreateTicket::class); - self::expectException(InvalidArgumentException::class); - $this->api->postTicket($ticket); - } - public function testPutTicket(): void { $ticketData = new TicketData; - [$response, $inputMock, $output] = $this->putCommonExpectations( + [$response, $output] = $this->putCommonExpectations( Ticket::class, $ticketData->getResponse() ); @@ -102,7 +91,7 @@ public function testPutTicket(): void ->willReturn($response->reveal()) ->shouldBeCalled(); - $ticket = $this->api->updateTicket($inputMock, $ticketData->getArrayData()); + $ticket = $this->api->updateTicket(new Ticket(['id' => self::TEST_ID]), $ticketData->getArrayData()); self::assertSame($output->reveal(), $ticket); } @@ -110,7 +99,6 @@ public function testPutTicketWithoutIdentifier(): void { $ticketData = new TicketData; $input = $this->prophesize(Ticket::class); - $input->getId()->willReturn(null)->shouldBeCalled(); self::expectException(MissingIdentifierException::class); /** @var Ticket $ticket */ $ticket = $input->reveal(); diff --git a/test/Unit/Api/User/UserApisTest.php b/test/Unit/Api/User/UserApisTest.php index 3e548aa7..8741d858 100644 --- a/test/Unit/Api/User/UserApisTest.php +++ b/test/Unit/Api/User/UserApisTest.php @@ -4,7 +4,6 @@ use SupportPal\ApiClient\Api\UserApi; use SupportPal\ApiClient\ApiClient\UserApiClient; -use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; use SupportPal\ApiClient\Model\User\Request\CreateUser; use SupportPal\ApiClient\Model\User\User; @@ -61,10 +60,8 @@ public function testPostUser(): void $userData = new UserData; $createUserData = new CreateUserData; $arrayData = $createUserData::DATA; - [$response, $userMock, $userOutput] = $this->postCommonExpectations( + [$response, $userOutput] = $this->postCommonExpectations( $userData->getResponse(), - $arrayData, - CreateUser::class, User::class ); @@ -74,23 +71,15 @@ public function testPostUser(): void ->shouldBeCalled() ->willReturn($response->reveal()); - $user = $this->api->postUser($userMock); + $user = $this->api->postUser(new CreateUser($arrayData)); self::assertSame($userOutput->reveal(), $user); } - public function testPostWithIncompleteData(): void - { - /** @var CreateUser $user */ - $user = $this->postIncompleteDataCommonExpectations(CreateUser::class); - self::expectException(InvalidArgumentException::class); - $this->api->postUser($user); - } - public function testPutUser(): void { $userData = new UserData; - [$response, $inputMock, $output] = $this->putCommonExpectations( + [$response, $output] = $this->putCommonExpectations( User::class, $userData->getResponse() ); @@ -101,7 +90,7 @@ public function testPutUser(): void ->willReturn($response->reveal()) ->shouldBeCalled(); - $user = $this->api->updateUser($inputMock, $userData->getArrayData()); + $user = $this->api->updateUser(new User(['id' => self::TEST_ID]), $userData->getArrayData()); self::assertSame($output->reveal(), $user); } @@ -109,7 +98,6 @@ public function testPutUserWithoutIdentifier(): void { $userData = new UserData; $input = $this->prophesize(User::class); - $input->getId()->willReturn(null)->shouldBeCalled(); self::expectException(MissingIdentifierException::class); /** @var User $user */ $user = $input->reveal(); diff --git a/test/Unit/ApiClientTest.php b/test/Unit/ApiClientTest.php index ecb87a98..897f7584 100644 --- a/test/Unit/ApiClientTest.php +++ b/test/Unit/ApiClientTest.php @@ -16,10 +16,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Factory\RequestFactory; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; -use Symfony\Component\Serializer\Encoder\DecoderInterface; -use Symfony\Component\Serializer\Exception\NotEncodableValueException; -use function json_decode; use function json_encode; /** @@ -47,33 +44,22 @@ class ApiClientTest extends TestCase /** @var ApiClient */ protected $apiClient; - /** @var ObjectProphecy|DecoderInterface */ - protected $decoder; - - /** @var string */ - protected $formatType = 'json'; - protected function setUp(): void { parent::setUp(); $this->httpClient = $this->prophesize(ClientInterface::class); $this->requestFactory = $this->prophesize(RequestFactory::class); - $this->decoder = $this->prophesize(DecoderInterface::class); /** @var Client $httpClient */ $httpClient = $this->httpClient->reveal(); /** @var RequestFactory $requestFactory */ $requestFactory = $this->requestFactory->reveal(); - /** @var DecoderInterface $decoder */ - $decoder = $this->decoder->reveal(); $apiClassName = $this->getApiClientName(); $this->apiClient = new $apiClassName( $httpClient, $requestFactory, - $decoder, - 'json' ); } @@ -107,11 +93,6 @@ public function testResponseNonEncodeableException(): void $response->getBody()->willReturn(''); - $this->decoder - ->decode('', $this->formatType) - ->shouldBeCalled() - ->willThrow(NotEncodableValueException::class); - /** @var RequestInterface $requestMock */ $requestMock = $request->reveal(); $this->apiClient->sendRequest($requestMock); @@ -182,11 +163,6 @@ protected function sendRequestCommonExpectations( $response->getStatusCode()->willReturn($statusCode); $response->getBody()->willReturn($responseBody); $this->httpClient->sendRequest($request->reveal())->shouldBeCalled()->willReturn($response->reveal()); - $this - ->decoder - ->decode($responseBody, $this->formatType) - ->shouldBeCalled() - ->willReturn(json_decode($responseBody, true)); return $response; } diff --git a/test/Unit/ApiTest.php b/test/Unit/ApiTest.php index 05109038..3f4f2512 100644 --- a/test/Unit/ApiTest.php +++ b/test/Unit/ApiTest.php @@ -6,15 +6,10 @@ use Psr\Http\Message\ResponseInterface; use SupportPal\ApiClient\Api\Api; use SupportPal\ApiClient\ApiClient; -use SupportPal\ApiClient\Converter\ModelToArrayConverter; -use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Factory\Collection\CollectionFactory; use SupportPal\ApiClient\Factory\ModelCollectionFactory; use SupportPal\ApiClient\Model\Collection\Collection; -use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Tests\TestCase; -use Symfony\Component\PropertyAccess\Exception\UninitializedPropertyException; -use Symfony\Component\Serializer\Encoder\DecoderInterface; use function array_push; use function current; @@ -30,9 +25,6 @@ abstract class ApiTest extends TestCase { protected const TEST_ID = 1; - /** @var ObjectProphecy|ModelToArrayConverter */ - protected $modelToArrayConverter; - /** @var ObjectProphecy|ApiClient */ protected $apiClient; @@ -45,9 +37,6 @@ abstract class ApiTest extends TestCase /** @var Api */ protected $api; - /** @var ObjectProphecy|DecoderInterface */ - protected $decoder; - /** @var ObjectProphecy|CollectionFactory */ private $collectionFactory; @@ -57,19 +46,12 @@ abstract class ApiTest extends TestCase protected function setUp(): void { parent::setUp(); - $this->modelToArrayConverter = $this->prophesize(ModelToArrayConverter::class); $this->apiClient = $this->prophesize($this->getApiClientName()); - $this->serializationType = 'json'; $this->modelCollectionFactory = $this->prophesize(ModelCollectionFactory::class); - $this->decoder = $this->prophesize(DecoderInterface::class); $this->collectionFactory = $this->prophesize(CollectionFactory::class); - /** @var ModelToArrayConverter $modelToArrayConverter */ - $modelToArrayConverter = $this->modelToArrayConverter->reveal(); /** @var ApiClient $apiClient */ $apiClient = $this->apiClient->reveal(); - /** @var DecoderInterface $decoder */ - $decoder = $this->decoder->reveal(); /** @var ModelCollectionFactory $modelCollectionFactory */ $modelCollectionFactory = $this->modelCollectionFactory->reveal(); /** @var CollectionFactory $collectionFactory */ @@ -77,10 +59,7 @@ protected function setUp(): void $apiName = $this->getApiName(); $this->api = new $apiName( - $modelToArrayConverter, $modelCollectionFactory, - $this->serializationType, - $decoder, $collectionFactory, $apiClient ); @@ -94,16 +73,10 @@ protected function setUp(): void protected function makeCommonExpectations(array $responseData, string $expectedClass): array { $response = $this->prophesize(ResponseInterface::class); - $formatType = 'json'; $response ->getBody() ->willReturn(json_encode($responseData)); - $this->decoder - ->decode(json_encode($responseData), $formatType) - ->shouldBeCalled() - ->willReturn($responseData); - if (is_array(current($responseData['data']))) { $models = []; foreach ($responseData['data'] as $value) { @@ -143,59 +116,20 @@ protected function makeCommonExpectations(array $responseData, string $expectedC */ protected function postCommonExpectations( array $responseData, - array $modelArrayData, - string $className, ?string $outputClassName = null ): array { - $input = $this->prophesize($className); - $output = $this->prophesize($outputClassName ?? $className); - - /** @var Model $inputMock */ - $inputMock = $input->reveal(); - - $this - ->modelToArrayConverter - ->convertOne($inputMock) - ->willReturn($modelArrayData) - ->shouldBeCalled(); - - $this->decoder - ->decode(json_encode($responseData), $this->formatType) - ->shouldBeCalled() - ->willReturn($responseData); - - $this - ->modelCollectionFactory - ->create($outputClassName ?? $className, $responseData['data']) - ->willReturn($output); + $output = $this->prophesize($outputClassName); $response = $this->prophesize(ResponseInterface::class); $response ->getBody() ->willReturn(json_encode($responseData)); - return [$response, $inputMock, $output]; - } - - /** - * @param class-string $className - * @return Model - */ - protected function postIncompleteDataCommonExpectations(string $className): Model - { - $input = $this->prophesize($className); - /** @var Model $inputMock */ - $inputMock = $input->reveal(); - - $this - ->modelToArrayConverter - ->convertOne($inputMock) - ->willThrow(UninitializedPropertyException::class) - ->shouldBeCalled(); - - self::expectException(InvalidArgumentException::class); + $this->modelCollectionFactory + ->create($outputClassName, $responseData['data']) + ->willReturn($output); - return $inputMock; + return [$response, $output]; } /** @@ -207,20 +141,9 @@ protected function putCommonExpectations( string $className, array $responseData ): array { - $input = $this->prophesize($className); $output = $this->prophesize($className); - $input->getId()->willReturn(self::TEST_ID); - /** @var Model $inputMock */ - $inputMock = $input->reveal(); - - $this->decoder - ->decode(json_encode($responseData), $this->formatType) - ->shouldBeCalled() - ->willReturn($responseData); - - $this - ->modelCollectionFactory + $this->modelCollectionFactory ->create($className, $responseData['data']) ->willReturn($output); @@ -229,7 +152,7 @@ protected function putCommonExpectations( ->getBody() ->willReturn(json_encode($responseData)); - return [$response, $inputMock, $output]; + return [$response, $output]; } /** diff --git a/test/Unit/Converter/ModelToArrayConverterTest.php b/test/Unit/Converter/ModelToArrayConverterTest.php deleted file mode 100644 index 5fdb715f..00000000 --- a/test/Unit/Converter/ModelToArrayConverterTest.php +++ /dev/null @@ -1,54 +0,0 @@ -serializer = $this->prophesize(SerializerInterface::class); - $this->decoder = $this->prophesize(DecoderInterface::class); - - /** @var SerializerInterface $serializer */ - $serializer = $this->serializer->reveal(); - /** @var DecoderInterface $decoder */ - $decoder = $this->decoder->reveal(); - $this->modelToArrayConverter = new ModelToArrayConverter($serializer, $decoder, 'json'); - } - - public function testConvertModel(): void - { - $modelProphecy = $this->prophesize(Model::class); - $expectation = ['test' => 'test']; - $this->serializer->serialize($modelProphecy->reveal(), 'json')->shouldBeCalled()->willReturn('{test}'); - $this->decoder->decode('{test}', 'json')->willReturn($expectation)->shouldBeCalled(); - - /** @var Model $model */ - $model = $modelProphecy->reveal(); - $actual = $this->modelToArrayConverter->convertOne($model); - self::assertSame($expectation, $actual); - } -} diff --git a/test/Unit/Factory/BaseModelFactoryTest.php b/test/Unit/Factory/BaseModelFactoryTest.php index 84706725..4f4fc337 100644 --- a/test/Unit/Factory/BaseModelFactoryTest.php +++ b/test/Unit/Factory/BaseModelFactoryTest.php @@ -2,7 +2,6 @@ namespace SupportPal\ApiClient\Tests\Unit\Factory; -use SupportPal\ApiClient\Factory\BaseModelFactory; use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\SelfService\Comment; @@ -11,7 +10,7 @@ /** * Class BaseModelFactoryTest * @package SupportPal\ApiClient\Tests\Unit\Factory - * @covers \SupportPal\ApiClient\Factory\BaseModelFactory + * @covers \SupportPal\ApiClient\Factory\ModelFactory */ class BaseModelFactoryTest extends BaseModelFactoryTestCase { @@ -44,10 +43,7 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - $mock = $this->getMockForAbstractClass( - BaseModelFactory::class, - [$this->format, $this->getSerializer(), $this->getEncoder()] - ); + $mock = $this->getMockForAbstractClass(ModelFactory::class); $mock->expects($this->any()) ->method('getModel') diff --git a/test/Unit/Factory/BaseModelFactoryTestCase.php b/test/Unit/Factory/BaseModelFactoryTestCase.php index 1c147372..c7ec6d87 100644 --- a/test/Unit/Factory/BaseModelFactoryTestCase.php +++ b/test/Unit/Factory/BaseModelFactoryTestCase.php @@ -3,17 +3,10 @@ namespace SupportPal\ApiClient\Tests\Unit\Factory; use PHPUnit\Framework\TestCase; -use Prophecy\Prophecy\ObjectProphecy; -use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Helper\StringHelper; use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Tests\FactoryTestCase; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; -use Symfony\Component\Serializer\Encoder\EncoderInterface; -use Symfony\Component\Serializer\Exception\UnexpectedValueException; -use Symfony\Component\Serializer\SerializerInterface; - -use function json_encode; /** * Class BaseModelFactoryTestCase @@ -26,76 +19,12 @@ abstract class BaseModelFactoryTestCase extends TestCase use PhpUnitCompatibilityTrait; use StringHelper; - /** @var ObjectProphecy|SerializerInterface */ - protected $serializer; - - /** @var string */ - protected $format = 'json'; - - /** @var ObjectProphecy|EncoderInterface */ - private $encoder; - - protected function setUp(): void - { - parent::setUp(); - $this->serializer = $this->prophesize(SerializerInterface::class); - $this->encoder = $this->prophesize(EncoderInterface::class); - } - public function testCreateModel(): void { - $this->encoder->encode($this->getModelData(), $this->format)->willReturn(json_encode($this->getModelData())); - $this->serializer - ->deserialize(json_encode($this->getModelData()), $this->getModel(), $this->format) - ->shouldBeCalled() - ->willReturn($this->getModelInstance()); - $model = $this->getModelFactory()->create($this->getModelData()); self::assertInstanceOf($this->getModel(), $model); } - public function testCreateWithFailedDeserialize(): void - { - $this->encoder->encode($this->getModelData(), $this->format)->willReturn(json_encode($this->getModelData())); - $this->serializer - ->deserialize(json_encode($this->getModelData()), $this->getModel(), $this->format) - ->shouldBeCalled() - ->willThrow(InvalidArgumentException::class); - self::expectException(InvalidArgumentException::class); - $this->getModelFactory()->create($this->getModelData()); - } - - public function testCreateWithFailedEncode(): void - { - $this->encoder - ->encode($this->getModelData(), $this->format) - ->willThrow(UnexpectedValueException::class); - self::expectException(InvalidArgumentException::class); - $this->getModelFactory()->create($this->getModelData()); - } - - /** - * @return SerializerInterface - */ - protected function getSerializer(): SerializerInterface - { - /** @var SerializerInterface $serializer */ - $serializer = $this->serializer->reveal(); - - return $serializer; - } - - /** - * @return EncoderInterface - */ - protected function getEncoder(): EncoderInterface - { - /** @var EncoderInterface $encoder */ - $encoder = $this->encoder->reveal(); - - return $encoder; - } - /** * @return Model */ diff --git a/test/Unit/Factory/Core/BrandFactoryTest.php b/test/Unit/Factory/Core/BrandFactoryTest.php index ea60b850..91422d7b 100644 --- a/test/Unit/Factory/Core/BrandFactoryTest.php +++ b/test/Unit/Factory/Core/BrandFactoryTest.php @@ -40,10 +40,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new BrandFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new BrandFactory; } } diff --git a/test/Unit/Factory/ModelCollectionFactoryTest.php b/test/Unit/Factory/ModelCollectionFactoryTest.php index 060de722..20c2406f 100644 --- a/test/Unit/Factory/ModelCollectionFactoryTest.php +++ b/test/Unit/Factory/ModelCollectionFactoryTest.php @@ -11,7 +11,7 @@ use SupportPal\ApiClient\Factory\ModelFactory; use SupportPal\ApiClient\Factory\SelfService\CommentFactory; use SupportPal\ApiClient\Factory\Shared\SettingsFactory; -use SupportPal\ApiClient\Model\BaseModel; +use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\SelfService\Comment; use SupportPal\ApiClient\Model\Shared\Settings; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; @@ -65,7 +65,7 @@ public function testCreateWithInvalidFactory(): void public function testCreateWithUnsupportedModel(): void { self::expectException(NotSupportedException::class); - $this->modelCollectionFactory->create(BaseModel::class, ['test' => 'test']); + $this->modelCollectionFactory->create(Model::class, [ 'test' => 'test']); } /** diff --git a/test/Unit/Factory/RequestFactoryTest.php b/test/Unit/Factory/RequestFactoryTest.php index 6e670138..abc78de3 100644 --- a/test/Unit/Factory/RequestFactoryTest.php +++ b/test/Unit/Factory/RequestFactoryTest.php @@ -4,15 +4,13 @@ use GuzzleHttp\Psr7\Request; use PHPUnit\Framework\TestCase; -use Prophecy\Argument; -use Prophecy\Prophecy\ObjectProphecy; use SupportPal\ApiClient\Factory\RequestFactory; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; -use Symfony\Component\Serializer\Encoder\EncoderInterface; use function array_merge; use function base64_encode; use function http_build_query; +use function json_decode; use function json_encode; /** @@ -27,16 +25,11 @@ class RequestFactoryTest extends TestCase /** @var RequestFactory */ private $requestFactory; - /** @var ObjectProphecy|EncoderInterface */ - private $encoder; - protected function setUp(): void { parent::setUp(); - $this->encoder = $this->prophesize(EncoderInterface::class); - /** @var EncoderInterface $encoder */ - $encoder = $this->encoder->reveal(); - $this->requestFactory = new RequestFactory('test', 'test', 'test', 'json', $encoder); + + $this->requestFactory = new RequestFactory('test', 'test', 'test'); } /** @@ -46,7 +39,6 @@ protected function setUp(): void public function testCreateRequestWithBody(array $data): void { $encodedBody = json_encode($data['body']); - $this->encoder->encode($data['body'], 'json')->shouldBeCalled()->willReturn($encodedBody); $request = $this->requestFactory->create( $data['method'], @@ -72,7 +64,6 @@ public function testCreateRequestWithBody(array $data): void */ public function testCreateRequestWithoutBody(array $data): void { - $this->encoder->encode(Argument::any())->shouldNotBeCalled(); $request = $this->requestFactory->create( $data['method'], $data['endpoint'], @@ -100,7 +91,7 @@ public function testDefaultValues(array $data): void $defaultParameters = ['testparams' => 'value', 'test_data2' => 'not_overwriten']; $defaultBody = ['testbody' => 'value', 'test_data2' => 'not_overwriten']; - $expectedBody = array_merge($data['body'], $defaultBody); + $expectedBody = array_merge($defaultBody, $data['body']); [$encodedBody, $headersArray, $request] = $this ->commonCreateRequest($expectedBody, $defaultBody, $defaultParameters, $data); @@ -108,7 +99,7 @@ public function testDefaultValues(array $data): void self::assertSame($data['method'], $request->getMethod()); self::assertSame('test' . $data['endpoint'], $request->getUri()->getPath()); self::assertEquals($headersArray, $request->getHeaders()); - self::assertSame($encodedBody, $request->getBody()->getContents()); + self::assertSame($encodedBody, json_decode($request->getBody()->getContents(), true)); self::assertSame( http_build_query(array_merge($defaultParameters, $data['parameters'])), $request->getUri()->getQuery() @@ -137,7 +128,7 @@ public function testProvidedDataOverwritesDefaults(): void self::assertSame($data['method'], $request->getMethod()); self::assertSame('test' . $data['endpoint'], $request->getUri()->getPath()); self::assertEquals($headersArray, $request->getHeaders()); - self::assertSame($encodedBody, $request->getBody()->getContents()); + self::assertSame($encodedBody, json_decode($request->getBody()->getContents(), true)); self::assertSame( http_build_query(array_merge($defaultParameters, $data['parameters'])), $request->getUri()->getQuery() @@ -221,18 +212,10 @@ private function commonCreateRequest( array $defaultParameters, array $data ): array { - $encodedBody = json_encode($expectedBody); - $encoder = $this->prophesize(EncoderInterface::class); - $encoder->encode($expectedBody, 'json')->shouldBeCalled()->willReturn($encodedBody); - - /** @var EncoderInterface $encoder */ - $encoder = $encoder->reveal(); $requestFactory = new RequestFactory( 'test', 'test', 'test', - 'json', - $encoder, $defaultBody, $defaultParameters ); @@ -246,6 +229,6 @@ private function commonCreateRequest( $data['parameters'] ); - return [$encodedBody, $headersArray, $request]; + return [$expectedBody, $headersArray, $request]; } } diff --git a/test/Unit/Factory/SelfService/ArticleFactoryTest.php b/test/Unit/Factory/SelfService/ArticleFactoryTest.php index dd34b47d..8ceb5045 100644 --- a/test/Unit/Factory/SelfService/ArticleFactoryTest.php +++ b/test/Unit/Factory/SelfService/ArticleFactoryTest.php @@ -21,11 +21,7 @@ class ArticleFactoryTest extends BaseModelFactoryTestCase */ protected function getModelFactory(): ModelFactory { - return new ArticleFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new ArticleFactory; } /** diff --git a/test/Unit/Factory/SelfService/CategoryFactoryTest.php b/test/Unit/Factory/SelfService/CategoryFactoryTest.php index 49c0b268..2dbe3238 100644 --- a/test/Unit/Factory/SelfService/CategoryFactoryTest.php +++ b/test/Unit/Factory/SelfService/CategoryFactoryTest.php @@ -21,11 +21,7 @@ class CategoryFactoryTest extends BaseModelFactoryTestCase */ protected function getModelFactory(): ModelFactory { - return new CategoryFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new CategoryFactory; } /** diff --git a/test/Unit/Factory/SelfService/CommentFactoryTest.php b/test/Unit/Factory/SelfService/CommentFactoryTest.php index 62102f86..2bf5a710 100644 --- a/test/Unit/Factory/SelfService/CommentFactoryTest.php +++ b/test/Unit/Factory/SelfService/CommentFactoryTest.php @@ -21,11 +21,7 @@ class CommentFactoryTest extends BaseModelFactoryTestCase */ protected function getModelFactory(): ModelFactory { - return new CommentFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new CommentFactory; } /** diff --git a/test/Unit/Factory/SelfService/TagFactoryTest.php b/test/Unit/Factory/SelfService/TagFactoryTest.php index b77caf35..a2d7da27 100644 --- a/test/Unit/Factory/SelfService/TagFactoryTest.php +++ b/test/Unit/Factory/SelfService/TagFactoryTest.php @@ -21,11 +21,7 @@ class TagFactoryTest extends BaseModelFactoryTestCase */ protected function getModelFactory(): ModelFactory { - return new TagFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new TagFactory; } /** diff --git a/test/Unit/Factory/SelfService/TypeFactoryTest.php b/test/Unit/Factory/SelfService/TypeFactoryTest.php index b7b53b0f..0baf57fd 100644 --- a/test/Unit/Factory/SelfService/TypeFactoryTest.php +++ b/test/Unit/Factory/SelfService/TypeFactoryTest.php @@ -21,11 +21,7 @@ class TypeFactoryTest extends BaseModelFactoryTestCase */ protected function getModelFactory(): ModelFactory { - return new TypeFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new TypeFactory; } /** diff --git a/test/Unit/Factory/Shared/SettingsFactoryTest.php b/test/Unit/Factory/Shared/SettingsFactoryTest.php index 8a4146bc..5c24cee5 100644 --- a/test/Unit/Factory/Shared/SettingsFactoryTest.php +++ b/test/Unit/Factory/Shared/SettingsFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new SettingsFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new SettingsFactory; } } diff --git a/test/Unit/Factory/Ticket/AttachmentFactoryTest.php b/test/Unit/Factory/Ticket/AttachmentFactoryTest.php index 8aa2aa8f..1397557c 100644 --- a/test/Unit/Factory/Ticket/AttachmentFactoryTest.php +++ b/test/Unit/Factory/Ticket/AttachmentFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new AttachmentFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new AttachmentFactory; } } diff --git a/test/Unit/Factory/Ticket/ChannelSettingsFactoryTest.php b/test/Unit/Factory/Ticket/ChannelSettingsFactoryTest.php index bc77b6d1..ad35b91f 100644 --- a/test/Unit/Factory/Ticket/ChannelSettingsFactoryTest.php +++ b/test/Unit/Factory/Ticket/ChannelSettingsFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new ChannelSettingsFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new ChannelSettingsFactory; } } diff --git a/test/Unit/Factory/Ticket/CustomFieldFactoryTest.php b/test/Unit/Factory/Ticket/CustomFieldFactoryTest.php index 3ad644da..52b9b0d0 100644 --- a/test/Unit/Factory/Ticket/CustomFieldFactoryTest.php +++ b/test/Unit/Factory/Ticket/CustomFieldFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new CustomFieldFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new CustomFieldFactory; } } diff --git a/test/Unit/Factory/Ticket/DepartmentFactoryTest.php b/test/Unit/Factory/Ticket/DepartmentFactoryTest.php index f457198b..6c68a68d 100644 --- a/test/Unit/Factory/Ticket/DepartmentFactoryTest.php +++ b/test/Unit/Factory/Ticket/DepartmentFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new DepartmentFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new DepartmentFactory; } } diff --git a/test/Unit/Factory/Ticket/MessageFactoryTest.php b/test/Unit/Factory/Ticket/MessageFactoryTest.php index e52629eb..f75d9aac 100644 --- a/test/Unit/Factory/Ticket/MessageFactoryTest.php +++ b/test/Unit/Factory/Ticket/MessageFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new MessageFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new MessageFactory; } } diff --git a/test/Unit/Factory/Ticket/PriorityFactoryTest.php b/test/Unit/Factory/Ticket/PriorityFactoryTest.php index 1f58ea8b..ca6de360 100644 --- a/test/Unit/Factory/Ticket/PriorityFactoryTest.php +++ b/test/Unit/Factory/Ticket/PriorityFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new PriorityFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new PriorityFactory; } } diff --git a/test/Unit/Factory/Ticket/StatusFactoryTest.php b/test/Unit/Factory/Ticket/StatusFactoryTest.php index 4398a177..5b01c017 100644 --- a/test/Unit/Factory/Ticket/StatusFactoryTest.php +++ b/test/Unit/Factory/Ticket/StatusFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new StatusFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new StatusFactory; } } diff --git a/test/Unit/Factory/Ticket/TicketFactoryTest.php b/test/Unit/Factory/Ticket/TicketFactoryTest.php index 648b8936..2b4b1ae0 100644 --- a/test/Unit/Factory/Ticket/TicketFactoryTest.php +++ b/test/Unit/Factory/Ticket/TicketFactoryTest.php @@ -45,10 +45,6 @@ protected function getModel(): string */ protected function getModelFactory(): ModelFactory { - return new TicketFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new TicketFactory; } } diff --git a/test/Unit/Factory/User/UserCustomFieldFactoryTest.php b/test/Unit/Factory/User/UserCustomFieldFactoryTest.php index f24f98dc..3d560dc0 100644 --- a/test/Unit/Factory/User/UserCustomFieldFactoryTest.php +++ b/test/Unit/Factory/User/UserCustomFieldFactoryTest.php @@ -21,11 +21,7 @@ class UserCustomFieldFactoryTest extends BaseModelFactoryTestCase */ protected function getModelFactory(): ModelFactory { - return new UserCustomFieldFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new UserCustomFieldFactory; } /** diff --git a/test/Unit/Factory/User/UserFactoryTest.php b/test/Unit/Factory/User/UserFactoryTest.php index ba971f41..ab711452 100644 --- a/test/Unit/Factory/User/UserFactoryTest.php +++ b/test/Unit/Factory/User/UserFactoryTest.php @@ -21,11 +21,7 @@ class UserFactoryTest extends BaseModelFactoryTestCase */ protected function getModelFactory(): ModelFactory { - return new UserFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new UserFactory; } /** diff --git a/test/Unit/Factory/User/UserGroupFactoryTest.php b/test/Unit/Factory/User/UserGroupFactoryTest.php index 81e79775..791aada5 100644 --- a/test/Unit/Factory/User/UserGroupFactoryTest.php +++ b/test/Unit/Factory/User/UserGroupFactoryTest.php @@ -16,11 +16,7 @@ class UserGroupFactoryTest extends BaseModelFactoryTestCase */ protected function getModelFactory(): ModelFactory { - return new GroupFactory( - $this->format, - $this->getSerializer(), - $this->getEncoder() - ); + return new GroupFactory; } /** diff --git a/test/Unit/Model/BaseModelTestCase.php b/test/Unit/Model/BaseModelTestCase.php index efb6ea66..d939a604 100644 --- a/test/Unit/Model/BaseModelTestCase.php +++ b/test/Unit/Model/BaseModelTestCase.php @@ -2,18 +2,14 @@ namespace SupportPal\ApiClient\Tests\Unit\Model; -use stdClass; -use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Helper\StringHelper; use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Tests\TestCase; -use function array_keys; - /** * Class BaseModelTestCase * @package SupportPal\ApiClient\Tests\Unit\Model - * @covers \SupportPal\ApiClient\Model\BaseModel + * @covers \SupportPal\ApiClient\Model\Model */ abstract class BaseModelTestCase extends TestCase { @@ -27,54 +23,6 @@ public function testCreateModel():void $this->assertArrayEqualsObjectFields($model, $modelData); } - public function testFillModelWithIncorrectData(): void - { - self::expectException(InvalidArgumentException::class); - $model = $this->getModel(); - /** @var array $testArray */ - $testArray = ['article_id','type_id','text']; - $model->fill($testArray); - } - - /** - * @dataProvider provideDataWithInvalidTypes - * @param array $data - * @param string $invalidKey - */ - public function testCreateWithInvalidTypes(array $data, string $invalidKey): void - { - self::expectException(InvalidArgumentException::class); - self::expectExceptionMessage($this->snakeCaseToPascalCase($invalidKey)); - $model = $this->getModel(); - $model->fill($data); - } - - /** - * @return iterable - */ - public function provideDataWithInvalidTypes(): iterable - { - foreach ($this->getInvalidTypesData() as $key => $value) { - $commentDataCopy = $this->getModelData(); - $commentDataCopy[$key] = $value; - - yield [$commentDataCopy, $key]; - } - } - - /** - * @return array - */ - protected function getInvalidTypesData(): array - { - $data = []; - foreach (array_keys($this->getModelData()) as $key) { - $data[$key] = new stdClass; - } - - return $data; - } - /** * @return array */ diff --git a/test/Unit/Model/Collection/CollectionTest.php b/test/Unit/Model/Collection/CollectionTest.php index 9b2076c3..2ef52267 100644 --- a/test/Unit/Model/Collection/CollectionTest.php +++ b/test/Unit/Model/Collection/CollectionTest.php @@ -55,9 +55,11 @@ public function testCollectionMap(): void /** @var Comment $firstModel */ $firstModel = current($models); - $name = $firstModel->getName() . 'test'; + $name = $firstModel->name . 'test'; $mappedCollection = $collection->map(function (Comment $comment) use ($name) { - return $comment->setName($name); + $comment->name = $name; + + return $comment; }); self::assertNotSame($collection, $mappedCollection); @@ -67,7 +69,7 @@ public function testCollectionMap(): void /** @var Comment $model */ foreach ($mappedCollection->getModels() as $model) { - self::assertSame($name, $model->getName()); + self::assertSame($name, $model->name); } } @@ -79,10 +81,10 @@ public function testCollectionFilter(): void /** @var Comment $firstModel */ $firstModel = current($models); - $name = $firstModel->getName() . 'test'; + $name = $firstModel->name . 'test'; $mappedCollection = $collection->filter(function (Comment $comment) use ($name) { - return $comment->getName() === $name; + return $comment->name === $name; }); self::assertNotSame($collection, $mappedCollection); diff --git a/test/Unit/Model/SelfService/CommentTest.php b/test/Unit/Model/SelfService/CommentTest.php index cc326fb1..51e3dddc 100644 --- a/test/Unit/Model/SelfService/CommentTest.php +++ b/test/Unit/Model/SelfService/CommentTest.php @@ -2,8 +2,6 @@ namespace SupportPal\ApiClient\Tests\Unit\Model\SelfService; -use SupportPal\ApiClient\Exception\InvalidArgumentException; -use SupportPal\ApiClient\Exception\MissingRequiredFieldsException; use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\SelfService\Comment; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; @@ -13,7 +11,7 @@ * Class CommentTest * @package SupportPal\ApiClient\Tests\Unit\Model * @covers \SupportPal\ApiClient\Model\SelfService\Comment - * @covers \SupportPal\ApiClient\Model\BaseModel + * @covers \SupportPal\ApiClient\Model\Model */ class CommentTest extends BaseModelTestCase { @@ -32,31 +30,4 @@ protected function getModelData(): array { return (new CommentData)->getDataWithObjects(); } - - /** - * @param array $data - * @param string $missingField - * @dataProvider provideDataWithMissingRequiredFields - * @throws InvalidArgumentException - */ - public function testCreateWithMissingData(array $data, string $missingField): void - { - self::expectException(MissingRequiredFieldsException::class); - self::expectExceptionMessage($missingField); - $model = new Comment; - $model->fill($data); - } - - /** - * @return iterable - */ - public function provideDataWithMissingRequiredFields(): iterable - { - foreach (Comment::REQUIRED_FIELDS as $requiredField) { - $dataCopy = $this->getModelData(); - unset($dataCopy[$requiredField]); - - yield [$dataCopy, $requiredField]; - } - } } diff --git a/test/Unit/Model/Shared/SettingsTest.php b/test/Unit/Model/Shared/SettingsTest.php index 5727f756..4df8ef47 100644 --- a/test/Unit/Model/Shared/SettingsTest.php +++ b/test/Unit/Model/Shared/SettingsTest.php @@ -2,7 +2,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Model\Shared; -use SupportPal\ApiClient\Model\SettingsModel; +use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\Shared\Settings; use SupportPal\ApiClient\Tests\DataFixtures\Core\CoreSettingsData; use SupportPal\ApiClient\Tests\TestCase; @@ -14,7 +14,7 @@ public function testCreateModel():void $model = $this->getModel(); $modelData = $this->getModelData(); $model->fill($modelData); - self::assertSame($model->all(), $modelData); + self::assertSame($model->toArray(), $modelData); } /** @@ -26,9 +26,9 @@ protected function getModelData(): array } /** - * @return SettingsModel + * @return Model */ - protected function getModel(): SettingsModel + protected function getModel(): Model { return new Settings; } diff --git a/test/Unit/ModelNormalizer/ModelNormalizerTest.php b/test/Unit/ModelNormalizer/ModelNormalizerTest.php deleted file mode 100644 index 1c66d391..00000000 --- a/test/Unit/ModelNormalizer/ModelNormalizerTest.php +++ /dev/null @@ -1,201 +0,0 @@ - */ - private $context; - - /** @var string[] */ - private $inputData; - - /** @var string[] */ - private $transformedOutput; - - /** @var ObjectProphecy|AttributeAwareTransformer */ - private $attributeAwareTransformer; - - protected function setUp(): void - { - parent::setUp(); - $this->normalizer = $this->prophesize(AbstractNormalizer::class); - $this->transformer = $this->prophesize(Transformer::class); - $this->attributeAwareTransformer = $this->prophesize(AttributeAwareTransformer::class); - - $this->object = $this->prophesize(Model::class)->reveal(); - $this->format = 'json'; - $this->context = []; - $this->inputData = ['test' => '1', 'test2' => '2', 'test3' => '3',]; - $this->transformedOutput = ['test' => '5', 'test2' => '6', 'test3' => '7',]; - - /** @var AbstractObjectNormalizer $objectNormalizer */ - $objectNormalizer = $this->normalizer->reveal(); - /** @var Transformer $transformer */ - $transformer = $this->transformer->reveal(); - /** @var AttributeAwareTransformer $transformer */ - $attributeAwareTransformer = $this->attributeAwareTransformer->reveal(); - - /** @var Transformer[] $transformers */ - $transformers = [$transformer]; - /** @var AttributeAwareTransformer[] $attributeAwareTransformers */ - $attributeAwareTransformers = [$attributeAwareTransformer]; - $this->modelNormalizer = new ModelNormalizer($objectNormalizer, $transformers, $attributeAwareTransformers); - } - - public function testNormalizeTransformAll(): void - { - $this->normalizer - ->normalize($this->object, $this->format, $this->context) - ->shouldBeCalled() - ->willReturn($this->inputData); - foreach ($this->inputData as $key => $value) { - $this->transformer->canTransform($value)->shouldBeCalled()->willReturn(true); - $this->transformer->transform($value)->shouldBeCalled()->willReturn($this->transformedOutput[$key]); - } - - $data = $this->modelNormalizer->normalize($this->object, $this->format, $this->context); - self::assertSame($this->transformedOutput, $data); - } - - /** - * @dataProvider provideSupportNormalizationCases - * @param mixed $data - * @param bool $objectNormalizerSupports - * @param bool $expectation - */ - public function testSupportsNormalization(mixed $data, bool $objectNormalizerSupports, bool $expectation): void - { - $objectNormalizerExpectation = $this->normalizer - ->supportsNormalization($data, $this->format) - ->willReturn($objectNormalizerSupports); - - if ($data instanceof Model) { - $objectNormalizerExpectation->shouldNotBeCalled(); - } - - if (! $data instanceof Model) { - $objectNormalizerExpectation->shouldBeCalled(); - } - - $this->normalizer - ->supportsNormalization($data, $this->format) - ->willReturn($objectNormalizerSupports); - - self::assertSame($expectation, $this->modelNormalizer->supportsNormalization($data, $this->format, [])); - } - - /** - * @return iterable> - * @throws InvalidArgumentException - */ - public function provideSupportNormalizationCases(): iterable - { - yield [[], true, true]; - yield [new Comment, false, true]; - yield [[], false, false]; - } - - public function testNormalizeTransformNone(): void - { - $this->normalizer - ->normalize($this->object, $this->format, $this->context) - ->shouldBeCalled() - ->willReturn($this->inputData); - - foreach ($this->inputData as $value) { - $this->transformer->canTransform($value)->shouldBeCalled()->willReturn(false); - $this->transformer->transform($value)->shouldNotBeCalled(); - } - - $data = $this->modelNormalizer->normalize($this->object, $this->format, $this->context); - self::assertSame($this->inputData, $data); - } - - /** - * @param mixed $data - * @param bool $objectNormalizerSupports - * @dataProvider provideSupportNormalizationCases - */ - public function testSupportsDenormalization(mixed $data, bool $objectNormalizerSupports): void - { - $this->normalizer - ->supportsDenormalization($data, Model::class, $this->format) - ->willReturn($objectNormalizerSupports) - ->shouldBeCalled(); - - self::assertSame( - $objectNormalizerSupports, - $this->modelNormalizer->supportsDenormalization($data, Model::class, $this->format) - ); - } - - /** - * @return iterable - */ - public function provideSupportDenormalizationCases(): iterable - { - yield [[], true]; - yield [new Comment, false]; - yield [[], false]; - } - - public function testDenormalize(): void - { - $this - ->normalizer - ->denormalize($this->inputData, Model::class, $this->format, $this->context) - ->shouldBeCalled() - ->willReturn($this->object); - - foreach ($this->inputData as $key => $value) { - $this - ->attributeAwareTransformer - ->canTransform($this->snakeCaseToCamelCase($key), Model::class, $value) - ->shouldBeCalled() - ->willReturn(false); - } - - $this->attributeAwareTransformer->transform(Argument::any())->shouldNotBeCalled(); - $this->transformer->canTransform($this->object)->shouldBeCalled()->willReturn(true); - $this->transformer->transform($this->object)->shouldBeCalled()->willReturn(null); - $output = $this->modelNormalizer->denormalize($this->inputData, Model::class, $this->format, $this->context); - self::assertNull($output); - } -} diff --git a/test/Unit/Transformer/BooleanToIntTransformerTest.php b/test/Unit/Transformer/BooleanToIntTransformerTest.php deleted file mode 100644 index c004778b..00000000 --- a/test/Unit/Transformer/BooleanToIntTransformerTest.php +++ /dev/null @@ -1,79 +0,0 @@ -booleanToIntTransformer = new BooleanToIntTransformer; - } - - /** - * @param bool $data - * @dataProvider provideCanTransformCases - */ - public function testCanTransform(bool $data): void - { - self::assertTrue($this->booleanToIntTransformer->canTransform($data)); - } - - /** - * @param mixed $data - * @dataProvider provideCannotTransformCases - */ - public function testCannotTransform(mixed $data): void - { - self::assertFalse($this->booleanToIntTransformer->canTransform($data)); - } - - /** - * @param bool $data - * @param int $expected - * @dataProvider provideTransformCases - */ - public function testTransform(bool $data, int $expected): void - { - self::assertSame($expected, $this->booleanToIntTransformer->transform($data)); - } - - /** - * @return iterable - */ - public function provideTransformCases(): iterable - { - yield [true, 1]; - yield [false, 0]; - } - - /** - * @return iterable> - */ - public function provideCanTransformCases(): iterable - { - yield [true]; - yield [false]; - } - - /** - * @return iterable - */ - public function provideCannotTransformCases(): iterable - { - yield [0.0]; - yield [0]; - yield ['str']; - yield [new stdClass]; - yield [new Comment]; - yield [[]]; - } -} diff --git a/test/Unit/Transformer/EmptyModelToNullTransformerTest.php b/test/Unit/Transformer/EmptyModelToNullTransformerTest.php deleted file mode 100644 index 1d46cd13..00000000 --- a/test/Unit/Transformer/EmptyModelToNullTransformerTest.php +++ /dev/null @@ -1,107 +0,0 @@ -transformer = new EmptyModelToNullTransformer; - } - - /** - * @param Model $model - * @dataProvider provideModelCases - */ - public function testTransformNotNull(Model $model): void - { - $modelArray = (array) $model; - $model = $this->transformer->transform($model); - self::assertEquals($modelArray, (array) $model); - } - - /** - * @param Model $model - * @dataProvider provideEmptyModelCases - */ - public function testTransformToNull(Model $model): void - { - self::assertNull($this->transformer->transform($model)); - } - - /** - * @param Model $model - * @dataProvider provideEmptyModelCases - */ - public function testCanTransform(Model $model): void - { - self::assertTrue($this->transformer->canTransform($model)); - } - - /** - * @param mixed $data - * @dataProvider provideCannotTransformCases - */ - public function testCannotTransform(mixed $data): void - { - self::assertFalse($this->transformer->canTransform($data)); - } - - /** - * @return iterable - * @throws InvalidArgumentException - */ - public function provideModelCases(): iterable - { - yield [(new CommentData)->getFilledInstance()]; - yield [(new TicketData)->getFilledInstance()]; - yield [(new UserData)->getFilledInstance()]; - yield [(new ArticleData)->getFilledInstance()]; - } - - /** - * @return iterable - */ - public function provideEmptyModelCases(): iterable - { - yield [new Comment]; - yield [new Ticket]; - yield [new User]; - yield [new Article]; - } - - /** - * @return iterable - */ - public function provideCannotTransformCases(): iterable - { - yield [[]]; - yield [new stdClass]; - yield ['']; - yield [new Settings]; - } -} diff --git a/test/Unit/Transformer/IntToBooleanTransformerTest.php b/test/Unit/Transformer/IntToBooleanTransformerTest.php deleted file mode 100644 index 8ad8e177..00000000 --- a/test/Unit/Transformer/IntToBooleanTransformerTest.php +++ /dev/null @@ -1,158 +0,0 @@ -propertyTypeExtractor = $this->prophesize(PropertyTypeExtractorInterface::class); - - $this->type = $this->prophesize(Type::class); - - /** @var PropertyTypeExtractorInterface $propertyTypeExtractor */ - $propertyTypeExtractor = $this->propertyTypeExtractor->reveal(); - $this->intToBooleanTransformer = new IntToBooleanTransformer($propertyTypeExtractor); - } - - /** - * @param mixed $value - * @dataProvider provideCannotTransformNonIntValueCases - */ - public function testCannotTransformNonIntValue(mixed $value): void - { - $this->propertyTypeExtractor->getTypes(Model::class, $this->attribute)->shouldNotBeCalled(); - self::assertFalse($this->intToBooleanTransformer->canTransform($this->attribute, Model::class, $value)); - } - - /** - * @param int $value - * @dataProvider provideCannotTransformIntNotBooleanValueCases - */ - public function testCannotTransformIntNotBooleanValue(int $value): void - { - $this->propertyTypeExtractor->getTypes(Model::class, $this->attribute)->shouldNotBeCalled(); - self::assertFalse($this->intToBooleanTransformer->canTransform($this->attribute, Model::class, $value)); - } - - /** - * @param int $value - * @dataProvider provideCannotTransformAttributeNotBool - */ - public function testCannotTransformNonBooleanAttribute(int $value): void - { - $this->type->getBuiltinType()->shouldBeCalled()->willReturn('test'); - $this->propertyTypeExtractor - ->getTypes(Model::class, $this->attribute) - ->shouldBeCalled() - ->willReturn([$this->type->reveal()]); - - self::assertFalse($this->intToBooleanTransformer->canTransform($this->attribute, Model::class, $value)); - } - - /** - * @param int $value - * @dataProvider provideCanTransformCases - */ - public function testCanTransform(int $value): void - { - $this->type->getBuiltinType()->shouldBeCalled()->willReturn(Type::BUILTIN_TYPE_BOOL); - $this->propertyTypeExtractor - ->getTypes(Model::class, $this->attribute) - ->shouldBeCalled() - ->willReturn([$this->type->reveal()]); - - self::assertTrue($this->intToBooleanTransformer->canTransform($this->attribute, Model::class, $value)); - } - - /** - * @param int $data - * @param bool $expected - * @dataProvider provideTransformCases - */ - public function testTransform(int $data, bool $expected): void - { - self::assertSame($expected, $this->intToBooleanTransformer->transform($data)); - } - - public function testCannotDetermineAttributeType(): void - { - $this->propertyTypeExtractor - ->getTypes(Model::class, $this->attribute) - ->shouldBeCalled() - ->willReturn(null); - - $value = $this->intToBooleanTransformer->canTransform($this->attribute, Model::class, 1); - self::assertSame(false, $value); - } - - /** - * @return iterable> - */ - public function provideTransformCases(): iterable - { - yield [1, true]; - yield [0, false]; - } - - /** - * @return iterable> - */ - public function provideCanTransformCases(): iterable - { - yield [0]; - yield [1]; - } - - /** - * @return iterable> - */ - public function provideCannotTransformAttributeNotBool(): iterable - { - yield [0]; - yield [1]; - } - - /** - * @return iterable - */ - public function provideCannotTransformNonIntValueCases(): iterable - { - yield [new Comment]; - yield [5.0]; - yield ['str']; - yield [new stdClass]; - } - - /** - * @return iterable> - */ - public function provideCannotTransformIntNotBooleanValueCases(): iterable - { - yield [2]; - yield [3]; - yield [-1]; - } -} diff --git a/test/Unit/Transformer/StringTrimTransformerTest.php b/test/Unit/Transformer/StringTrimTransformerTest.php deleted file mode 100644 index 1a73cf18..00000000 --- a/test/Unit/Transformer/StringTrimTransformerTest.php +++ /dev/null @@ -1,73 +0,0 @@ -transformer = new StringTrimTransformer; - } - - public function testCanTransform(): void - { - self::assertTrue($this->transformer->canTransform('')); - } - - /** - * @param mixed $data - * @dataProvider provideCannotTransformCases - */ - public function testCannotTransform(mixed $data): void - { - self::assertFalse($this->transformer->canTransform($data)); - } - - /** - * @return iterable - */ - public function provideCannotTransformCases(): iterable - { - yield [[]]; - yield [new stdClass]; - yield [new Comment]; - yield [new Settings]; - } - - /** - * @param string $input - * @param string $expected - * @dataProvider provideTrimStringCases - */ - public function testTransformTrim(string $input, string $expected): void - { - self::assertSame($expected, $this->transformer->transform($input)); - } - - /** - * @return iterable> - */ - public function provideTrimStringCases(): iterable - { - yield [' ', '']; - yield [' test ', 'test']; - yield [' test', 'test']; - yield ['test ', 'test']; - yield ['test', 'test']; - } -}