From d65418e4736969949f5a2558a39763cc3950ddaf Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Fri, 24 May 2024 12:45:40 +0100 Subject: [PATCH 01/20] wip --- composer.json | 3 +- composer.lock | 1980 +++++++++++++---- src/Model/BaseModel.php | 162 +- src/Model/BaseTranslation.php | 16 +- src/Model/Model.php | 14 - src/Normalizer/ModelNormalizer.php | 143 -- src/Transformer/AttributeAwareTransformer.php | 20 - src/Transformer/BooleanToIntTransformer.php | 25 - .../EmptyModelToNullTransformer.php | 51 - src/Transformer/IntToBooleanTransformer.php | 57 - src/Transformer/StringTrimTransformer.php | 25 - src/Transformer/Transformer.php | 18 - 12 files changed, 1517 insertions(+), 997 deletions(-) delete mode 100644 src/Model/Model.php delete mode 100644 src/Normalizer/ModelNormalizer.php delete mode 100644 src/Transformer/AttributeAwareTransformer.php delete mode 100644 src/Transformer/BooleanToIntTransformer.php delete mode 100644 src/Transformer/EmptyModelToNullTransformer.php delete mode 100644 src/Transformer/IntToBooleanTransformer.php delete mode 100644 src/Transformer/StringTrimTransformer.php delete mode 100644 src/Transformer/Transformer.php diff --git a/composer.json b/composer.json index d4afaf45..0e0b0dcd 100644 --- a/composer.json +++ b/composer.json @@ -13,13 +13,12 @@ "php": "^8.1", "doctrine/cache": "^1.10", "guzzlehttp/guzzle": "^7.0", + "illuminate/database": "^11.8", "kevinrob/guzzle-cache-middleware": "^5.0", "phpdocumentor/reflection-docblock": "^5.2", "psr/http-message": "^1.0", "symfony/config": "^6.2|^7.0", "symfony/dependency-injection": "^6.2|^7.0", - "symfony/property-access": "^6.2|^7.0", - "symfony/serializer": "^6.2|^7.0", "symfony/yaml": "^6.2|^7.0" }, "require-dev": { diff --git a/composer.lock b/composer.lock index acc8f3b2..51ff3fb3 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,137 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "50bf234bf4cb51d502c1c2de49fc9bd4", + "content-hash": "ab87a0d0b8e28fc78b096a97ffcb09a6", "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", + "source": { + "type": "git", + "url": "https://github.com/CarbonPHP/carbon-doctrine-types.git", + "reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/18ba5ddfec8976260ead6e866180bd5d2f71aa1d", + "reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d", + "shasum": "" + }, + "require": { + "php": "^8.1" + }, + "conflict": { + "doctrine/dbal": "<4.0.0 || >=5.0.0" + }, + "require-dev": { + "doctrine/dbal": "^4.0.0", + "nesbot/carbon": "^2.71.0 || ^3.0.0", + "phpunit/phpunit": "^10.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Carbon\\Doctrine\\": "src/Carbon/Doctrine/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "KyleKatarn", + "email": "kylekatarnls@gmail.com" + } + ], + "description": "Types to use Carbon in Doctrine", + "keywords": [ + "carbon", + "date", + "datetime", + "doctrine", + "time" + ], + "support": { + "issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues", + "source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/3.2.0" + }, + "funding": [ + { + "url": "https://github.com/kylekatarnls", + "type": "github" + }, + { + "url": "https://opencollective.com/Carbon", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "type": "tidelift" + } + ], + "time": "2024-02-09T16:56:22+00:00" + }, { "name": "doctrine/cache", "version": "1.13.0", @@ -152,6 +281,97 @@ }, "time": "2024-01-30T19:34:25+00:00" }, + { + "name": "doctrine/inflector", + "version": "2.0.10", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "reference": "5817d0659c5b50c9b950feb9af7b9668e2c436bc", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^11.0", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-phpunit": "^1.1", + "phpstan/phpstan-strict-rules": "^1.3", + "phpunit/phpunit": "^8.5 || ^9.5", + "vimeo/psalm": "^4.25 || ^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", + "homepage": "https://www.doctrine-project.org/projects/inflector.html", + "keywords": [ + "inflection", + "inflector", + "lowercase", + "manipulation", + "php", + "plural", + "singular", + "strings", + "uppercase", + "words" + ], + "support": { + "issues": "https://github.com/doctrine/inflector/issues", + "source": "https://github.com/doctrine/inflector/tree/2.0.10" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], + "time": "2024-02-18T20:23:39+00:00" + }, { "name": "guzzlehttp/guzzle", "version": "7.8.1", @@ -478,48 +698,40 @@ "time": "2023-12-03T20:05:35+00:00" }, { - "name": "kevinrob/guzzle-cache-middleware", - "version": "v5.1.0", + "name": "illuminate/collections", + "version": "v11.8.0", "source": { "type": "git", - "url": "https://github.com/Kevinrob/guzzle-cache-middleware.git", - "reference": "6bd64dbbe5155107d84a0f67140a8822a709c6d0" + "url": "https://github.com/illuminate/collections.git", + "reference": "dad22e648ae0f4973470d82b4ae5f809540a87ff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Kevinrob/guzzle-cache-middleware/zipball/6bd64dbbe5155107d84a0f67140a8822a709c6d0", - "reference": "6bd64dbbe5155107d84a0f67140a8822a709c6d0", + "url": "https://api.github.com/repos/illuminate/collections/zipball/dad22e648ae0f4973470d82b4ae5f809540a87ff", + "reference": "dad22e648ae0f4973470d82b4ae5f809540a87ff", "shasum": "" }, "require": { - "guzzlehttp/guzzle": "^6.0 || ^7.0", - "guzzlehttp/promises": "^1.4 || ^2.0", - "guzzlehttp/psr7": "^1.7.0 || ^2.0.0", - "php": ">=7.2.0" - }, - "require-dev": { - "cache/array-adapter": "^0.4 || ^0.5 || ^1.0", - "cache/simple-cache-bridge": "^0.1 || ^1.0", - "doctrine/cache": "^1.10", - "illuminate/cache": "^5.0", - "league/flysystem": "^2.5", - "phpunit/phpunit": "^8.5.15 || ^9.5", - "psr/cache": "^1.0", - "symfony/cache": "^4.4 || ^5.0", - "symfony/phpunit-bridge": "^4.4 || ^5.0" + "illuminate/conditionable": "^11.0", + "illuminate/contracts": "^11.0", + "illuminate/macroable": "^11.0", + "php": "^8.2" }, "suggest": { - "doctrine/cache": "This library has a lot of ready-to-use cache storage (to be used with Kevinrob\\GuzzleCache\\Storage\\DoctrineCacheStorage). Use only versions >=1.4.0 < 2.0.0", - "guzzlehttp/guzzle": "For using this library. It was created for Guzzle6 (but you can use it with any PSR-7 HTTP client).", - "laravel/framework": "To be used with Kevinrob\\GuzzleCache\\Storage\\LaravelCacheStorage", - "league/flysystem": "To be used with Kevinrob\\GuzzleCache\\Storage\\FlysystemStorage", - "psr/cache": "To be used with Kevinrob\\GuzzleCache\\Storage\\Psr6CacheStorage", - "psr/simple-cache": "To be used with Kevinrob\\GuzzleCache\\Storage\\Psr16CacheStorage" + "symfony/var-dumper": "Required to use the dump method (^7.0)." }, "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, "autoload": { + "files": [ + "helpers.php" + ], "psr-4": { - "Kevinrob\\GuzzleCache\\": "src/" + "Illuminate\\Support\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -528,66 +740,44 @@ ], "authors": [ { - "name": "Kevin Robatel", - "email": "kevinrob2@gmail.com", - "homepage": "https://github.com/Kevinrob" + "name": "Taylor Otwell", + "email": "taylor@laravel.com" } ], - "description": "A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)", - "homepage": "https://github.com/Kevinrob/guzzle-cache-middleware", - "keywords": [ - "Etag", - "Flysystem", - "Guzzle", - "cache", - "cache-control", - "doctrine", - "expiration", - "guzzle6", - "handler", - "http", - "http 1.1", - "middleware", - "performance", - "php", - "promise", - "psr6", - "psr7", - "rfc7234", - "validation" - ], + "description": "The Illuminate Collections package.", + "homepage": "https://laravel.com", "support": { - "issues": "https://github.com/Kevinrob/guzzle-cache-middleware/issues", - "source": "https://github.com/Kevinrob/guzzle-cache-middleware/tree/v5.1.0" + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" }, - "time": "2023-11-09T06:53:45+00:00" + "time": "2024-05-20T13:26:28+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", + "name": "illuminate/conditionable", + "version": "v11.8.0", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + "url": "https://github.com/illuminate/conditionable.git", + "reference": "8a558fec063b6a63da1c3af1d219c0f998edffeb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "url": "https://api.github.com/repos/illuminate/conditionable/zipball/8a558fec063b6a63da1c3af1d219c0f998edffeb", + "reference": "8a558fec063b6a63da1c3af1d219c0f998edffeb", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0" + "php": "^8.0.2" }, "type": "library", "extra": { "branch-alias": { - "dev-2.x": "2.x-dev" + "dev-master": "11.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": "src/" + "Illuminate\\Support\\": "" } }, "notification-url": "https://packagist.org/downloads/", @@ -596,66 +786,522 @@ ], "authors": [ { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" + "name": "Taylor Otwell", + "email": "taylor@laravel.com" } ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", - "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" - ], + "description": "The Illuminate Conditionable package.", + "homepage": "https://laravel.com", "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" }, - "time": "2020-06-27T09:03:43+00:00" + "time": "2024-04-04T17:36:49+00:00" }, { - "name": "phpdocumentor/reflection-docblock", - "version": "5.4.0", + "name": "illuminate/container", + "version": "v11.8.0", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" + "url": "https://github.com/illuminate/container.git", + "reference": "af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", - "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", + "url": "https://api.github.com/repos/illuminate/container/zipball/af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7", + "reference": "af979ecfd6dfa6583eae5dfe2e9a8840358f4ca7", "shasum": "" }, "require": { - "doctrine/deprecations": "^1.1", - "ext-filter": "*", - "php": "^7.4 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.7", - "phpstan/phpdoc-parser": "^1.7", - "webmozart/assert": "^1.9.1" + "illuminate/contracts": "^11.0", + "php": "^8.2", + "psr/container": "^1.1.1|^2.0.1" }, - "require-dev": { - "mockery/mockery": "~1.3.5", - "phpstan/extension-installer": "^1.1", - "phpstan/phpstan": "^1.8", - "phpstan/phpstan-mockery": "^1.1", - "phpstan/phpstan-webmozart-assert": "^1.2", - "phpunit/phpunit": "^9.5", - "vimeo/psalm": "^5.13" + "provide": { + "psr/container-implementation": "1.1|2.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.x-dev" + "dev-master": "11.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": "src" + "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", + "source": { + "type": "git", + "url": "https://github.com/illuminate/contracts.git", + "reference": "8782f75e80ab3e6036842d24dbeead34a16f3a79" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/8782f75e80ab3e6036842d24dbeead34a16f3a79", + "reference": "8782f75e80ab3e6036842d24dbeead34a16f3a79", + "shasum": "" + }, + "require": { + "php": "^8.2", + "psr/container": "^1.1.1|^2.0.1", + "psr/simple-cache": "^1.0|^2.0|^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Contracts\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Contracts package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "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", + "source": { + "type": "git", + "url": "https://github.com/illuminate/macroable.git", + "reference": "5b6c7c7c5951e6e8fc22dd7e4363602df8294dfa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/macroable/zipball/5b6c7c7c5951e6e8fc22dd7e4363602df8294dfa", + "reference": "5b6c7c7c5951e6e8fc22dd7e4363602df8294dfa", + "shasum": "" + }, + "require": { + "php": "^8.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Macroable package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2024-05-16T21:43:47+00:00" + }, + { + "name": "illuminate/support", + "version": "v11.8.0", + "source": { + "type": "git", + "url": "https://github.com/illuminate/support.git", + "reference": "8deb8ba65ed7dc4e3f7b9b64ab70456250454824" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/support/zipball/8deb8ba65ed7dc4e3f7b9b64ab70456250454824", + "reference": "8deb8ba65ed7dc4e3f7b9b64ab70456250454824", + "shasum": "" + }, + "require": { + "doctrine/inflector": "^2.0", + "ext-ctype": "*", + "ext-filter": "*", + "ext-mbstring": "*", + "illuminate/collections": "^11.0", + "illuminate/conditionable": "^11.0", + "illuminate/contracts": "^11.0", + "illuminate/macroable": "^11.0", + "nesbot/carbon": "^2.72.2|^3.0", + "php": "^8.2", + "voku/portable-ascii": "^2.0" + }, + "conflict": { + "tightenco/collect": "<5.5.33" + }, + "replace": { + "spatie/once": "*" + }, + "suggest": { + "illuminate/filesystem": "Required to use the composer class (^11.0).", + "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0.2).", + "ramsey/uuid": "Required to use Str::uuid() (^4.7).", + "symfony/process": "Required to use the composer class (^7.0).", + "symfony/uid": "Required to use Str::ulid() (^7.0).", + "symfony/var-dumper": "Required to use the dd function (^7.0).", + "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.4.1)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "11.x-dev" + } + }, + "autoload": { + "files": [ + "helpers.php" + ], + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Support package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2024-05-21T15:24:23+00:00" + }, + { + "name": "kevinrob/guzzle-cache-middleware", + "version": "v5.1.0", + "source": { + "type": "git", + "url": "https://github.com/Kevinrob/guzzle-cache-middleware.git", + "reference": "6bd64dbbe5155107d84a0f67140a8822a709c6d0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Kevinrob/guzzle-cache-middleware/zipball/6bd64dbbe5155107d84a0f67140a8822a709c6d0", + "reference": "6bd64dbbe5155107d84a0f67140a8822a709c6d0", + "shasum": "" + }, + "require": { + "guzzlehttp/guzzle": "^6.0 || ^7.0", + "guzzlehttp/promises": "^1.4 || ^2.0", + "guzzlehttp/psr7": "^1.7.0 || ^2.0.0", + "php": ">=7.2.0" + }, + "require-dev": { + "cache/array-adapter": "^0.4 || ^0.5 || ^1.0", + "cache/simple-cache-bridge": "^0.1 || ^1.0", + "doctrine/cache": "^1.10", + "illuminate/cache": "^5.0", + "league/flysystem": "^2.5", + "phpunit/phpunit": "^8.5.15 || ^9.5", + "psr/cache": "^1.0", + "symfony/cache": "^4.4 || ^5.0", + "symfony/phpunit-bridge": "^4.4 || ^5.0" + }, + "suggest": { + "doctrine/cache": "This library has a lot of ready-to-use cache storage (to be used with Kevinrob\\GuzzleCache\\Storage\\DoctrineCacheStorage). Use only versions >=1.4.0 < 2.0.0", + "guzzlehttp/guzzle": "For using this library. It was created for Guzzle6 (but you can use it with any PSR-7 HTTP client).", + "laravel/framework": "To be used with Kevinrob\\GuzzleCache\\Storage\\LaravelCacheStorage", + "league/flysystem": "To be used with Kevinrob\\GuzzleCache\\Storage\\FlysystemStorage", + "psr/cache": "To be used with Kevinrob\\GuzzleCache\\Storage\\Psr6CacheStorage", + "psr/simple-cache": "To be used with Kevinrob\\GuzzleCache\\Storage\\Psr16CacheStorage" + }, + "type": "library", + "autoload": { + "psr-4": { + "Kevinrob\\GuzzleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Robatel", + "email": "kevinrob2@gmail.com", + "homepage": "https://github.com/Kevinrob" + } + ], + "description": "A HTTP/1.1 Cache for Guzzle 6. It's a simple Middleware to be added in the HandlerStack. (RFC 7234)", + "homepage": "https://github.com/Kevinrob/guzzle-cache-middleware", + "keywords": [ + "Etag", + "Flysystem", + "Guzzle", + "cache", + "cache-control", + "doctrine", + "expiration", + "guzzle6", + "handler", + "http", + "http 1.1", + "middleware", + "performance", + "php", + "promise", + "psr6", + "psr7", + "rfc7234", + "validation" + ], + "support": { + "issues": "https://github.com/Kevinrob/guzzle-cache-middleware/issues", + "source": "https://github.com/Kevinrob/guzzle-cache-middleware/tree/v5.1.0" + }, + "time": "2023-11-09T06:53:45+00:00" + }, + { + "name": "nesbot/carbon", + "version": "3.3.1", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "8ff64b92c1b1ec84fcde9f8bb9ff2ca34cb8a77a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/8ff64b92c1b1ec84fcde9f8bb9ff2ca34cb8a77a", + "reference": "8ff64b92c1b1ec84fcde9f8bb9ff2ca34cb8a77a", + "shasum": "" + }, + "require": { + "carbonphp/carbon-doctrine-types": "*", + "ext-json": "*", + "php": "^8.1", + "psr/clock": "^1.0", + "symfony/clock": "^6.3 || ^7.0", + "symfony/polyfill-mbstring": "^1.0", + "symfony/translation": "^4.4.18 || ^5.2.1|| ^6.0 || ^7.0" + }, + "provide": { + "psr/clock-implementation": "1.0" + }, + "require-dev": { + "doctrine/dbal": "^3.6.3 || ^4.0", + "doctrine/orm": "^2.15.2 || ^3.0", + "friendsofphp/php-cs-fixer": "^3.52.1", + "kylekatarnls/multi-tester": "^2.5.3", + "ondrejmirtes/better-reflection": "^6.25.0.4", + "phpmd/phpmd": "^2.15.0", + "phpstan/extension-installer": "^1.3.1", + "phpstan/phpstan": "^1.10.65", + "phpunit/phpunit": "^10.5.15", + "squizlabs/php_codesniffer": "^3.9.0" + }, + "bin": [ + "bin/carbon" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev", + "dev-2.x": "2.x-dev" + }, + "laravel": { + "providers": [ + "Carbon\\Laravel\\ServiceProvider" + ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "https://markido.com" + }, + { + "name": "kylekatarnls", + "homepage": "https://github.com/kylekatarnls" + } + ], + "description": "An API extension for DateTime that supports 281 different languages.", + "homepage": "https://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "support": { + "docs": "https://carbon.nesbot.com/docs", + "issues": "https://github.com/briannesbitt/Carbon/issues", + "source": "https://github.com/briannesbitt/Carbon" + }, + "funding": [ + { + "url": "https://github.com/sponsors/kylekatarnls", + "type": "github" + }, + { + "url": "https://opencollective.com/Carbon#sponsor", + "type": "opencollective" + }, + { + "url": "https://tidelift.com/subscription/pkg/packagist-nesbot-carbon?utm_source=packagist-nesbot-carbon&utm_medium=referral&utm_campaign=readme", + "type": "tidelift" + } + ], + "time": "2024-05-01T06:54:22+00:00" + }, + { + "name": "phpdocumentor/reflection-common", + "version": "2.2.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionCommon.git", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-2.x": "2.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -664,10 +1310,78 @@ ], "authors": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" - }, - { + "name": "Jaap van Otterdijk", + "email": "opensource@ijaap.nl" + } + ], + "description": "Common reflection classes used by phpdocumentor to reflect the code structure", + "homepage": "http://www.phpdoc.org", + "keywords": [ + "FQSEN", + "phpDocumentor", + "phpdoc", + "reflection", + "static analysis" + ], + "support": { + "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", + "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + }, + "time": "2020-06-27T09:03:43+00:00" + }, + { + "name": "phpdocumentor/reflection-docblock", + "version": "5.4.0", + "source": { + "type": "git", + "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", + "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", + "shasum": "" + }, + "require": { + "doctrine/deprecations": "^1.1", + "ext-filter": "*", + "php": "^7.4 || ^8.0", + "phpdocumentor/reflection-common": "^2.2", + "phpdocumentor/type-resolver": "^1.7", + "phpstan/phpdoc-parser": "^1.7", + "webmozart/assert": "^1.9.1" + }, + "require-dev": { + "mockery/mockery": "~1.3.5", + "phpstan/extension-installer": "^1.1", + "phpstan/phpstan": "^1.8", + "phpstan/phpstan-mockery": "^1.1", + "phpstan/phpstan-webmozart-assert": "^1.2", + "phpunit/phpunit": "^9.5", + "vimeo/psalm": "^5.13" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "5.x-dev" + } + }, + "autoload": { + "psr-4": { + "phpDocumentor\\Reflection\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Mike van Riel", + "email": "me@mikevanriel.com" + }, + { "name": "Jaap van Otterdijk", "email": "opensource@ijaap.nl" } @@ -784,6 +1498,54 @@ }, "time": "2024-05-06T12:04:23+00:00" }, + { + "name": "psr/clock", + "version": "1.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/clock.git", + "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/clock/zipball/e41a24703d4560fd0acb709162f73b8adfc3aa0d", + "reference": "e41a24703d4560fd0acb709162f73b8adfc3aa0d", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Psr\\Clock\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for reading the clock.", + "homepage": "https://github.com/php-fig/clock", + "keywords": [ + "clock", + "now", + "psr", + "psr-20", + "time" + ], + "support": { + "issues": "https://github.com/php-fig/clock/issues", + "source": "https://github.com/php-fig/clock/tree/1.0.0" + }, + "time": "2022-11-25T14:36:26+00:00" + }, { "name": "psr/container", "version": "2.0.2", @@ -997,6 +1759,57 @@ }, "time": "2023-04-04T09:50:52+00:00" }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, { "name": "ralouphie/getallheaders", "version": "3.0.3", @@ -1021,7 +1834,58 @@ "type": "library", "autoload": { "files": [ - "src/getallheaders.php" + "src/getallheaders.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ralph Khattar", + "email": "ralph.khattar@gmail.com" + } + ], + "description": "A polyfill for getallheaders.", + "support": { + "issues": "https://github.com/ralouphie/getallheaders/issues", + "source": "https://github.com/ralouphie/getallheaders/tree/develop" + }, + "time": "2019-03-08T08:55:37+00:00" + }, + { + "name": "symfony/clock", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/clock.git", + "reference": "2008671acb4a30b01c453de193cf9c80549ebda6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/clock/zipball/2008671acb4a30b01c453de193cf9c80549ebda6", + "reference": "2008671acb4a30b01c453de193cf9c80549ebda6", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "psr/clock": "^1.0", + "symfony/polyfill-php83": "^1.28" + }, + "provide": { + "psr/clock-implementation": "1.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/now.php" + ], + "psr-4": { + "Symfony\\Component\\Clock\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1030,16 +1894,39 @@ ], "authors": [ { - "name": "Ralph Khattar", - "email": "ralph.khattar@gmail.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" } ], - "description": "A polyfill for getallheaders.", + "description": "Decouples applications from the system clock", + "homepage": "https://symfony.com", + "keywords": [ + "clock", + "psr20", + "time" + ], "support": { - "issues": "https://github.com/ralouphie/getallheaders/issues", - "source": "https://github.com/ralouphie/getallheaders/tree/develop" + "source": "https://github.com/symfony/clock/tree/v7.0.7" }, - "time": "2019-03-08T08:55:37+00:00" + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" }, { "name": "symfony/config", @@ -1406,165 +2293,6 @@ ], "time": "2024-01-29T20:11:03+00:00" }, - { - "name": "symfony/polyfill-intl-grapheme", - "version": "v1.29.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-grapheme.git", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", - "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Grapheme\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's grapheme_* functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "grapheme", - "intl", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-01-29T20:11:03+00:00" - }, - { - "name": "symfony/polyfill-intl-normalizer", - "version": "v1.29.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-intl-normalizer.git", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", - "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", - "shasum": "" - }, - "require": { - "php": ">=7.1" - }, - "suggest": { - "ext-intl": "For best performance" - }, - "type": "library", - "extra": { - "thanks": { - "name": "symfony/polyfill", - "url": "https://github.com/symfony/polyfill" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Polyfill\\Intl\\Normalizer\\": "" - }, - "classmap": [ - "Resources/stubs" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for intl's Normalizer class and related functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "intl", - "normalizer", - "polyfill", - "portable", - "shim" - ], - "support": { - "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-01-29T20:11:03+00:00" - }, { "name": "symfony/polyfill-mbstring", "version": "v1.29.0", @@ -1643,97 +2371,41 @@ "type": "tidelift" } ], - "time": "2024-01-29T20:11:03+00:00" - }, - { - "name": "symfony/process", - "version": "v7.0.7", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "3839e56b94dd1dbd13235d27504e66baf23faba0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/3839e56b94dd1dbd13235d27504e66baf23faba0", - "reference": "3839e56b94dd1dbd13235d27504e66baf23faba0", - "shasum": "" - }, - "require": { - "php": ">=8.2" - }, - "type": "library", - "autoload": { - "psr-4": { - "Symfony\\Component\\Process\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Executes commands in sub-processes", - "homepage": "https://symfony.com", - "support": { - "source": "https://github.com/symfony/process/tree/v7.0.7" - }, - "funding": [ - { - "url": "https://symfony.com/sponsor", - "type": "custom" - }, - { - "url": "https://github.com/fabpot", - "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", - "type": "tidelift" - } - ], - "time": "2024-04-18T09:29:19+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { - "name": "symfony/property-access", - "version": "v7.0.7", + "name": "symfony/polyfill-php80", + "version": "v1.29.0", "source": { "type": "git", - "url": "https://github.com/symfony/property-access.git", - "reference": "8661b861480d2807eb2789ff99d034c0c71ab955" + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-access/zipball/8661b861480d2807eb2789ff99d034c0c71ab955", - "reference": "8661b861480d2807eb2789ff99d034c0c71ab955", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "shasum": "" }, "require": { - "php": ">=8.2", - "symfony/property-info": "^6.4|^7.0" - }, - "require-dev": { - "symfony/cache": "^6.4|^7.0" + "php": ">=7.1" }, "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, "autoload": { + "files": [ + "bootstrap.php" + ], "psr-4": { - "Symfony\\Component\\PropertyAccess\\": "" + "Symfony\\Polyfill\\Php80\\": "" }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "Resources/stubs" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1742,29 +2414,28 @@ ], "authors": [ { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Provides functions to read and write from/to an object or array using a simple string notation", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ - "access", - "array", - "extraction", - "index", - "injection", - "object", - "property", - "property-path", - "reflection" + "compatibility", + "polyfill", + "portable", + "shim" ], "support": { - "source": "https://github.com/symfony/property-access/tree/v7.0.7" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" }, "funding": [ { @@ -1780,46 +2451,42 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:29:19+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { - "name": "symfony/property-info", - "version": "v7.0.7", + "name": "symfony/polyfill-php83", + "version": "v1.29.0", "source": { "type": "git", - "url": "https://github.com/symfony/property-info.git", - "reference": "f0bdb46e19ab308527b324b7ec36161f6880a532" + "url": "https://github.com/symfony/polyfill-php83.git", + "reference": "86fcae159633351e5fd145d1c47de6c528f8caff" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/property-info/zipball/f0bdb46e19ab308527b324b7ec36161f6880a532", - "reference": "f0bdb46e19ab308527b324b7ec36161f6880a532", + "url": "https://api.github.com/repos/symfony/polyfill-php83/zipball/86fcae159633351e5fd145d1c47de6c528f8caff", + "reference": "86fcae159633351e5fd145d1c47de6c528f8caff", "shasum": "" }, "require": { - "php": ">=8.2", - "symfony/string": "^6.4|^7.0" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "<5.2", - "phpdocumentor/type-resolver": "<1.5.1", - "symfony/dependency-injection": "<6.4", - "symfony/serializer": "<6.4" - }, - "require-dev": { - "phpdocumentor/reflection-docblock": "^5.2", - "phpstan/phpdoc-parser": "^1.0", - "symfony/cache": "^6.4|^7.0", - "symfony/dependency-injection": "^6.4|^7.0", - "symfony/serializer": "^6.4|^7.0" + "php": ">=7.1", + "symfony/polyfill-php80": "^1.14" }, "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, "autoload": { + "files": [ + "bootstrap.php" + ], "psr-4": { - "Symfony\\Component\\PropertyInfo\\": "" + "Symfony\\Polyfill\\Php83\\": "" }, - "exclude-from-classmap": [ - "/Tests/" + "classmap": [ + "Resources/stubs" ] }, "notification-url": "https://packagist.org/downloads/", @@ -1828,26 +2495,24 @@ ], "authors": [ { - "name": "Kévin Dunglas", - "email": "dunglas@gmail.com" + "name": "Nicolas Grekas", + "email": "p@tchwork.com" }, { "name": "Symfony Community", "homepage": "https://symfony.com/contributors" } ], - "description": "Extracts information about PHP class' properties using metadata of popular sources", + "description": "Symfony polyfill backporting some PHP 8.3+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ - "doctrine", - "phpdoc", - "property", - "symfony", - "type", - "validator" + "compatibility", + "polyfill", + "portable", + "shim" ], "support": { - "source": "https://github.com/symfony/property-info/tree/v7.0.7" + "source": "https://github.com/symfony/polyfill-php83/tree/v1.29.0" }, "funding": [ { @@ -1863,63 +2528,29 @@ "type": "tidelift" } ], - "time": "2024-04-28T11:44:19+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { - "name": "symfony/serializer", + "name": "symfony/process", "version": "v7.0.7", "source": { "type": "git", - "url": "https://github.com/symfony/serializer.git", - "reference": "08f0c517acf4b12dfc0d3963cd12f7b8023aea31" + "url": "https://github.com/symfony/process.git", + "reference": "3839e56b94dd1dbd13235d27504e66baf23faba0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/serializer/zipball/08f0c517acf4b12dfc0d3963cd12f7b8023aea31", - "reference": "08f0c517acf4b12dfc0d3963cd12f7b8023aea31", + "url": "https://api.github.com/repos/symfony/process/zipball/3839e56b94dd1dbd13235d27504e66baf23faba0", + "reference": "3839e56b94dd1dbd13235d27504e66baf23faba0", "shasum": "" }, "require": { - "php": ">=8.2", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "phpdocumentor/reflection-docblock": "<3.2.2", - "phpdocumentor/type-resolver": "<1.4.0", - "symfony/dependency-injection": "<6.4", - "symfony/property-access": "<6.4", - "symfony/property-info": "<6.4", - "symfony/uid": "<6.4", - "symfony/validator": "<6.4", - "symfony/yaml": "<6.4" - }, - "require-dev": { - "phpdocumentor/reflection-docblock": "^3.2|^4.0|^5.0", - "seld/jsonlint": "^1.10", - "symfony/cache": "^6.4|^7.0", - "symfony/config": "^6.4|^7.0", - "symfony/console": "^6.4|^7.0", - "symfony/dependency-injection": "^6.4|^7.0", - "symfony/error-handler": "^6.4|^7.0", - "symfony/filesystem": "^6.4|^7.0", - "symfony/form": "^6.4|^7.0", - "symfony/http-foundation": "^6.4|^7.0", - "symfony/http-kernel": "^6.4|^7.0", - "symfony/messenger": "^6.4|^7.0", - "symfony/mime": "^6.4|^7.0", - "symfony/property-access": "^6.4|^7.0", - "symfony/property-info": "^6.4|^7.0", - "symfony/translation-contracts": "^2.5|^3", - "symfony/uid": "^6.4|^7.0", - "symfony/validator": "^6.4|^7.0", - "symfony/var-dumper": "^6.4|^7.0", - "symfony/var-exporter": "^6.4|^7.0", - "symfony/yaml": "^6.4|^7.0" + "php": ">=8.2" }, "type": "library", "autoload": { "psr-4": { - "Symfony\\Component\\Serializer\\": "" + "Symfony\\Component\\Process\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -1939,10 +2570,10 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Handles serializing and deserializing data structures, including object graphs, into array structures or other formats like XML and JSON.", + "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/serializer/tree/v7.0.7" + "source": "https://github.com/symfony/process/tree/v7.0.7" }, "funding": [ { @@ -1958,7 +2589,7 @@ "type": "tidelift" } ], - "time": "2024-04-28T11:44:19+00:00" + "time": "2024-04-18T09:29:19+00:00" }, { "name": "symfony/service-contracts", @@ -2044,35 +2675,51 @@ "time": "2024-04-18T09:32:20+00:00" }, { - "name": "symfony/string", + "name": "symfony/translation", "version": "v7.0.7", "source": { "type": "git", - "url": "https://github.com/symfony/string.git", - "reference": "e405b5424dc2528e02e31ba26b83a79fd4eb8f63" + "url": "https://github.com/symfony/translation.git", + "reference": "1515e03afaa93e6419aba5d5c9d209159317100b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/string/zipball/e405b5424dc2528e02e31ba26b83a79fd4eb8f63", - "reference": "e405b5424dc2528e02e31ba26b83a79fd4eb8f63", + "url": "https://api.github.com/repos/symfony/translation/zipball/1515e03afaa93e6419aba5d5c9d209159317100b", + "reference": "1515e03afaa93e6419aba5d5c9d209159317100b", "shasum": "" }, "require": { "php": ">=8.2", - "symfony/polyfill-ctype": "~1.8", - "symfony/polyfill-intl-grapheme": "~1.0", - "symfony/polyfill-intl-normalizer": "~1.0", - "symfony/polyfill-mbstring": "~1.0" + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation-contracts": "^2.5|^3.0" }, "conflict": { - "symfony/translation-contracts": "<2.5" + "symfony/config": "<6.4", + "symfony/console": "<6.4", + "symfony/dependency-injection": "<6.4", + "symfony/http-client-contracts": "<2.5", + "symfony/http-kernel": "<6.4", + "symfony/service-contracts": "<2.5", + "symfony/twig-bundle": "<6.4", + "symfony/yaml": "<6.4" + }, + "provide": { + "symfony/translation-implementation": "2.3|3.0" }, "require-dev": { - "symfony/error-handler": "^6.4|^7.0", - "symfony/http-client": "^6.4|^7.0", + "nikic/php-parser": "^4.18|^5.0", + "psr/log": "^1|^2|^3", + "symfony/config": "^6.4|^7.0", + "symfony/console": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/finder": "^6.4|^7.0", + "symfony/http-client-contracts": "^2.5|^3.0", + "symfony/http-kernel": "^6.4|^7.0", "symfony/intl": "^6.4|^7.0", - "symfony/translation-contracts": "^2.5|^3.0", - "symfony/var-exporter": "^6.4|^7.0" + "symfony/polyfill-intl-icu": "^1.21", + "symfony/routing": "^6.4|^7.0", + "symfony/service-contracts": "^2.5|^3", + "symfony/yaml": "^6.4|^7.0" }, "type": "library", "autoload": { @@ -2080,7 +2727,7 @@ "Resources/functions.php" ], "psr-4": { - "Symfony\\Component\\String\\": "" + "Symfony\\Component\\Translation\\": "" }, "exclude-from-classmap": [ "/Tests/" @@ -2090,6 +2737,76 @@ "license": [ "MIT" ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools to internationalize your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/translation/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, + { + "name": "symfony/translation-contracts", + "version": "v3.5.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation-contracts.git", + "reference": "b9d2189887bb6b2e0367a9fc7136c5239ab9b05a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/b9d2189887bb6b2e0367a9fc7136c5239ab9b05a", + "reference": "b9d2189887bb6b2e0367a9fc7136c5239ab9b05a", + "shasum": "" + }, + "require": { + "php": ">=8.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.5-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Test/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], "authors": [ { "name": "Nicolas Grekas", @@ -2100,18 +2817,18 @@ "homepage": "https://symfony.com/contributors" } ], - "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "description": "Generic abstractions related to translation", "homepage": "https://symfony.com", "keywords": [ - "grapheme", - "i18n", - "string", - "unicode", - "utf-8", - "utf8" + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" ], "support": { - "source": "https://github.com/symfony/string/tree/v7.0.7" + "source": "https://github.com/symfony/translation-contracts/tree/v3.5.0" }, "funding": [ { @@ -2127,7 +2844,7 @@ "type": "tidelift" } ], - "time": "2024-04-18T09:29:19+00:00" + "time": "2024-04-18T09:32:20+00:00" }, { "name": "symfony/var-exporter", @@ -2258,23 +2975,97 @@ "description": "Loads and dumps YAML files", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/yaml/tree/v7.0.7" + "source": "https://github.com/symfony/yaml/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-28T11:44:19+00:00" + }, + { + "name": "voku/portable-ascii", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/voku/portable-ascii.git", + "reference": "b56450eed252f6801410d810c8e1727224ae0743" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/voku/portable-ascii/zipball/b56450eed252f6801410d810c8e1727224ae0743", + "reference": "b56450eed252f6801410d810c8e1727224ae0743", + "shasum": "" + }, + "require": { + "php": ">=7.0.0" + }, + "require-dev": { + "phpunit/phpunit": "~6.0 || ~7.0 || ~9.0" + }, + "suggest": { + "ext-intl": "Use Intl for transliterator_transliterate() support" + }, + "type": "library", + "autoload": { + "psr-4": { + "voku\\": "src/voku/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Lars Moelleken", + "homepage": "http://www.moelleken.org/" + } + ], + "description": "Portable ASCII library - performance optimized (ascii) string functions for php.", + "homepage": "https://github.com/voku/portable-ascii", + "keywords": [ + "ascii", + "clean", + "php" + ], + "support": { + "issues": "https://github.com/voku/portable-ascii/issues", + "source": "https://github.com/voku/portable-ascii/tree/2.0.1" }, "funding": [ { - "url": "https://symfony.com/sponsor", + "url": "https://www.paypal.me/moelleken", "type": "custom" }, { - "url": "https://github.com/fabpot", + "url": "https://github.com/voku", "type": "github" }, { - "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "url": "https://opencollective.com/portable-ascii", + "type": "open_collective" + }, + { + "url": "https://www.patreon.com/voku", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/voku/portable-ascii", "type": "tidelift" } ], - "time": "2024-04-28T11:44:19+00:00" + "time": "2022-03-08T17:03:00+00:00" }, { "name": "webmozart/assert", @@ -5250,6 +6041,251 @@ ], "time": "2024-04-18T09:29:19+00:00" }, + { + "name": "symfony/polyfill-intl-grapheme", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-grapheme.git", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-grapheme/zipball/32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "reference": "32a9da87d7b3245e09ac426c83d334ae9f06f80f", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Grapheme\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's grapheme_* functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "grapheme", + "intl", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-grapheme/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/polyfill-intl-normalizer", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-intl-normalizer.git", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-intl-normalizer/zipball/bc45c394692b948b4d383a08d7753968bed9a83d", + "reference": "bc45c394692b948b4d383a08d7753968bed9a83d", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "suggest": { + "ext-intl": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Intl\\Normalizer\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for intl's Normalizer class and related functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "intl", + "normalizer", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-intl-normalizer/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, + { + "name": "symfony/string", + "version": "v7.0.7", + "source": { + "type": "git", + "url": "https://github.com/symfony/string.git", + "reference": "e405b5424dc2528e02e31ba26b83a79fd4eb8f63" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/string/zipball/e405b5424dc2528e02e31ba26b83a79fd4eb8f63", + "reference": "e405b5424dc2528e02e31ba26b83a79fd4eb8f63", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "~1.8", + "symfony/polyfill-intl-grapheme": "~1.0", + "symfony/polyfill-intl-normalizer": "~1.0", + "symfony/polyfill-mbstring": "~1.0" + }, + "conflict": { + "symfony/translation-contracts": "<2.5" + }, + "require-dev": { + "symfony/error-handler": "^6.4|^7.0", + "symfony/http-client": "^6.4|^7.0", + "symfony/intl": "^6.4|^7.0", + "symfony/translation-contracts": "^2.5|^3.0", + "symfony/var-exporter": "^6.4|^7.0" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\String\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides an object-oriented API to strings and deals with bytes, UTF-8 code points and grapheme clusters in a unified way", + "homepage": "https://symfony.com", + "keywords": [ + "grapheme", + "i18n", + "string", + "unicode", + "utf-8", + "utf8" + ], + "support": { + "source": "https://github.com/symfony/string/tree/v7.0.7" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-04-18T09:29:19+00:00" + }, { "name": "symfony/var-dumper", "version": "v7.0.7", diff --git a/src/Model/BaseModel.php b/src/Model/BaseModel.php index 29927515..47ef9728 100644 --- a/src/Model/BaseModel.php +++ b/src/Model/BaseModel.php @@ -2,164 +2,10 @@ namespace SupportPal\ApiClient\Model; -use SupportPal\ApiClient\Exception\InvalidArgumentException; -use SupportPal\ApiClient\Exception\MissingRequiredFieldsException; -use SupportPal\ApiClient\Helper\StringHelper; -use SupportPal\ApiClient\Transformer\AttributeAwareTransformer; -use SupportPal\ApiClient\Transformer\IntToBooleanTransformer; -use SupportPal\ApiClient\Transformer\StringTrimTransformer; -use SupportPal\ApiClient\Transformer\Transformer; -use Symfony\Component\PropertyInfo\Extractor\ReflectionExtractor; -use Symfony\Component\Serializer\Attribute\SerializedName; -use TypeError; +use Illuminate\Database\Eloquent\Model; -use function array_push; -use function count; -use function get_class; -use function implode; -use function is_string; -use function method_exists; - -/** - * Class BaseModel - * @package SupportPal\ApiClient\Model - */ -abstract class BaseModel implements Model +abstract class BaseModel extends Model { - public const REQUIRED_FIELDS = []; - - use StringHelper; - - /** @var array|null */ - #[SerializedName('pivot')] - private ?array $pivot = null; - - /** - * @inheritDoc - */ - public function fill(array $data): Model - { - foreach ($data as $key => $value) { - if (! is_string($key)) { - throw new InvalidArgumentException( - 'Supplied input must be an associative array of template: array' - ); - } - } - - $attributeAwareTransformers = [new IntToBooleanTransformer(new ReflectionExtractor),]; - $transformers = [new StringTrimTransformer,]; - - $this->assertRequiredFieldsExists($data); - foreach ($data as $key => $value) { - $attributeSetter = 'set' . $this->snakeCaseToPascalCase($key); - if (! method_exists($this, $attributeSetter)) { - continue; - } - - $value = $this->applyAttributeAwareTransformers($attributeAwareTransformers, $key, $value); - $value = $this->applyValueTransformers($transformers, $value); - $this->setAttributeValue($attributeSetter, $value); - } - - return $this; - } - - /** - * @return string[] - */ - protected function getRequiredFields(): array - { - return static::REQUIRED_FIELDS; - } - - /** - * This functions asserts that all the required values for the API are passed correctly - * @param array $data - */ - protected function assertRequiredFieldsExists(array $data): void - { - $missingFields = []; - foreach ($this->getRequiredFields() as $required) { - if (isset($data[$required])) { - continue; - } - - array_push($missingFields, $required); - } - - if (count($missingFields) > 0) { - throw new MissingRequiredFieldsException( - 'incomplete required fields, the following are missing: ' . implode(',', $missingFields) - ); - } - } - - /** - * @return array|null - */ - public function getPivot(): ?array - { - return $this->pivot; - } - - /** - * @param array|null $pivot - */ - public function setPivot(?array $pivot): self - { - $this->pivot = $pivot; - - return $this; - } - - /** - * @param AttributeAwareTransformer[] $attributeAwareTransformers - * @return mixed - */ - private function applyAttributeAwareTransformers(array $attributeAwareTransformers, string $key, mixed $value) - { - foreach ($attributeAwareTransformers as $transformer) { - if (! $transformer->canTransform($this->snakeCaseToCamelCase($key), get_class($this), $value)) { - continue; - } - - $value = $transformer->transform($value); - } - - return $value; - } - - /** - * @throws InvalidArgumentException - */ - private function setAttributeValue(string $attributeSetter, mixed $value): void - { - try { - $this->{$attributeSetter}($value); - } catch (TypeError $exception) { - throw new InvalidArgumentException( - $exception->getMessage(), - $exception->getCode(), - $exception->getPrevious() - ); - } - } - - /** - * @param Transformer[] $transformers - * @return mixed - */ - private function applyValueTransformers(array $transformers, mixed $value) - { - foreach ($transformers as $transformer) { - if (! $transformer->canTransform($value)) { - continue; - } - - $value = $transformer->transform($value); - } - - return $value; - } + /** @var string[] */ + protected $guarded = []; } diff --git a/src/Model/BaseTranslation.php b/src/Model/BaseTranslation.php index a247e58e..0c15290d 100644 --- a/src/Model/BaseTranslation.php +++ b/src/Model/BaseTranslation.php @@ -2,22 +2,14 @@ namespace SupportPal\ApiClient\Model; -use Symfony\Component\Serializer\Attribute\SerializedName; +use function array_merge; abstract class BaseTranslation extends BaseModel { - #[SerializedName('locale')] - private string $locale; - - public function getLocale(): string - { - return $this->locale; - } - - public function setLocale(string $locale): self + public function __construct(array $attributes = []) { - $this->locale = $locale; + $this->casts = array_merge($this->casts, ['locale' => 'string']); - return $this; + parent::__construct($attributes); } } diff --git a/src/Model/Model.php b/src/Model/Model.php deleted file mode 100644 index c018ed1f..00000000 --- a/src/Model/Model.php +++ /dev/null @@ -1,14 +0,0 @@ - $data - * @throws InvalidArgumentException - */ - public function fill(array $data): Model; -} diff --git a/src/Normalizer/ModelNormalizer.php b/src/Normalizer/ModelNormalizer.php deleted file mode 100644 index feb9827d..00000000 --- a/src/Normalizer/ModelNormalizer.php +++ /dev/null @@ -1,143 +0,0 @@ -normalizer = $normalizer; - $this->transformers = $transformers; - $this->attributeAwareTransformers = $attributeAwareTransformers; - } - - /** - * @inheritDoc - */ - public function normalize(mixed $object, ?string $format = null, array $context = []): float|array|ArrayObject|bool|int|string|null - { - $data = $this->normalizer->normalize($object, $format, $context); - - return $this->applyArrayTransformations($data); - } - - /** - * @inheritDoc - */ - public function denormalize(mixed $data, string|int|bool|array|float $type, ?string $format = null, array $context = []): mixed - { - $data = $this->applyAttributeAwareTransformations($data, $type); - /** @var Model $model */ - $model = $this->normalizer->denormalize($data, $type, $format, $context); - - return $this->applyModelTransformations($model); - } - - /** - * @inheritDoc - */ - public function supportsNormalization($data, ?string $format = null, array $context = []): bool - { - return $data instanceof Model || $this->normalizer->supportsNormalization($data, $format); - } - - /** - * @inheritDoc - */ - public function supportsDenormalization($data, string $type, ?string $format = null, array $context = []): bool - { - return $this->normalizer->supportsDenormalization($data, $type, $format); - } - - /** - * @param Model $model - * @return Model - */ - protected function applyModelTransformations(Model $model) - { - foreach ($this->transformers as $transformer) { - if (! $transformer->canTransform($model)) { - continue; - } - - $model = $transformer->transform($model); - } - - return $model; - } - - /** - * @param array $data - * @param string $type - * @return array - */ - protected function applyAttributeAwareTransformations(array $data, string $type): array - { - foreach ($data as $key => $value) { - foreach ($this->attributeAwareTransformers as $transformer) { - if (! $transformer->canTransform($this->snakeCaseToCamelCase($key), $type, $value)) { - continue; - } - - $data[$key] = $transformer->transform($value); - } - } - - return $data; - } - - /** - * @param array $data - * @return array - */ - protected function applyArrayTransformations(array $data): array - { - foreach ($data as $key => $value) { - foreach ($this->transformers as $transformer) { - if (! $transformer->canTransform($value)) { - continue; - } - - $data[$key] = $transformer->transform($value); - } - } - - return $data; - } - - /** - * @inheritDoc - */ - public function getSupportedTypes(?string $format): array - { - return $this->normalizer->getSupportedTypes($format); - } -} diff --git a/src/Transformer/AttributeAwareTransformer.php b/src/Transformer/AttributeAwareTransformer.php deleted file mode 100644 index 20cd9f6f..00000000 --- a/src/Transformer/AttributeAwareTransformer.php +++ /dev/null @@ -1,20 +0,0 @@ -{$method}()) { - return $value; - } - } catch (TypeError $typeError) { - /** - * non-nullable field not initiated (i.e Error: Typed property not initialized) - */ - continue; - } catch (Error $error) { - if (str_contains($error->getMessage(), sprintf('must not be accessed before initialization'))) { - continue; - } - - throw $error; - } - } - - return null; - } -} diff --git a/src/Transformer/IntToBooleanTransformer.php b/src/Transformer/IntToBooleanTransformer.php deleted file mode 100644 index 74ed5221..00000000 --- a/src/Transformer/IntToBooleanTransformer.php +++ /dev/null @@ -1,57 +0,0 @@ -propertyTypeExtractor = $propertyTypeExtractor; - } - - /** - * @inheritDoc - */ - public function canTransform(string $attribute, string $class, $value): bool - { - return is_int($value) - && in_array($value, [0, 1], true) - && $this->isBoolAttribute($class, $attribute); - } - - /** - * @inheritDoc - */ - public function transform($value) - { - return boolval($value); - } - - /** - * @param string $class - * @param string $attribute - * @return bool - */ - protected function isBoolAttribute(string $class, string $attribute) - { - /** @var Type[] $types */ - $types = $this->propertyTypeExtractor->getTypes($class, $attribute) ?? []; - - $boolFilteredType = array_filter($types, function (Type $type) { - return $type->getBuiltinType() === Type::BUILTIN_TYPE_BOOL; - }); - - return ! empty($boolFilteredType); - } -} diff --git a/src/Transformer/StringTrimTransformer.php b/src/Transformer/StringTrimTransformer.php deleted file mode 100644 index 1697bf8d..00000000 --- a/src/Transformer/StringTrimTransformer.php +++ /dev/null @@ -1,25 +0,0 @@ - Date: Wed, 22 May 2024 19:16:38 +0100 Subject: [PATCH 02/20] feat: use jenssegers/model --- composer.json | 2 +- composer.lock | 232 ++--- src/Api/Api.php | 48 +- src/Api/ApiAware.php | 24 - src/Api/SelfService/CommentApis.php | 14 +- src/Api/Ticket/AttachmentApis.php | 15 +- src/Api/Ticket/MessageApis.php | 13 +- src/Api/Ticket/TicketApis.php | 29 +- src/Api/User/UserApis.php | 29 +- src/ApiClient.php | 28 +- src/Converter/ModelToArrayConverter.php | 42 - src/Factory/BaseModelFactory.php | 63 -- src/Factory/Core/BrandFactory.php | 4 +- src/Factory/ModelFactory.php | 22 +- src/Factory/RequestFactory.php | 16 +- src/Factory/SelfService/ArticleFactory.php | 4 +- src/Factory/SelfService/CategoryFactory.php | 4 +- src/Factory/SelfService/CommentFactory.php | 4 +- src/Factory/SelfService/TagFactory.php | 4 +- src/Factory/SelfService/TypeFactory.php | 4 +- src/Factory/Shared/SettingsFactory.php | 4 +- src/Factory/Ticket/AttachmentFactory.php | 4 +- src/Factory/Ticket/ChannelSettingsFactory.php | 4 +- src/Factory/Ticket/CustomFieldFactory.php | 4 +- src/Factory/Ticket/DepartmentFactory.php | 4 +- src/Factory/Ticket/MessageFactory.php | 4 +- src/Factory/Ticket/PriorityFactory.php | 4 +- src/Factory/Ticket/StatusFactory.php | 4 +- src/Factory/Ticket/TicketFactory.php | 4 +- src/Factory/User/GroupFactory.php | 4 +- src/Factory/User/UserCustomFieldFactory.php | 4 +- src/Factory/User/UserFactory.php | 4 +- src/Model/Core/Brand.php | 623 +------------ src/Model/Core/BrandTranslation.php | 58 +- src/Model/Core/Upload.php | 168 +--- src/Model/Department/Department.php | 394 +-------- .../Department/DepartmentTranslation.php | 74 +- src/Model/Department/Email.php | 290 +----- src/Model/Department/EmailTemplates.php | 279 +----- src/Model/{BaseModel.php => Model.php} | 4 +- src/Model/SelfService/Article.php | 420 +-------- src/Model/SelfService/ArticleAttachment.php | 134 +-- src/Model/SelfService/ArticleTranslation.php | 152 +--- src/Model/SelfService/Category.php | 222 +---- src/Model/SelfService/CategoryTranslation.php | 110 +-- src/Model/SelfService/Comment.php | 281 +----- .../SelfService/Request/CreateComment.php | 76 +- src/Model/SelfService/Tag.php | 110 +-- src/Model/SelfService/TagTranslation.php | 71 +- src/Model/SelfService/Type.php | 328 +------ src/Model/SelfService/TypeTranslation.php | 87 +- src/Model/SettingsModel.php | 15 - src/Model/Shared/CustomField.php | 320 +------ src/Model/Shared/Option.php | 126 +-- src/Model/Shared/OptionTranslation.php | 61 +- src/Model/Shared/Settings.php | 39 +- src/Model/Ticket/Attachment.php | 215 +---- src/Model/Ticket/Channel.php | 151 +--- src/Model/Ticket/ChannelSettings.php | 71 +- src/Model/Ticket/Extra.php | 76 +- src/Model/Ticket/Message.php | 305 +------ src/Model/Ticket/Priority.php | 180 +--- src/Model/Ticket/PriorityTranslation.php | 58 +- src/Model/Ticket/Request/CreateMessage.php | 100 +-- src/Model/Ticket/Request/CreateTicket.php | 229 +---- src/Model/Ticket/SlaPlan.php | 158 +--- src/Model/Ticket/SlaPlanTranslation.php | 74 +- src/Model/Ticket/Status.php | 174 +--- src/Model/Ticket/StatusTranslation.php | 58 +- src/Model/Ticket/Tag.php | 142 +-- src/Model/Ticket/TagTranslation.php | 58 +- src/Model/Ticket/Ticket.php | 832 ++---------------- src/Model/Ticket/TicketCustomField.php | 80 +- .../Ticket/TicketCustomFieldTranslation.php | 90 +- .../{BaseTranslation.php => Translation.php} | 5 +- src/Model/User/Domain.php | 40 +- src/Model/User/Group.php | 142 +-- src/Model/User/GroupTranslation.php | 74 +- src/Model/User/Organisation.php | 236 +---- src/Model/User/Request/CreateUser.php | 154 +--- src/Model/User/User.php | 543 +----------- src/Model/User/UserCustomField.php | 41 +- src/Model/User/UserCustomFieldTranslation.php | 90 +- src/Resources/api.yml | 3 +- src/Resources/api_client.yml | 1 - src/Resources/core_services.yml | 4 - src/Resources/factories.yml | 42 +- src/Resources/library_services.yml | 42 - src/Resources/services.yml | 20 - test/ApiTestCase.php | 9 +- test/ContainerAwareBaseTestCase.php | 41 +- test/Functional/SupportPalTest.php | 5 +- test/Resources/services_test.yml | 72 +- test/TestCase.php | 9 +- test/Unit/Api/SelfService/CommentApisTest.php | 18 +- test/Unit/Api/Ticket/AttachmentApisTest.php | 6 +- test/Unit/Api/Ticket/MessageApisTest.php | 15 +- test/Unit/Api/Ticket/TicketApisTest.php | 20 +- test/Unit/Api/User/UserApisTest.php | 20 +- test/Unit/ApiClientTest.php | 24 - test/Unit/ApiTest.php | 91 +- .../Converter/ModelToArrayConverterTest.php | 54 -- test/Unit/Factory/BaseModelFactoryTest.php | 8 +- .../Unit/Factory/BaseModelFactoryTestCase.php | 71 -- test/Unit/Factory/Core/BrandFactoryTest.php | 6 +- .../Factory/ModelCollectionFactoryTest.php | 4 +- test/Unit/Factory/RequestFactoryTest.php | 31 +- .../SelfService/ArticleFactoryTest.php | 6 +- .../SelfService/CategoryFactoryTest.php | 6 +- .../SelfService/CommentFactoryTest.php | 6 +- .../Factory/SelfService/TagFactoryTest.php | 6 +- .../Factory/SelfService/TypeFactoryTest.php | 6 +- .../Factory/Shared/SettingsFactoryTest.php | 6 +- .../Factory/Ticket/AttachmentFactoryTest.php | 6 +- .../Ticket/ChannelSettingsFactoryTest.php | 6 +- .../Factory/Ticket/CustomFieldFactoryTest.php | 6 +- .../Factory/Ticket/DepartmentFactoryTest.php | 6 +- .../Factory/Ticket/MessageFactoryTest.php | 6 +- .../Factory/Ticket/PriorityFactoryTest.php | 6 +- .../Unit/Factory/Ticket/StatusFactoryTest.php | 6 +- .../Unit/Factory/Ticket/TicketFactoryTest.php | 6 +- .../User/UserCustomFieldFactoryTest.php | 6 +- test/Unit/Factory/User/UserFactoryTest.php | 6 +- .../Factory/User/UserGroupFactoryTest.php | 6 +- test/Unit/Model/BaseModelTestCase.php | 54 +- test/Unit/Model/Collection/CollectionTest.php | 12 +- test/Unit/Model/SelfService/CommentTest.php | 31 +- test/Unit/Model/Shared/SettingsTest.php | 8 +- .../ModelNormalizer/ModelNormalizerTest.php | 201 ----- .../BooleanToIntTransformerTest.php | 79 -- .../EmptyModelToNullTransformerTest.php | 107 --- .../IntToBooleanTransformerTest.php | 158 ---- .../Transformer/StringTrimTransformerTest.php | 73 -- 133 files changed, 983 insertions(+), 9925 deletions(-) delete mode 100644 src/Converter/ModelToArrayConverter.php delete mode 100644 src/Factory/BaseModelFactory.php rename src/Model/{BaseModel.php => Model.php} (61%) delete mode 100644 src/Model/SettingsModel.php rename src/Model/{BaseTranslation.php => Translation.php} (75%) delete mode 100644 src/Resources/library_services.yml delete mode 100644 test/Unit/Converter/ModelToArrayConverterTest.php delete mode 100644 test/Unit/ModelNormalizer/ModelNormalizerTest.php delete mode 100644 test/Unit/Transformer/BooleanToIntTransformerTest.php delete mode 100644 test/Unit/Transformer/EmptyModelToNullTransformerTest.php delete mode 100644 test/Unit/Transformer/IntToBooleanTransformerTest.php delete mode 100644 test/Unit/Transformer/StringTrimTransformerTest.php 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']; - } -} From 8d49a65dc1670b09014f85bf467f0004022d817b Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Fri, 24 May 2024 16:44:04 +0100 Subject: [PATCH 03/20] fix phpcd --- test/Unit/Factory/RequestFactoryTest.php | 52 ++++++++++++------------ 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/test/Unit/Factory/RequestFactoryTest.php b/test/Unit/Factory/RequestFactoryTest.php index abc78de3..ddf1afa3 100644 --- a/test/Unit/Factory/RequestFactoryTest.php +++ b/test/Unit/Factory/RequestFactoryTest.php @@ -91,19 +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($defaultBody, $data['body']); - [$encodedBody, $headersArray, $request] = $this - ->commonCreateRequest($expectedBody, $defaultBody, $defaultParameters, $data); - - self::assertInstanceOf(Request::class, $request); - self::assertSame($data['method'], $request->getMethod()); - self::assertSame('test' . $data['endpoint'], $request->getUri()->getPath()); - self::assertEquals($headersArray, $request->getHeaders()); - self::assertSame($encodedBody, json_decode($request->getBody()->getContents(), true)); - self::assertSame( - http_build_query(array_merge($defaultParameters, $data['parameters'])), - $request->getUri()->getQuery() - ); + $this->createAndAssert($defaultBody, $data, $defaultParameters); } public function testProvidedDataOverwritesDefaults(): void @@ -111,7 +99,6 @@ public function testProvidedDataOverwritesDefaults(): void $defaultParameters = ['testparams' => 'value']; $defaultBody = ['testbody' => 'value']; - $data = [ 'method' => 'DELETE', 'endpoint' => 'test/api/core', @@ -120,19 +107,7 @@ public function testProvidedDataOverwritesDefaults(): void 'parameters' => ['testparams' => 'overwrite_value'] ]; - $expectedBody = array_merge($defaultBody, $data['body']); - [$encodedBody, $headersArray, $request] = $this - ->commonCreateRequest($expectedBody, $defaultBody, $defaultParameters, $data); - - self::assertInstanceOf(Request::class, $request); - self::assertSame($data['method'], $request->getMethod()); - self::assertSame('test' . $data['endpoint'], $request->getUri()->getPath()); - self::assertEquals($headersArray, $request->getHeaders()); - self::assertSame($encodedBody, json_decode($request->getBody()->getContents(), true)); - self::assertSame( - http_build_query(array_merge($defaultParameters, $data['parameters'])), - $request->getUri()->getQuery() - ); + $this->createAndAssert($defaultBody, $data, $defaultParameters); } /** @@ -231,4 +206,27 @@ private function commonCreateRequest( return [$expectedBody, $headersArray, $request]; } + + /** + * @param mixed[] $defaultBody + * @param mixed[] $data + * @param mixed[] $defaultParameters + * @return void + */ + private function createAndAssert(array $defaultBody, array $data, array $defaultParameters): void + { + $expectedBody = array_merge($defaultBody, $data['body']); + [$encodedBody, $headersArray, $request] = $this + ->commonCreateRequest($expectedBody, $defaultBody, $defaultParameters, $data); + + self::assertInstanceOf(Request::class, $request); + self::assertSame($data['method'], $request->getMethod()); + self::assertSame('test' . $data['endpoint'], $request->getUri()->getPath()); + self::assertEquals($headersArray, $request->getHeaders()); + self::assertSame($encodedBody, json_decode($request->getBody()->getContents(), true)); + self::assertSame( + http_build_query(array_merge($defaultParameters, $data['parameters'])), + $request->getUri()->getQuery() + ); + } } From 9250bdb62c4e40b749006e8aca33522b1ec805b8 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Fri, 24 May 2024 17:05:43 +0100 Subject: [PATCH 04/20] fix phpstan --- phpstan.neon | 1 - src/Factory/ModelFactory.php | 7 +- src/Model/SelfService/Comment.php | 1 + .../SelfService/Request/CreateComment.php | 49 ------ src/Model/Shared/CustomField.php | 1 + src/Model/Ticket/Request/CreateMessage.php | 67 -------- src/Model/Ticket/Request/CreateTicket.php | 156 ------------------ src/Model/User/Request/CreateUser.php | 103 ------------ test/ApiTestCase.php | 2 +- test/Cache/CacheableApisTest.php | 10 +- test/E2E/BaseTestCase.php | 13 +- test/Integration/ApiClientTest.php | 12 +- .../Converter/ModelToArrayConverterTest.php | 47 ------ .../Factory/RequestFactoryTest.php | 2 +- .../ModelNormalizer/ModelNormalizerTest.php | 152 ----------------- test/TestCase.php | 8 +- test/Unit/ApiTest.php | 5 - test/Unit/Model/Collection/CollectionTest.php | 12 +- 18 files changed, 27 insertions(+), 621 deletions(-) delete mode 100644 test/Integration/Converter/ModelToArrayConverterTest.php delete mode 100644 test/Integration/ModelNormalizer/ModelNormalizerTest.php diff --git a/phpstan.neon b/phpstan.neon index 05b78c8d..bb671777 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -8,7 +8,6 @@ parameters: - test inferPrivatePropertyTypeFromConstructor: true excludePaths: - - src/Normalizer/ModelNormalizer.php - test/DataFixtures - test/PhpUnit parallel: diff --git a/src/Factory/ModelFactory.php b/src/Factory/ModelFactory.php index 87686c79..16923fd7 100644 --- a/src/Factory/ModelFactory.php +++ b/src/Factory/ModelFactory.php @@ -12,11 +12,14 @@ abstract class ModelFactory { /** - * @inheritDoc + * @param mixed[] $data */ public function create(array $data): Model { - return (new ($this->getModel))->fill($data); + /** @var Model $model */ + $model = new ($this->getModel()); + + return $model->fill($data); } abstract public function getModel(): string; diff --git a/src/Model/SelfService/Comment.php b/src/Model/SelfService/Comment.php index 58309b1f..946bfe09 100644 --- a/src/Model/SelfService/Comment.php +++ b/src/Model/SelfService/Comment.php @@ -13,6 +13,7 @@ class Comment extends Model 'article_id' => 'int', 'type_id' => 'int', 'author_id' => 'int', + 'name' => 'string', 'text' => 'string', 'purified_text' => 'string', 'parent_id' => 'int', diff --git a/src/Model/SelfService/Request/CreateComment.php b/src/Model/SelfService/Request/CreateComment.php index 0a10f200..272ec2cf 100644 --- a/src/Model/SelfService/Request/CreateComment.php +++ b/src/Model/SelfService/Request/CreateComment.php @@ -3,7 +3,6 @@ namespace SupportPal\ApiClient\Model\SelfService\Request; use SupportPal\ApiClient\Model\Model; -use Symfony\Component\Serializer\Attribute\SerializedName; class CreateComment extends Model { @@ -13,67 +12,19 @@ class CreateComment extends Model 'text', ]; - #[SerializedName('article_id')] protected int $articleId; - #[SerializedName('type_id')] protected int $typeId; - #[SerializedName('parent_id')] protected ?int $parentId; - #[SerializedName('author_id')] protected ?int $authorId; - #[SerializedName('name')] protected ?string $name; - #[SerializedName('text')] protected string $text; - #[SerializedName('status')] protected ?int $status; - #[SerializedName('notify_reply')] protected ?bool $notifyReply; - - public function getArticleId(): int - { - return $this->articleId; - } - - public function getTypeId(): int - { - return $this->typeId; - } - - public function getParentId(): ?int - { - return $this->parentId; - } - - public function getAuthorId(): ?int - { - return $this->authorId; - } - - public function getName(): ?string - { - return $this->name; - } - - public function getText(): string - { - return $this->text; - } - - public function getStatus(): ?int - { - return $this->status; - } - - public function getNotifyReply(): ?bool - { - return $this->notifyReply; - } } diff --git a/src/Model/Shared/CustomField.php b/src/Model/Shared/CustomField.php index 4b8eb717..6ae23e62 100644 --- a/src/Model/Shared/CustomField.php +++ b/src/Model/Shared/CustomField.php @@ -29,6 +29,7 @@ abstract class CustomField extends Model public const TYPE_RATING = 10; + /** @var array */ protected $casts = [ 'id' => 'int', 'name' => 'string', diff --git a/src/Model/Ticket/Request/CreateMessage.php b/src/Model/Ticket/Request/CreateMessage.php index 3d0f52e2..2be87b0c 100644 --- a/src/Model/Ticket/Request/CreateMessage.php +++ b/src/Model/Ticket/Request/CreateMessage.php @@ -3,7 +3,6 @@ namespace SupportPal\ApiClient\Model\Ticket\Request; use SupportPal\ApiClient\Model\Model; -use Symfony\Component\Serializer\Attribute\SerializedName; class CreateMessage extends Model { @@ -13,91 +12,25 @@ class CreateMessage extends Model 'text', ]; - #[SerializedName('ticket_id')] protected int $ticketId; - #[SerializedName('user_id')] protected int $userId; - #[SerializedName('user_ip_address')] protected string|null $userIpAddress; - #[SerializedName('message_type')] protected int|null $messageType; - #[SerializedName('text')] protected string $text; /** @var string[]|null */ - #[SerializedName('cc')] protected array|null $cc; - #[SerializedName('is_draft')] protected bool|null $isDraft; - #[SerializedName('send_user_email')] protected bool|null $sendUserEmail; - #[SerializedName('send_operators_email')] protected bool|null $sendOperatorsEmail; /** @var string[]|null */ - #[SerializedName('attachment')] protected array|null $attachment; - - public function getTicketId(): int - { - return $this->ticketId; - } - - public function getUserId(): int - { - return $this->userId; - } - - public function getUserIpAddress(): ?string - { - return $this->userIpAddress; - } - - public function getMessageType(): ?int - { - return $this->messageType; - } - - public function getText(): string - { - return $this->text; - } - - /** - * @return string[]|null - */ - public function getCc(): ?array - { - return $this->cc; - } - - public function getIsDraft(): ?bool - { - return $this->isDraft; - } - - public function getSendUserEmail(): ?bool - { - return $this->sendUserEmail; - } - - public function getSendOperatorsEmail(): ?bool - { - return $this->sendOperatorsEmail; - } - - /** - * @return string[]|null - */ - public function getAttachment(): ?array - { - return $this->attachment; - } } diff --git a/src/Model/Ticket/Request/CreateTicket.php b/src/Model/Ticket/Request/CreateTicket.php index 7f8c699d..82ca274a 100644 --- a/src/Model/Ticket/Request/CreateTicket.php +++ b/src/Model/Ticket/Request/CreateTicket.php @@ -3,7 +3,6 @@ namespace SupportPal\ApiClient\Model\Ticket\Request; use SupportPal\ApiClient\Model\Model; -use Symfony\Component\Serializer\Attribute\SerializedName; class CreateTicket extends Model { @@ -15,211 +14,56 @@ class CreateTicket extends Model 'text', ]; - #[SerializedName('user')] protected int|null $user; - #[SerializedName('on_behalf_of')] protected int|null $onBehalfOf; - #[SerializedName('user_firstname')] protected string|null $userFirstname; - #[SerializedName('user_lastname')] protected string|null $userLastname; - #[SerializedName('user_email')] protected string|null $userEmail; - #[SerializedName('user_organisation')] protected string|null $userOrganisation; - #[SerializedName('user_ip_address')] protected string|null $userIpAddress; - #[SerializedName('department')] protected int $department; - #[SerializedName('brand')] protected int|null $brand; - #[SerializedName('status')] protected int $status; - #[SerializedName('priority')] protected int $priority; - #[SerializedName('internal')] protected bool|null $internal; - #[SerializedName('subject')] protected string $subject; - #[SerializedName('text')] protected string $text; /** @var int[]|null */ - #[SerializedName('tag')] protected array|null $tag; /** @var int[]|null */ - #[SerializedName('assignedto')] protected array|null $assignedto; /** @var int[]|null */ - #[SerializedName('watching')] protected array|null $watching; /** @var int[]|null */ - #[SerializedName('customfield')] protected array|null $customfield; /** @var string[]|null */ - #[SerializedName('cc')] protected array|null $cc; - #[SerializedName('send_user_email')] protected int|null $sendUserEmail; - #[SerializedName('send_operators_email')] protected int|null $sendOperatorsEmail; /** @var string[]|null */ - #[SerializedName('attachment')] protected array|null $attachment; - #[SerializedName('created_at')] protected int|null $createdAt; - public function getUser(): ?int - { - return $this->user; - } - - public function getOnBehalfOf(): ?int - { - return $this->onBehalfOf; - } - - public function getUserFirstname(): ?string - { - return $this->userFirstname; - } - - public function getUserLastname(): ?string - { - return $this->userLastname; - } - - public function getUserEmail(): ?string - { - return $this->userEmail; - } - - public function getUserOrganisation(): ?string - { - return $this->userOrganisation; - } - - public function getUserIpAddress(): ?string - { - return $this->userIpAddress; - } - - public function getDepartment(): int - { - return $this->department; - } - - public function getBrand(): ?int - { - return $this->brand; - } - - public function getStatus(): int - { - return $this->status; - } - - public function getPriority(): int - { - return $this->priority; - } - - public function getInternal(): ?bool - { - return $this->internal; - } - - public function getSubject(): string - { - return $this->subject; - } - - public function getText(): string - { - return $this->text; - } - - /** - * @return int[]|null - */ - public function getTag(): ?array - { - return $this->tag; - } - - /** - * @return int[]|null - */ - public function getAssignedto(): ?array - { - return $this->assignedto; - } - - /** - * @return int[]|null - */ - public function getWatching(): ?array - { - return $this->watching; - } - - /** - * @return int[]|null - */ - public function getCustomfield(): ?array - { - return $this->customfield; - } - - /** - * @return string[]|null - */ - public function getCc(): ?array - { - return $this->cc; - } - - public function getSendUserEmail(): ?int - { - return $this->sendUserEmail; - } - - public function getSendOperatorsEmail(): ?int - { - return $this->sendOperatorsEmail; - } - - /** - * @return string[]|null - */ - public function getAttachment(): ?array - { - return $this->attachment; - } - - public function getCreatedAt(): ?int - { - return $this->createdAt; - } } diff --git a/src/Model/User/Request/CreateUser.php b/src/Model/User/Request/CreateUser.php index ac8ba0b7..9f907811 100644 --- a/src/Model/User/Request/CreateUser.php +++ b/src/Model/User/Request/CreateUser.php @@ -3,145 +3,42 @@ namespace SupportPal\ApiClient\Model\User\Request; use SupportPal\ApiClient\Model\Model; -use Symfony\Component\Serializer\Attribute\SerializedName; class CreateUser extends Model { public const REQUIRED_FIELDS = ['email']; - #[SerializedName('brand_id')] protected int|null $brandId; - #[SerializedName('firstname')] protected string|null $firstname; - #[SerializedName('lastname')] protected string|null $lastname; - #[SerializedName('email')] protected string $email; - #[SerializedName('password')] protected string|null $password; - #[SerializedName('country')] protected string|null $country; - #[SerializedName('language_code')] protected string|null $languageCode; - #[SerializedName('timezone')] protected string|null $timezone; - #[SerializedName('confirmed')] protected bool|null $confirmed; - #[SerializedName('active')] protected int|null $active; - #[SerializedName('organisation')] protected string|null $organisation; - #[SerializedName('organisation_id')] protected int|null $organisationId; - #[SerializedName('organisation_access_level')] protected int|null $organisationAccessLevel; - #[SerializedName('organisation_notifications')] protected int|null $organisationNotifications; /** @var int[]|null */ - #[SerializedName('customfield')] protected array|null $customfield; /** @var int[]|null */ - #[SerializedName('groups')] protected array|null $groups; - - public function getBrandId(): ?int - { - return $this->brandId; - } - - public function getFirstname(): ?string - { - return $this->firstname; - } - - public function getLastname(): ?string - { - return $this->lastname; - } - - public function getEmail(): string - { - return $this->email; - } - - public function getPassword(): ?string - { - return $this->password; - } - - public function getCountry(): ?string - { - return $this->country; - } - - public function getLanguageCode(): ?string - { - return $this->languageCode; - } - - public function getTimezone(): ?string - { - return $this->timezone; - } - - public function getConfirmed(): ?bool - { - return $this->confirmed; - } - - public function getActive(): ?int - { - return $this->active; - } - - public function getOrganisation(): ?string - { - return $this->organisation; - } - - public function getOrganisationId(): ?int - { - return $this->organisationId; - } - - public function getOrganisationAccessLevel(): ?int - { - return $this->organisationAccessLevel; - } - - public function getOrganisationNotifications(): ?int - { - return $this->organisationNotifications; - } - - /** - * @return int[]|null - */ - public function getCustomfield(): ?array - { - return $this->customfield; - } - - /** - * @return int[]|null - */ - public function getGroups(): ?array - { - return $this->groups; - } } diff --git a/test/ApiTestCase.php b/test/ApiTestCase.php index d952c981..4fcb8907 100644 --- a/test/ApiTestCase.php +++ b/test/ApiTestCase.php @@ -29,7 +29,7 @@ public function testGetEndpoint(array $data, string $functionName, array $parame new Response( 200, [], - json_encode($data) + (string) json_encode($data) ) ); diff --git a/test/Cache/CacheableApisTest.php b/test/Cache/CacheableApisTest.php index b6e86765..2bd26ddc 100644 --- a/test/Cache/CacheableApisTest.php +++ b/test/Cache/CacheableApisTest.php @@ -94,9 +94,9 @@ public function testGetCacheableApiTestCacheMiss( /** @var ApiClient $apiClient */ $apiClient = $this->getContainer()->get($apiClientClass); - $response = new Response(200, [], (string) $this->getEncoder()->encode($data, $this->getFormatType())); - $response2 = new Response(200, [], (string) $this->getEncoder()->encode($data, $this->getFormatType())); - $response3 = new Response(200, [], (string) $this->getEncoder()->encode($data, $this->getFormatType())); + $response = new Response(200, [], (string) json_encode($data)); + $response2 = new Response(200, [], (string) json_encode($data)); + $response3 = new Response(200, [], (string) json_encode($data)); $this->mockRequestHandler->append($response); $this->mockRequestHandler->append($response2); @@ -287,8 +287,8 @@ private function buildCacheStrategy(string $cacheDir): CacheStrategyInterface */ protected function mockResponses(array $data): void { - $response = new Response(200, [], (string) $this->getEncoder()->encode($data, $this->getFormatType())); - $response2 = new Response(200, [], (string) $this->getEncoder()->encode($data, $this->getFormatType())); + $response = new Response(200, [], (string) json_encode($data)); + $response2 = new Response(200, [], (string) json_encode($data)); $this->mockRequestHandler->append($response); $this->mockRequestHandler->append($response2); diff --git a/test/E2E/BaseTestCase.php b/test/E2E/BaseTestCase.php index 30af6b62..b605e308 100644 --- a/test/E2E/BaseTestCase.php +++ b/test/E2E/BaseTestCase.php @@ -9,7 +9,6 @@ use SupportPal\ApiClient\Api\TicketApi; use SupportPal\ApiClient\Api\UserApi; use SupportPal\ApiClient\Config\ApiContext; -use SupportPal\ApiClient\Converter\ModelToArrayConverter; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\Shared\Settings; @@ -45,9 +44,6 @@ abstract class BaseTestCase extends TestCase /** @var SupportPal */ private $supportPal; - /** @var ModelToArrayConverter */ - private $modelToArrayConverter; - public function setUp(): void { parent::setUp(); @@ -65,10 +61,6 @@ public function setUp(): void $containerBuilder->set(Client::class, new Client); $containerBuilder->compile(); - /** @var ModelToArrayConverter $modelConverter */ - $modelConverter = $containerBuilder->get(ModelToArrayConverter::class); - $this->modelToArrayConverter = $modelConverter; - $apiContext = ApiContext::createFromUrl($apiUrl, $token); $this->supportPal = new SupportPal($apiContext); @@ -113,7 +105,6 @@ public function testGetAll(string $endpoint, string $apiCall): void $this->callAllGetters($value, $callExceptions); self::assertEmpty($callExceptions, var_export($callExceptions, true)); $this->assertArrayEqualsObjectFields($value, $modelsArray[$offset]); - $this->modelToArrayConverter->convertOne($value); } catch (ExpectationFailedException $exception) { throw new ExpectationFailedException( sprintf('test failed in range start: %d, end: %d', $start, $start + self::BATCH_SIZE), @@ -137,8 +128,7 @@ protected function settingsTestCase(string $endpoint, string $apiCall): void $response = $this->getSupportPal()->sendRequest($request); $responseArray = json_decode((string) $response->getBody(), true)['data']; self::assertInstanceOf(Settings::class, $model); - self::assertSame($responseArray, $model->all()); - $this->modelToArrayConverter->convertOne($model); + self::assertSame($responseArray, $model); } /** @@ -170,7 +160,6 @@ public function testGetOneById(string $endpoint, string $apiCall): void $callExceptions = []; $this->callAllGetters($model, $callExceptions); self::assertEmpty($callExceptions, var_export($callExceptions, true)); - $this->modelToArrayConverter->convertOne($model); ++$iteration; } catch (HttpResponseException $exception) { self::assertStringContainsString('given ID was not found', $exception->getMessage()); diff --git a/test/Integration/ApiClientTest.php b/test/Integration/ApiClientTest.php index 90792a9b..b1e1e4ea 100644 --- a/test/Integration/ApiClientTest.php +++ b/test/Integration/ApiClientTest.php @@ -72,12 +72,12 @@ public function testGetEndpoints(array $data, string $functionName, array $param $expectedResponse = new Response( 200, [], - (string) $this->getEncoder()->encode($data, $this->getFormatType()) + (string) json_encode($data) ); $this->appendRequestResponse($expectedResponse); $response = $this->makeClientCall($functionName, $parameters); self::assertSame($expectedResponse, $response); - self::assertSame($data, $this->getDecoder()->decode((string) $response->getBody(), $this->getFormatType())); + self::assertSame($data, json_decode((string) $response->getBody(), true)); } /** @@ -103,14 +103,14 @@ public function testUnsuccessfulGetEndpoint(Response $response, string $endpoint public function testPostModel(array $modelData, array $responseData, string $endpoint): void { /** @var string $jsonSuccessfulBody */ - $jsonSuccessfulBody = $this->getEncoder()->encode($responseData, $this->getFormatType()); + $jsonSuccessfulBody = json_encode($responseData); $expectedResponse = new Response(200, [], $jsonSuccessfulBody); $this->appendRequestResponse($expectedResponse); $response = $this->makeClientCall($endpoint, [$modelData]); self::assertSame($expectedResponse, $response); self::assertSame( $responseData, - $this->getDecoder()->decode((string) $response->getBody(), $this->getFormatType()) + json_decode((string) $response->getBody(), true) ); } @@ -137,14 +137,14 @@ public function testUnsuccessfulPostModel(Response $response, string $endpoint, public function testPutModel(array $modelData, array $responseData, string $endpoint): void { /** @var string $jsonSuccessfulBody */ - $jsonSuccessfulBody = $this->getEncoder()->encode($responseData, $this->getFormatType()); + $jsonSuccessfulBody = json_encode($responseData); $expectedResponse = new Response(200, [], $jsonSuccessfulBody); $this->appendRequestResponse($expectedResponse); $response = $this->makeClientCall($endpoint, [self::TEST_ID, $modelData]); self::assertSame($expectedResponse, $response); self::assertSame( $responseData, - $this->getDecoder()->decode((string) $response->getBody(), $this->getFormatType()) + json_decode((string) $response->getBody(), true) ); } diff --git a/test/Integration/Converter/ModelToArrayConverterTest.php b/test/Integration/Converter/ModelToArrayConverterTest.php deleted file mode 100644 index df172243..00000000 --- a/test/Integration/Converter/ModelToArrayConverterTest.php +++ /dev/null @@ -1,47 +0,0 @@ -getContainer()->get(ModelToArrayConverter::class); - $this->modelToArrayConverter = $modelToArrayConverter; - } - - /** - * @param Model $model - * @dataProvider provideModelCases - */ - public function testConvertModel(Model $model): void - { - $arrayModel = $this->modelToArrayConverter->convertOne($model); - $this->assertArrayEqualsObjectFields($model, $arrayModel); - } - - /** - * @return iterable> - * @throws InvalidArgumentException - */ - public function provideModelCases(): iterable - { - yield [(new CommentData)->getFilledInstance()]; - yield [(new UserData)->getFilledInstance()]; - yield [(new DepartmentData)->getFilledInstance()]; - } -} diff --git a/test/Integration/Factory/RequestFactoryTest.php b/test/Integration/Factory/RequestFactoryTest.php index 43ecb84c..501303bd 100644 --- a/test/Integration/Factory/RequestFactoryTest.php +++ b/test/Integration/Factory/RequestFactoryTest.php @@ -84,7 +84,7 @@ public function testCreateRequest(array $data): void $headersArray['Host'] = [$request->getUri()->getHost() . ':' . $request->getUri()->getPort()]; $encodedBody = ! empty($data['body']) || ! empty($this->defaultBodyContent) - ? $this->getEncoder()->encode(array_merge($data['body'], $this->defaultBodyContent), $this->getFormatType()) + ? json_encode(array_merge($data['body'], $this->defaultBodyContent)) : ''; self::assertInstanceOf(Request::class, $request); diff --git a/test/Integration/ModelNormalizer/ModelNormalizerTest.php b/test/Integration/ModelNormalizer/ModelNormalizerTest.php deleted file mode 100644 index 5ecc10b7..00000000 --- a/test/Integration/ModelNormalizer/ModelNormalizerTest.php +++ /dev/null @@ -1,152 +0,0 @@ -getContainer()->get(Serializer::class); - /** @var ModelNormalizer $normalizer */ - $normalizer = $this->getContainer()->get(ModelNormalizer::class); - - $filters = $this->getContainer()->findTaggedServiceIds('transformer.field_transformer'); - foreach (array_keys($filters) as $serviceName) { - /** @var Transformer $transformer */ - $transformer = $this->getContainer()->get($serviceName); - $this->transformers[] = $transformer; - } - - $this->normalizer = $normalizer; - } - - /** - * @param Model $model - * @param array $data - * @dataProvider provideObjects - * @throws ExceptionInterface - */ - public function testNormalizer(Model $model, array $data): void - { - /** @var array $normalizedObject */ - $normalizedObject = $this->normalizer->normalize($model); - $data = $this->applyTransformers($data); - $this->assertArraysEqual($data, $normalizedObject); - } - - public function testDenormalizer(): void - { - /** @var Model $denormalizedObject */ - $denormalizedObject = $this->normalizer->denormalize(TicketData::DATA, Ticket::class, $this->getFormatType()); - self::assertInstanceOf(Ticket::class, $denormalizedObject); - $this->assertArrayEqualsObjectFields($denormalizedObject, TicketData::DATA); - } - - public function testDenormalizeReturnsNull(): void - { - $denormalized = $this->normalizer->denormalize([], Ticket::class, $this->getFormatType()); - self::assertNull($denormalized); - } - - /** - * @param array $arr1 - * @param array $arr2 - */ - public function assertArraysEqual(array $arr1, array $arr2): void - { - foreach ($arr1 as $key => $value) { - if (is_array($value)) { - $this->assertArraysEqual($value, $arr2[$key]); - - continue; - } - - /** - * normalizer skips null values - */ - if (isset($arr2[$key])) { - self::assertSame($value, $arr2[$key]); - - continue; - } - - self::assertNull($value); - } - } - - /** - * @param array $data - * @return array - */ - private function applyTransformers(array $data): array - { - foreach ($data as $key => $value) { - if (is_array($value)) { - $data[$key] = $this->applyTransformers($value); - continue; - } - - foreach ($this->transformers as $transformer) { - if (! $transformer->canTransform($value)) { - continue; - } - - $data[$key] = $transformer->transform($value); - } - } - - return $data; - } - - /** - * @return iterable - * @throws InvalidArgumentException - */ - public function provideObjects(): iterable - { - $departmentData = new DepartmentData; - $channelSettingsData = new ChannelSettingsData; - $ticketCustomFieldData = new TicketCustomFieldData; - $priorityData = new PriorityData; - $statusData = new StatusData; - $attachmentData = new AttachmentData; - $ticketData = new TicketData; - $messageData = new MessageData; - - yield [$departmentData->getFilledInstance(), $departmentData->getArrayData()]; - yield [$channelSettingsData->getFilledInstance(), $channelSettingsData->getArrayData()]; - yield [$ticketCustomFieldData->getFilledInstance(), $ticketCustomFieldData->getArrayData()]; - yield [$priorityData->getFilledInstance(), $priorityData->getArrayData()]; - yield [$statusData->getFilledInstance(), $statusData->getArrayData()]; - yield [$attachmentData->getFilledInstance(), $attachmentData->getArrayData()]; - yield [$ticketData->getFilledInstance(), $ticketData->getArrayData()]; - yield [$messageData->getFilledInstance(), $messageData->getArrayData()]; - } -} diff --git a/test/TestCase.php b/test/TestCase.php index a0336c55..b19b1620 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Helper\StringHelper; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Model; -use SupportPal\ApiClient\Model\SettingsModel; +use SupportPal\ApiClient\Model\Shared\Settings; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; use function count; @@ -96,12 +96,6 @@ protected function assertApiDataMatchesModels(Model|Collection $models, array $d return; } - if ($models instanceof SettingsModel) { - self::assertSame($models->all(), $data['data']); - - return; - } - if (! ($models instanceof Model)) { return; } diff --git a/test/Unit/ApiTest.php b/test/Unit/ApiTest.php index 3f4f2512..5fd0522e 100644 --- a/test/Unit/ApiTest.php +++ b/test/Unit/ApiTest.php @@ -40,9 +40,6 @@ abstract class ApiTest extends TestCase /** @var ObjectProphecy|CollectionFactory */ private $collectionFactory; - /** @var string */ - private $formatType = 'json'; - protected function setUp(): void { parent::setUp(); @@ -109,8 +106,6 @@ protected function makeCommonExpectations(array $responseData, string $expectedC /** * @param array $responseData - * @param array $modelArrayData - * @param class-string $className * @param class-string|null $outputClassName * @return array */ diff --git a/test/Unit/Model/Collection/CollectionTest.php b/test/Unit/Model/Collection/CollectionTest.php index 2ef52267..2360cef8 100644 --- a/test/Unit/Model/Collection/CollectionTest.php +++ b/test/Unit/Model/Collection/CollectionTest.php @@ -55,11 +55,9 @@ public function testCollectionMap(): void /** @var Comment $firstModel */ $firstModel = current($models); - $name = $firstModel->name . 'test'; + $name = $firstModel->getAttribute('name') . 'test'; $mappedCollection = $collection->map(function (Comment $comment) use ($name) { - $comment->name = $name; - - return $comment; + return $comment->setAttribute('name', $name); }); self::assertNotSame($collection, $mappedCollection); @@ -69,7 +67,7 @@ public function testCollectionMap(): void /** @var Comment $model */ foreach ($mappedCollection->getModels() as $model) { - self::assertSame($name, $model->name); + self::assertSame($name, $model->getAttribute('name')); } } @@ -81,10 +79,10 @@ public function testCollectionFilter(): void /** @var Comment $firstModel */ $firstModel = current($models); - $name = $firstModel->name . 'test'; + $name = $firstModel->getAttribute('name') . 'test'; $mappedCollection = $collection->filter(function (Comment $comment) use ($name) { - return $comment->name === $name; + return $comment->getAttribute('name') === $name; }); self::assertNotSame($collection, $mappedCollection); From 8399f9ac84555a491494610152f9788bc3f3b4cc Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Fri, 24 May 2024 17:16:00 +0100 Subject: [PATCH 05/20] fix phpcs --- src/Factory/ModelFactory.php | 8 +++++--- src/Model/Ticket/Request/CreateTicket.php | 1 - test/Cache/CacheableApisTest.php | 1 + test/Integration/ApiClientTest.php | 2 ++ test/Integration/Factory/RequestFactoryTest.php | 1 + test/TestCase.php | 1 - 6 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Factory/ModelFactory.php b/src/Factory/ModelFactory.php index 16923fd7..31beed50 100644 --- a/src/Factory/ModelFactory.php +++ b/src/Factory/ModelFactory.php @@ -16,11 +16,13 @@ abstract class ModelFactory */ public function create(array $data): Model { - /** @var Model $model */ - $model = new ($this->getModel()); + $modelClass = $this->getModel(); - return $model->fill($data); + return (new $modelClass)->fill($data); } + /** + * @return class-string + */ abstract public function getModel(): string; } diff --git a/src/Model/Ticket/Request/CreateTicket.php b/src/Model/Ticket/Request/CreateTicket.php index 82ca274a..f1915a36 100644 --- a/src/Model/Ticket/Request/CreateTicket.php +++ b/src/Model/Ticket/Request/CreateTicket.php @@ -65,5 +65,4 @@ class CreateTicket extends Model protected array|null $attachment; protected int|null $createdAt; - } diff --git a/test/Cache/CacheableApisTest.php b/test/Cache/CacheableApisTest.php index 2bd26ddc..88d2b464 100644 --- a/test/Cache/CacheableApisTest.php +++ b/test/Cache/CacheableApisTest.php @@ -38,6 +38,7 @@ use SupportPal\ApiClient\Tests\DataFixtures\User\UserData; use function call_user_func_array; +use function json_encode; use function sleep; use function sys_get_temp_dir; diff --git a/test/Integration/ApiClientTest.php b/test/Integration/ApiClientTest.php index b1e1e4ea..f2d3f0f1 100644 --- a/test/Integration/ApiClientTest.php +++ b/test/Integration/ApiClientTest.php @@ -13,6 +13,8 @@ use SupportPal\ApiClient\Tests\ContainerAwareBaseTestCase; use function call_user_func_array; +use function json_decode; +use function json_encode; /** * Class ApiClientTest diff --git a/test/Integration/Factory/RequestFactoryTest.php b/test/Integration/Factory/RequestFactoryTest.php index 501303bd..03809073 100644 --- a/test/Integration/Factory/RequestFactoryTest.php +++ b/test/Integration/Factory/RequestFactoryTest.php @@ -11,6 +11,7 @@ use function array_merge; use function base64_encode; use function http_build_query; +use function json_encode; /** * Class RequestFactoryTest diff --git a/test/TestCase.php b/test/TestCase.php index b19b1620..94a558f8 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -5,7 +5,6 @@ use SupportPal\ApiClient\Helper\StringHelper; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Model; -use SupportPal\ApiClient\Model\Shared\Settings; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; use function count; From b9e5bf763d1006a903adf362e3528d272959383c Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Tue, 28 May 2024 18:15:01 +0100 Subject: [PATCH 06/20] remove factories and clean up http endpoints code --- src/Api/Api.php | 46 +--- src/Api/ApiAware.php | 24 -- src/Api/Core/{BrandApis.php => Brands.php} | 20 +- src/Api/Core/Settings.php | 22 ++ src/Api/Core/SettingsApis.php | 33 --- src/Api/CoreApi.php | 25 +- .../{ArticleApis.php => Articles.php} | 35 +-- .../{CategoryApis.php => Categories.php} | 24 +- .../{CommentApis.php => Comments.php} | 26 +- src/Api/SelfService/Settings.php | 22 ++ src/Api/SelfService/SettingsApis.php | 32 --- src/Api/SelfService/{TagApis.php => Tags.php} | 30 +-- .../SelfService/{TypeApis.php => Types.php} | 24 +- src/Api/SelfServiceApi.php | 41 ++-- .../{AttachmentApis.php => Attachments.php} | 22 +- src/Api/Ticket/ChannelSettings.php | 22 ++ src/Api/Ticket/ChannelSettingsApis.php | 35 --- .../{CustomFieldApis.php => CustomFields.php} | 20 +- .../{DepartmentApis.php => Departments.php} | 24 +- .../Ticket/{MessageApis.php => Messages.php} | 22 +- .../{PriorityApis.php => Priorities.php} | 20 +- src/Api/Ticket/Settings.php | 22 ++ src/Api/Ticket/SettingsApis.php | 33 --- .../Ticket/{StatusApis.php => Statuses.php} | 20 +- .../Ticket/{TicketApis.php => Tickets.php} | 24 +- src/Api/TicketApi.php | 52 ++-- .../{CustomFieldApis.php => CustomFields.php} | 20 +- .../{UserGroupApis.php => UserGroups.php} | 21 +- src/Api/User/{UserApis.php => Users.php} | 24 +- src/Api/UserApi.php | 28 +-- src/ApiClient/CoreApiClient.php | 18 -- src/ApiClient/SelfServiceApiClient.php | 26 -- src/Factory/Collection/CollectionFactory.php | 26 -- src/Factory/Core/BrandFactory.php | 17 -- src/Factory/ModelCollectionFactory.php | 48 ---- src/Factory/ModelFactory.php | 28 --- src/Factory/SelfService/ArticleFactory.php | 21 -- src/Factory/SelfService/CategoryFactory.php | 21 -- src/Factory/SelfService/CommentFactory.php | 21 -- src/Factory/SelfService/TagFactory.php | 21 -- src/Factory/SelfService/TypeFactory.php | 21 -- src/Factory/Shared/SettingsFactory.php | 17 -- src/Factory/Ticket/AttachmentFactory.php | 17 -- src/Factory/Ticket/ChannelSettingsFactory.php | 21 -- src/Factory/Ticket/CustomFieldFactory.php | 17 -- src/Factory/Ticket/DepartmentFactory.php | 21 -- src/Factory/Ticket/MessageFactory.php | 17 -- src/Factory/Ticket/PriorityFactory.php | 17 -- src/Factory/Ticket/StatusFactory.php | 17 -- src/Factory/Ticket/TicketFactory.php | 17 -- src/Factory/User/GroupFactory.php | 17 -- src/Factory/User/UserCustomFieldFactory.php | 17 -- src/Factory/User/UserFactory.php | 21 -- src/{ApiClient => Http}/ApiClientAware.php | 12 +- src/{ApiClient.php => Http/Client.php} | 36 +-- src/{ApiClient => Http}/Core/BrandApis.php | 4 +- src/{ApiClient => Http}/Core/SettingsApis.php | 6 +- src/Http/CoreClient.php | 12 + .../RequestFactory.php => Http/Request.php} | 12 +- .../SelfService/ArticleApis.php | 6 +- .../SelfService/CategoryApis.php | 6 +- .../SelfService/CommentApis.php | 8 +- .../SelfService/SettingsApis.php | 6 +- .../SelfService/TagApis.php | 6 +- .../SelfService/TypeApis.php | 6 +- src/Http/SelfServiceClient.php | 20 ++ .../Ticket/AttachmentApis.php | 6 +- .../Ticket/ChannelSettingsApis.php | 4 +- .../Ticket/CustomFieldApis.php | 4 +- .../Ticket/DepartmentApis.php | 6 +- .../Ticket/MessageApis.php | 6 +- .../Ticket/PriorityApis.php | 4 +- .../Ticket/SettingsApis.php | 6 +- src/{ApiClient => Http}/Ticket/StatusApis.php | 4 +- .../Ticket/TicketApis.php} | 32 +-- src/Http/TicketClient.php | 26 ++ .../User/CustomFieldApis.php | 4 +- .../User/UserApis.php} | 19 +- .../User/UserGroupApis.php | 4 +- src/Http/UserClient.php | 14 ++ src/Resources/api.yml | 10 +- src/Resources/api_client.yml | 23 -- src/Resources/client.yml | 32 +++ src/Resources/core_services.yml | 22 -- src/Resources/factories.yml | 91 ------- src/Resources/services.yml | 4 +- src/SupportPal.php | 22 +- test/Cache/CacheableApisTest.php | 98 ++++---- test/CollectionFactoryTestCase.php | 57 ----- test/FactoryTestCase.php | 27 -- test/Functional/SupportPalTest.php | 4 +- test/Integration/ApiClient/CoreApisTest.php | 4 +- .../ApiClient/SelfServiceApisTest.php | 4 +- test/Integration/ApiClient/TicketApisTest.php | 4 +- test/Integration/ApiClient/UserApisTest.php | 4 +- test/Integration/ApiClientTest.php | 12 +- .../Factory/BaseModelFactoryTestCase.php | 76 ------ .../Collection/CollectionFactoryTest.php | 17 -- .../Factory/Core/BrandFactoryTest.php | 39 --- .../Factory/Core/UserFactoryTest.php | 43 ---- .../Factory/ModelCollectionFactoryTest.php | 110 --------- .../Factory/RequestFactoryTest.php | 138 ----------- .../SelfService/ArticleFactoryTest.php | 39 --- .../SelfService/CategoryFactoryTest.php | 39 --- .../SelfService/CommentFactoryTest.php | 43 ---- .../Factory/SelfService/TagFactoryTest.php | 39 --- .../Factory/SelfService/TypeFactoryTest.php | 43 ---- .../Factory/Ticket/AttachmentFactoryTest.php | 39 --- .../Ticket/ChannelSettingsFactoryTest.php | 39 --- .../Factory/Ticket/CustomFieldFactoryTest.php | 39 --- .../Factory/Ticket/DepartmentFactoryTest.php | 39 --- .../Factory/Ticket/MessageFactoryTest.php | 39 --- .../Factory/Ticket/PriorityFactoryTest.php | 39 --- .../Factory/Ticket/StatusFactoryTest.php | 39 --- .../Factory/Ticket/TicketFactoryTest.php | 39 --- .../Factory/User/GroupFactoryTest.php | 39 --- .../User/UserCustomFieldFactoryTest.php | 39 --- test/Resources/services_test.yml | 102 +------- test/Unit/Api/Core/BrandApisTest.php | 10 +- test/Unit/Api/Core/SettingsApisTest.php | 12 +- test/Unit/Api/SelfService/ArticleApisTest.php | 14 +- .../Unit/Api/SelfService/CategoryApisTest.php | 10 +- test/Unit/Api/SelfService/CommentApisTest.php | 12 +- .../Unit/Api/SelfService/SettingsApisTest.php | 8 +- test/Unit/Api/SelfService/TagApisTest.php | 10 +- test/Unit/Api/SelfService/TypeApiTest.php | 10 +- test/Unit/Api/Ticket/AttachmentApisTest.php | 10 +- test/Unit/Api/Ticket/ChannelApisTest.php | 8 +- test/Unit/Api/Ticket/CustomFieldApisTest.php | 10 +- test/Unit/Api/Ticket/DepartmentApisTest.php | 10 +- test/Unit/Api/Ticket/MessageApisTest.php | 12 +- test/Unit/Api/Ticket/PriorityApisTest.php | 10 +- test/Unit/Api/Ticket/StatusApisTest.php | 10 +- test/Unit/Api/Ticket/TicketApisTest.php | 16 +- .../Api/Ticket/TicketSettingsApisTest.php | 8 +- test/Unit/Api/User/UserApisTest.php | 16 +- .../Unit/Api/User/UserCustomFieldApisTest.php | 10 +- test/Unit/Api/User/UserGroupApisTest.php | 10 +- test/Unit/ApiClient/Core/BrandApisTest.php | 6 +- test/Unit/ApiClient/Core/CoreApisTest.php | 10 +- .../ApiClient/SelfService/ArticleApisTest.php | 10 +- .../SelfService/CategoryApisTest.php | 10 +- .../ApiClient/SelfService/CommentApisTest.php | 10 +- .../SelfService/SettingsApisTest.php | 10 +- .../ApiClient/SelfService/TagApisTest.php | 10 +- .../ApiClient/SelfService/TypeApisTest.php | 10 +- .../ApiClient/Ticket/AttachmentApisTest.php | 10 +- .../Ticket/ChannelSettingsApisTest.php | 10 +- .../ApiClient/Ticket/CustomFieldApisTest.php | 10 +- .../ApiClient/Ticket/DepartmentApisTest.php | 10 +- .../Unit/ApiClient/Ticket/MessageApisTest.php | 10 +- .../ApiClient/Ticket/PriorityApisTest.php | 10 +- test/Unit/ApiClient/Ticket/StatusApisTest.php | 10 +- test/Unit/ApiClient/Ticket/TicketApisTest.php | 12 +- .../Ticket/TicketSettingsApisTest.php | 12 +- .../ApiClient/User/CustomFieldApisTest.php | 12 +- test/Unit/ApiClient/User/UserApisTest.php | 12 +- .../Unit/ApiClient/User/UserGroupApisTest.php | 12 +- test/Unit/ApiClientTest.php | 36 ++- test/Unit/ApiTest.php | 109 ++------ test/Unit/Factory/BaseModelFactoryTest.php | 54 ---- .../Unit/Factory/BaseModelFactoryTestCase.php | 32 --- .../Collection/CollectionFactoryTest.php | 20 -- test/Unit/Factory/Core/BrandFactoryTest.php | 45 ---- .../Factory/ModelCollectionFactoryTest.php | 105 -------- test/Unit/Factory/RequestFactoryTest.php | 232 ------------------ .../SelfService/ArticleFactoryTest.php | 50 ---- .../SelfService/CategoryFactoryTest.php | 50 ---- .../SelfService/CommentFactoryTest.php | 50 ---- .../Factory/SelfService/TagFactoryTest.php | 50 ---- .../Factory/SelfService/TypeFactoryTest.php | 50 ---- .../Factory/Shared/SettingsFactoryTest.php | 50 ---- .../Factory/Ticket/AttachmentFactoryTest.php | 50 ---- .../Ticket/ChannelSettingsFactoryTest.php | 50 ---- .../Factory/Ticket/CustomFieldFactoryTest.php | 50 ---- .../Factory/Ticket/DepartmentFactoryTest.php | 50 ---- .../Factory/Ticket/MessageFactoryTest.php | 50 ---- .../Factory/Ticket/PriorityFactoryTest.php | 50 ---- .../Unit/Factory/Ticket/StatusFactoryTest.php | 50 ---- .../Unit/Factory/Ticket/TicketFactoryTest.php | 50 ---- .../User/UserCustomFieldFactoryTest.php | 50 ---- test/Unit/Factory/User/UserFactoryTest.php | 50 ---- .../Factory/User/UserGroupFactoryTest.php | 45 ---- 183 files changed, 729 insertions(+), 4283 deletions(-) delete mode 100644 src/Api/ApiAware.php rename src/Api/Core/{BrandApis.php => Brands.php} (68%) create mode 100644 src/Api/Core/Settings.php delete mode 100644 src/Api/Core/SettingsApis.php rename src/Api/SelfService/{ArticleApis.php => Articles.php} (68%) rename src/Api/SelfService/{CategoryApis.php => Categories.php} (62%) rename src/Api/SelfService/{CommentApis.php => Comments.php} (67%) create mode 100644 src/Api/SelfService/Settings.php delete mode 100644 src/Api/SelfService/SettingsApis.php rename src/Api/SelfService/{TagApis.php => Tags.php} (50%) rename src/Api/SelfService/{TypeApis.php => Types.php} (62%) rename src/Api/Ticket/{AttachmentApis.php => Attachments.php} (73%) create mode 100644 src/Api/Ticket/ChannelSettings.php delete mode 100644 src/Api/Ticket/ChannelSettingsApis.php rename src/Api/Ticket/{CustomFieldApis.php => CustomFields.php} (69%) rename src/Api/Ticket/{DepartmentApis.php => Departments.php} (64%) rename src/Api/Ticket/{MessageApis.php => Messages.php} (73%) rename src/Api/Ticket/{PriorityApis.php => Priorities.php} (68%) create mode 100644 src/Api/Ticket/Settings.php delete mode 100644 src/Api/Ticket/SettingsApis.php rename src/Api/Ticket/{StatusApis.php => Statuses.php} (68%) rename src/Api/Ticket/{TicketApis.php => Tickets.php} (76%) rename src/Api/User/{CustomFieldApis.php => CustomFields.php} (68%) rename src/Api/User/{UserGroupApis.php => UserGroups.php} (69%) rename src/Api/User/{UserApis.php => Users.php} (76%) delete mode 100644 src/ApiClient/CoreApiClient.php delete mode 100644 src/ApiClient/SelfServiceApiClient.php delete mode 100644 src/Factory/Collection/CollectionFactory.php delete mode 100644 src/Factory/Core/BrandFactory.php delete mode 100644 src/Factory/ModelCollectionFactory.php delete mode 100644 src/Factory/ModelFactory.php delete mode 100644 src/Factory/SelfService/ArticleFactory.php delete mode 100644 src/Factory/SelfService/CategoryFactory.php delete mode 100644 src/Factory/SelfService/CommentFactory.php delete mode 100644 src/Factory/SelfService/TagFactory.php delete mode 100644 src/Factory/SelfService/TypeFactory.php delete mode 100644 src/Factory/Shared/SettingsFactory.php delete mode 100644 src/Factory/Ticket/AttachmentFactory.php delete mode 100644 src/Factory/Ticket/ChannelSettingsFactory.php delete mode 100644 src/Factory/Ticket/CustomFieldFactory.php delete mode 100644 src/Factory/Ticket/DepartmentFactory.php delete mode 100644 src/Factory/Ticket/MessageFactory.php delete mode 100644 src/Factory/Ticket/PriorityFactory.php delete mode 100644 src/Factory/Ticket/StatusFactory.php delete mode 100644 src/Factory/Ticket/TicketFactory.php delete mode 100644 src/Factory/User/GroupFactory.php delete mode 100644 src/Factory/User/UserCustomFieldFactory.php delete mode 100644 src/Factory/User/UserFactory.php rename src/{ApiClient => Http}/ApiClientAware.php (79%) rename src/{ApiClient.php => Http/Client.php} (76%) rename src/{ApiClient => Http}/Core/BrandApis.php (89%) rename src/{ApiClient => Http}/Core/SettingsApis.php (80%) create mode 100644 src/Http/CoreClient.php rename src/{Factory/RequestFactory.php => Http/Request.php} (92%) rename src/{ApiClient => Http}/SelfService/ArticleApis.php (91%) rename src/{ApiClient => Http}/SelfService/CategoryApis.php (85%) rename src/{ApiClient => Http}/SelfService/CommentApis.php (86%) rename src/{ApiClient => Http}/SelfService/SettingsApis.php (77%) rename src/{ApiClient => Http}/SelfService/TagApis.php (84%) rename src/{ApiClient => Http}/SelfService/TypeApis.php (85%) create mode 100644 src/Http/SelfServiceClient.php rename src/{ApiClient => Http}/Ticket/AttachmentApis.php (89%) rename src/{ApiClient => Http}/Ticket/ChannelSettingsApis.php (85%) rename src/{ApiClient => Http}/Ticket/CustomFieldApis.php (90%) rename src/{ApiClient => Http}/Ticket/DepartmentApis.php (85%) rename src/{ApiClient => Http}/Ticket/MessageApis.php (88%) rename src/{ApiClient => Http}/Ticket/PriorityApis.php (89%) rename src/{ApiClient => Http}/Ticket/SettingsApis.php (78%) rename src/{ApiClient => Http}/Ticket/StatusApis.php (89%) rename src/{ApiClient/TicketApiClient.php => Http/Ticket/TicketApis.php} (60%) create mode 100644 src/Http/TicketClient.php rename src/{ApiClient => Http}/User/CustomFieldApis.php (90%) rename src/{ApiClient/UserApiClient.php => Http/User/UserApis.php} (74%) rename src/{ApiClient => Http}/User/UserGroupApis.php (89%) create mode 100644 src/Http/UserClient.php delete mode 100644 src/Resources/api_client.yml create mode 100644 src/Resources/client.yml delete mode 100644 src/Resources/core_services.yml delete mode 100644 src/Resources/factories.yml delete mode 100644 test/CollectionFactoryTestCase.php delete mode 100644 test/FactoryTestCase.php delete mode 100644 test/Integration/Factory/BaseModelFactoryTestCase.php delete mode 100644 test/Integration/Factory/Collection/CollectionFactoryTest.php delete mode 100644 test/Integration/Factory/Core/BrandFactoryTest.php delete mode 100644 test/Integration/Factory/Core/UserFactoryTest.php delete mode 100644 test/Integration/Factory/ModelCollectionFactoryTest.php delete mode 100644 test/Integration/Factory/RequestFactoryTest.php delete mode 100644 test/Integration/Factory/SelfService/ArticleFactoryTest.php delete mode 100644 test/Integration/Factory/SelfService/CategoryFactoryTest.php delete mode 100644 test/Integration/Factory/SelfService/CommentFactoryTest.php delete mode 100644 test/Integration/Factory/SelfService/TagFactoryTest.php delete mode 100644 test/Integration/Factory/SelfService/TypeFactoryTest.php delete mode 100644 test/Integration/Factory/Ticket/AttachmentFactoryTest.php delete mode 100644 test/Integration/Factory/Ticket/ChannelSettingsFactoryTest.php delete mode 100644 test/Integration/Factory/Ticket/CustomFieldFactoryTest.php delete mode 100644 test/Integration/Factory/Ticket/DepartmentFactoryTest.php delete mode 100644 test/Integration/Factory/Ticket/MessageFactoryTest.php delete mode 100644 test/Integration/Factory/Ticket/PriorityFactoryTest.php delete mode 100644 test/Integration/Factory/Ticket/StatusFactoryTest.php delete mode 100644 test/Integration/Factory/Ticket/TicketFactoryTest.php delete mode 100644 test/Integration/Factory/User/GroupFactoryTest.php delete mode 100644 test/Integration/Factory/User/UserCustomFieldFactoryTest.php delete mode 100644 test/Unit/Factory/BaseModelFactoryTest.php delete mode 100644 test/Unit/Factory/BaseModelFactoryTestCase.php delete mode 100644 test/Unit/Factory/Collection/CollectionFactoryTest.php delete mode 100644 test/Unit/Factory/Core/BrandFactoryTest.php delete mode 100644 test/Unit/Factory/ModelCollectionFactoryTest.php delete mode 100644 test/Unit/Factory/RequestFactoryTest.php delete mode 100644 test/Unit/Factory/SelfService/ArticleFactoryTest.php delete mode 100644 test/Unit/Factory/SelfService/CategoryFactoryTest.php delete mode 100644 test/Unit/Factory/SelfService/CommentFactoryTest.php delete mode 100644 test/Unit/Factory/SelfService/TagFactoryTest.php delete mode 100644 test/Unit/Factory/SelfService/TypeFactoryTest.php delete mode 100644 test/Unit/Factory/Shared/SettingsFactoryTest.php delete mode 100644 test/Unit/Factory/Ticket/AttachmentFactoryTest.php delete mode 100644 test/Unit/Factory/Ticket/ChannelSettingsFactoryTest.php delete mode 100644 test/Unit/Factory/Ticket/CustomFieldFactoryTest.php delete mode 100644 test/Unit/Factory/Ticket/DepartmentFactoryTest.php delete mode 100644 test/Unit/Factory/Ticket/MessageFactoryTest.php delete mode 100644 test/Unit/Factory/Ticket/PriorityFactoryTest.php delete mode 100644 test/Unit/Factory/Ticket/StatusFactoryTest.php delete mode 100644 test/Unit/Factory/Ticket/TicketFactoryTest.php delete mode 100644 test/Unit/Factory/User/UserCustomFieldFactoryTest.php delete mode 100644 test/Unit/Factory/User/UserFactoryTest.php delete mode 100644 test/Unit/Factory/User/UserGroupFactoryTest.php diff --git a/src/Api/Api.php b/src/Api/Api.php index 2b03dec7..e04ce765 100644 --- a/src/Api/Api.php +++ b/src/Api/Api.php @@ -3,47 +3,14 @@ namespace SupportPal\ApiClient\Api; use Psr\Http\Message\ResponseInterface; -use SupportPal\ApiClient\ApiClient; -use SupportPal\ApiClient\ApiClient\CoreApiClient; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; -use SupportPal\ApiClient\ApiClient\TicketApiClient; -use SupportPal\ApiClient\ApiClient\UserApiClient; -use SupportPal\ApiClient\Factory\Collection\CollectionFactory; -use SupportPal\ApiClient\Factory\ModelCollectionFactory; +use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Model; use function json_decode; abstract class Api { - use ApiAware; - - /** @var UserApiClient|SelfServiceApiClient|TicketApiClient|CoreApiClient|ApiClient */ - protected $apiClient; - - /** @var ModelCollectionFactory */ - private $modelCollectionFactory; - - /** @var CollectionFactory */ - private $collectionFactory; - - public function __construct( - ModelCollectionFactory $modelCollectionFactory, - CollectionFactory $collectionFactory, - ApiClient $apiClient - ) { - $this->modelCollectionFactory = $modelCollectionFactory; - $this->collectionFactory = $collectionFactory; - $this->apiClient = $apiClient; - } - - /** - * @inheritDoc - */ - protected function getModelCollectionFactory(): ModelCollectionFactory - { - return $this->modelCollectionFactory; - } - /** * @param ResponseInterface $response * @return array @@ -54,10 +21,11 @@ protected function decodeBody(ResponseInterface $response): array } /** - * @return CollectionFactory + * @param Model[] $models + * @throws InvalidArgumentException */ - protected function getCollectionFactory(): CollectionFactory + public function createCollection(int $count, array $models): Collection { - return $this->collectionFactory; + return new Collection($count, $models); } } diff --git a/src/Api/ApiAware.php b/src/Api/ApiAware.php deleted file mode 100644 index 500630bc..00000000 --- a/src/Api/ApiAware.php +++ /dev/null @@ -1,24 +0,0 @@ - $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -39,20 +33,16 @@ public function getBrands(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createBrand'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** * @param array $data - * @return Brand */ private function createBrand(array $data): Brand { - /** @var Brand $model */ - $model = $this->getModelCollectionFactory()->create(Brand::class, $data); - - return $model; + return new Brand($data); } - abstract protected function getApiClient(): CoreApiClient; + abstract protected function getApiClient(): CoreClient; } diff --git a/src/Api/Core/Settings.php b/src/Api/Core/Settings.php new file mode 100644 index 00000000..28609df4 --- /dev/null +++ b/src/Api/Core/Settings.php @@ -0,0 +1,22 @@ +getApiClient()->getSettings(); + + return new SettingsModel($this->decodeBody($response)['data']); + } + + abstract protected function getApiClient(): CoreClient; +} diff --git a/src/Api/Core/SettingsApis.php b/src/Api/Core/SettingsApis.php deleted file mode 100644 index 2f555453..00000000 --- a/src/Api/Core/SettingsApis.php +++ /dev/null @@ -1,33 +0,0 @@ -getApiClient()->getSettings(); - /** @var Settings $model */ - $model = $this->getModelCollectionFactory()->create(Settings::class, $this->decodeBody($response)['data']); - - return $model; - } - - abstract protected function getApiClient(): CoreApiClient; -} diff --git a/src/Api/CoreApi.php b/src/Api/CoreApi.php index 13705d9a..24c4f7fa 100644 --- a/src/Api/CoreApi.php +++ b/src/Api/CoreApi.php @@ -2,27 +2,20 @@ namespace SupportPal\ApiClient\Api; -use SupportPal\ApiClient\Api\Core\BrandApis; -use SupportPal\ApiClient\Api\Core\SettingsApis; -use SupportPal\ApiClient\ApiClient\CoreApiClient; +use SupportPal\ApiClient\Api\Core\Brands; +use SupportPal\ApiClient\Api\Core\Settings; +use SupportPal\ApiClient\Http\CoreClient; -/** - * Contains all ApiCalls pre and post processing that falls under Core Module - * Trait CoreApis - * @package SupportPal\ApiClient\Api - */ class CoreApi extends Api { - use BrandApis; - use SettingsApis; + use Brands; + use Settings; - /** @var CoreApiClient */ - protected $apiClient; + public function __construct(protected readonly CoreClient $apiClient) + { + } - /** - * @return CoreApiClient - */ - protected function getApiClient(): CoreApiClient + protected function getApiClient(): CoreClient { return $this->apiClient; } diff --git a/src/Api/SelfService/ArticleApis.php b/src/Api/SelfService/Articles.php similarity index 68% rename from src/Api/SelfService/ArticleApis.php rename to src/Api/SelfService/Articles.php index 0a507c82..66d4d9cb 100644 --- a/src/Api/SelfService/ArticleApis.php +++ b/src/Api/SelfService/Articles.php @@ -2,27 +2,18 @@ namespace SupportPal\ApiClient\Api\SelfService; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\SelfService\Article; use function array_map; -/** - * Trait ArticleApis, includes all related ApiCalls pre and post processing to Articles - * @package SupportPal\ApiClient\Api\SelfService - */ -trait ArticleApis +trait Articles { - use ApiAware; - /** - * @param int $articleId * @param array $queryParameters - * @return Article * @throws HttpResponseException */ public function getArticle(int $articleId, array $queryParameters = []): Article @@ -33,9 +24,7 @@ public function getArticle(int $articleId, array $queryParameters = []): Article } /** - * @param string $term * @param array $queryParameters - * @return Collection * @throws HttpResponseException|InvalidArgumentException */ public function getArticlesByTerm(string $term, array $queryParameters = []): Collection @@ -45,12 +34,11 @@ public function getArticlesByTerm(string $term, array $queryParameters = []): Co $body = $this->decodeBody($response); $models = array_map([$this, 'createArticle'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException|InvalidArgumentException */ public function getArticles(array $queryParameters = []): Collection @@ -59,18 +47,15 @@ public function getArticles(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createArticle'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $typeId - * @param string $term * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ - public function getRelatedArticles(int $typeId, string $term, array $queryParameters = []) + public function getRelatedArticles(int $typeId, string $term, array $queryParameters = []): Collection { $queryParameters['term'] = $term; $queryParameters['type_id'] = $typeId; @@ -79,20 +64,16 @@ public function getRelatedArticles(int $typeId, string $term, array $queryParame $body = $this->decodeBody($response); $models = array_map([$this, 'createArticle'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** * @param array $data - * @return Article */ private function createArticle(array $data): Article { - /** @var Article $model */ - $model = $this->getModelCollectionFactory()->create(Article::class, $data); - - return $model; + return new Article($data); } - abstract protected function getApiClient(): SelfServiceApiClient; + abstract protected function getApiClient(): SelfServiceClient; } diff --git a/src/Api/SelfService/CategoryApis.php b/src/Api/SelfService/Categories.php similarity index 62% rename from src/Api/SelfService/CategoryApis.php rename to src/Api/SelfService/Categories.php index 9cd297c1..115a2206 100644 --- a/src/Api/SelfService/CategoryApis.php +++ b/src/Api/SelfService/Categories.php @@ -2,26 +2,17 @@ namespace SupportPal\ApiClient\Api\SelfService; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\SelfService\Category; use function array_map; -/** - * Trait CategoryApis, includes all related ApiCalls pre and post processing to categories - * @package SupportPal\ApiClient\Api\SelfService - */ -trait CategoryApis +trait Categories { - use ApiAware; - /** - * @param int $categoryId - * @return Category * @throws HttpResponseException */ public function getCategory(int $categoryId): Category @@ -33,7 +24,6 @@ public function getCategory(int $categoryId): Category /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -43,20 +33,16 @@ public function getCategories(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createCategory'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** * @param array $data - * @return Category */ private function createCategory(array $data): Category { - /** @var Category $model */ - $model = $this->getModelCollectionFactory()->create(Category::class, $data); - - return $model; + return new Category($data); } - abstract protected function getApiClient(): SelfServiceApiClient; + abstract protected function getApiClient(): SelfServiceClient; } diff --git a/src/Api/SelfService/CommentApis.php b/src/Api/SelfService/Comments.php similarity index 67% rename from src/Api/SelfService/CommentApis.php rename to src/Api/SelfService/Comments.php index edd38adb..2ee00557 100644 --- a/src/Api/SelfService/CommentApis.php +++ b/src/Api/SelfService/Comments.php @@ -2,28 +2,19 @@ namespace SupportPal\ApiClient\Api\SelfService; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\SelfService\Comment; use SupportPal\ApiClient\Model\SelfService\Request\CreateComment; use function array_map; -/** - * Trait CommentApis, includes all related ApiCalls pre and post processing to comments - * @package SupportPal\ApiClient\Api\SelfService - */ -trait CommentApis +trait Comments { - use ApiAware; - /** - * This method creates a comment in SupportPal * @param CreateComment $comment - * @return Comment * @throws HttpResponseException */ public function postComment(CreateComment $comment): Comment @@ -35,7 +26,6 @@ public function postComment(CreateComment $comment): Comment /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -45,12 +35,10 @@ public function getComments(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createComment'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $commentId - * @return Comment * @throws HttpResponseException */ public function getComment(int $commentId): Comment @@ -62,15 +50,11 @@ public function getComment(int $commentId): Comment /** * @param array $data - * @return Comment */ private function createComment(array $data): Comment { - /** @var Comment $model */ - $model = $this->getModelCollectionFactory()->create(Comment::class, $data); - - return $model; + return new Comment($data); } - abstract protected function getApiClient(): SelfServiceApiClient; + abstract protected function getApiClient(): SelfServiceClient; } diff --git a/src/Api/SelfService/Settings.php b/src/Api/SelfService/Settings.php new file mode 100644 index 00000000..12e5847e --- /dev/null +++ b/src/Api/SelfService/Settings.php @@ -0,0 +1,22 @@ +getApiClient()->getSettings(); + + return new SettingsModel($this->decodeBody($response)['data']); + } + + abstract protected function getApiClient(): SelfServiceClient; +} diff --git a/src/Api/SelfService/SettingsApis.php b/src/Api/SelfService/SettingsApis.php deleted file mode 100644 index 693a8a24..00000000 --- a/src/Api/SelfService/SettingsApis.php +++ /dev/null @@ -1,32 +0,0 @@ -getApiClient()->getSettings(); - /** @var Settings $model */ - $model = $this->getModelCollectionFactory()->create(Settings::class, $this->decodeBody($response)['data']); - - return $model; - } - - abstract protected function getApiClient(): SelfServiceApiClient; -} diff --git a/src/Api/SelfService/TagApis.php b/src/Api/SelfService/Tags.php similarity index 50% rename from src/Api/SelfService/TagApis.php rename to src/Api/SelfService/Tags.php index 4bac7b48..80b67c30 100644 --- a/src/Api/SelfService/TagApis.php +++ b/src/Api/SelfService/Tags.php @@ -2,29 +2,20 @@ namespace SupportPal\ApiClient\Api\SelfService; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\Collection\Collection; -use SupportPal\ApiClient\Model\SelfService\Tag as SelfServiceTagAlias; +use SupportPal\ApiClient\Model\SelfService\Tag; use function array_map; -/** - * Trait TagApis, includes all related ApiCalls pre and post processing to Tags - * @package SupportPal\ApiClient\Api\SelfService - */ -trait TagApis +trait Tags { - use ApiAware; - /** - * @param int $tagId - * @return SelfServiceTagAlias * @throws HttpResponseException */ - public function getTag(int $tagId): SelfServiceTagAlias + public function getTag(int $tagId): Tag { $response = $this->getApiClient()->getTag($tagId); @@ -33,7 +24,6 @@ public function getTag(int $tagId): SelfServiceTagAlias /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException|InvalidArgumentException */ public function getTags(array $queryParameters = []): Collection @@ -42,20 +32,16 @@ public function getTags(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createTag'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** * @param array $data - * @return SelfServiceTagAlias */ - private function createTag(array $data): SelfServiceTagAlias + private function createTag(array $data): Tag { - /** @var SelfServiceTagAlias $model */ - $model = $this->getModelCollectionFactory()->create(SelfServiceTagAlias::class, $data); - - return $model; + return new Tag($data); } - abstract protected function getApiClient(): SelfServiceApiClient; + abstract protected function getApiClient(): SelfServiceClient; } diff --git a/src/Api/SelfService/TypeApis.php b/src/Api/SelfService/Types.php similarity index 62% rename from src/Api/SelfService/TypeApis.php rename to src/Api/SelfService/Types.php index f9a05398..744711f7 100644 --- a/src/Api/SelfService/TypeApis.php +++ b/src/Api/SelfService/Types.php @@ -2,26 +2,18 @@ namespace SupportPal\ApiClient\Api\SelfService; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\SelfService\Type; use function array_map; -/** - * Trait TypeApis, includes all related ApiCalls pre and post processing to selfservice types - * @package SupportPal\ApiClient\Api\SelfService - */ -trait TypeApis +trait Types { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -31,12 +23,10 @@ public function getTypes(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createType'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $typeId - * @return Type * @throws HttpResponseException */ public function getType(int $typeId): Type @@ -48,15 +38,11 @@ public function getType(int $typeId): Type /** * @param array $data - * @return Type */ private function createType(array $data): Type { - /** @var Type $model */ - $model = $this->getModelCollectionFactory()->create(Type::class, $data); - - return $model; + return new Type($data); } - abstract protected function getApiClient(): SelfServiceApiClient; + abstract protected function getApiClient(): SelfServiceClient; } diff --git a/src/Api/SelfServiceApi.php b/src/Api/SelfServiceApi.php index aceb78c9..a8fbf7aa 100644 --- a/src/Api/SelfServiceApi.php +++ b/src/Api/SelfServiceApi.php @@ -2,35 +2,28 @@ namespace SupportPal\ApiClient\Api; -use SupportPal\ApiClient\Api\SelfService\ArticleApis; -use SupportPal\ApiClient\Api\SelfService\CategoryApis; -use SupportPal\ApiClient\Api\SelfService\CommentApis; -use SupportPal\ApiClient\Api\SelfService\SettingsApis; -use SupportPal\ApiClient\Api\SelfService\TagApis; -use SupportPal\ApiClient\Api\SelfService\TypeApis; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; +use SupportPal\ApiClient\Api\SelfService\Articles; +use SupportPal\ApiClient\Api\SelfService\Categories; +use SupportPal\ApiClient\Api\SelfService\Comments; +use SupportPal\ApiClient\Api\SelfService\Settings; +use SupportPal\ApiClient\Api\SelfService\Tags; +use SupportPal\ApiClient\Api\SelfService\Types; +use SupportPal\ApiClient\Http\SelfServiceClient; -/** - * Contains all ApiCalls pre and post processing that falls under SelfService Module - * Trait SelfServiceApis - * @package SupportPal\ApiClient\Api - */ class SelfServiceApi extends Api { - use ArticleApis; - use CategoryApis; - use CommentApis; - use SettingsApis; - use TagApis; - use TypeApis; + use Articles; + use Categories; + use Comments; + use Settings; + use Tags; + use Types; - /** @var SelfServiceApiClient */ - protected $apiClient; + public function __construct(protected readonly SelfServiceClient $apiClient) + { + } - /** - * @return SelfServiceApiClient - */ - protected function getApiClient(): SelfServiceApiClient + protected function getApiClient(): SelfServiceClient { return $this->apiClient; } diff --git a/src/Api/Ticket/AttachmentApis.php b/src/Api/Ticket/Attachments.php similarity index 73% rename from src/Api/Ticket/AttachmentApis.php rename to src/Api/Ticket/Attachments.php index 65ef6126..1f290108 100644 --- a/src/Api/Ticket/AttachmentApis.php +++ b/src/Api/Ticket/Attachments.php @@ -3,23 +3,19 @@ namespace SupportPal\ApiClient\Api\Ticket; use Psr\Http\Message\StreamInterface; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Ticket\Attachment; use function array_map; -trait AttachmentApis +trait Attachments { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -29,12 +25,10 @@ public function getAttachments(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createAttachment'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $attachmentId - * @return Attachment * @throws HttpResponseException */ public function getAttachment(int $attachmentId): Attachment @@ -45,8 +39,6 @@ public function getAttachment(int $attachmentId): Attachment } /** - * @param Attachment $attachment - * @return StreamInterface * @throws HttpResponseException * @throws MissingIdentifierException */ @@ -61,15 +53,11 @@ public function downloadAttachment(Attachment $attachment): StreamInterface /** * @param array $data - * @return Attachment */ private function createAttachment(array $data): Attachment { - /** @var Attachment $model */ - $model = $this->getModelCollectionFactory()->create(Attachment::class, $data); - - return $model; + return new Attachment($data); } - abstract protected function getApiClient(): TicketApiClient; + abstract protected function getApiClient(): TicketClient; } diff --git a/src/Api/Ticket/ChannelSettings.php b/src/Api/Ticket/ChannelSettings.php new file mode 100644 index 00000000..d9b7a61b --- /dev/null +++ b/src/Api/Ticket/ChannelSettings.php @@ -0,0 +1,22 @@ +getApiClient()->getChannelSettings($channel); + + return new ChannelSettingsModel($this->decodeBody($response)['data']); + } + + abstract protected function getApiClient(): TicketClient; +} diff --git a/src/Api/Ticket/ChannelSettingsApis.php b/src/Api/Ticket/ChannelSettingsApis.php deleted file mode 100644 index efa6d15c..00000000 --- a/src/Api/Ticket/ChannelSettingsApis.php +++ /dev/null @@ -1,35 +0,0 @@ -getApiClient()->getChannelSettings($channel); - /** @var ChannelSettings $model */ - $model = $this - ->getModelCollectionFactory() - ->create(ChannelSettings::class, $this->decodeBody($response)['data']); - - return $model; - } - - abstract protected function getApiClient(): TicketApiClient; -} diff --git a/src/Api/Ticket/CustomFieldApis.php b/src/Api/Ticket/CustomFields.php similarity index 69% rename from src/Api/Ticket/CustomFieldApis.php rename to src/Api/Ticket/CustomFields.php index 76a97781..8d2a79cd 100644 --- a/src/Api/Ticket/CustomFieldApis.php +++ b/src/Api/Ticket/CustomFields.php @@ -2,23 +2,19 @@ namespace SupportPal\ApiClient\Api\Ticket; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Shared\CustomField; use SupportPal\ApiClient\Model\Ticket\TicketCustomField; use function array_map; -trait CustomFieldApis +trait CustomFields { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -28,12 +24,10 @@ public function getCustomFields(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createTicketCustomField'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $customFieldId - * @return CustomField * @throws HttpResponseException */ public function getCustomField(int $customFieldId): CustomField @@ -45,15 +39,11 @@ public function getCustomField(int $customFieldId): CustomField /** * @param array $data - * @return TicketCustomField */ private function createTicketCustomField(array $data): TicketCustomField { - /** @var TicketCustomField $model */ - $model = $this->getModelCollectionFactory()->create(TicketCustomField::class, $data); - - return $model; + return new TicketCustomField($data); } - abstract protected function getApiClient(): TicketApiClient; + abstract protected function getApiClient(): TicketClient; } diff --git a/src/Api/Ticket/DepartmentApis.php b/src/Api/Ticket/Departments.php similarity index 64% rename from src/Api/Ticket/DepartmentApis.php rename to src/Api/Ticket/Departments.php index ace182d1..bb5f76e5 100644 --- a/src/Api/Ticket/DepartmentApis.php +++ b/src/Api/Ticket/Departments.php @@ -2,26 +2,18 @@ namespace SupportPal\ApiClient\Api\Ticket; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Department\Department; use function array_map; -/** - * Trait DepartmentApis, includes all related apis to departments - * @package SupportPal\ApiClient\Api\Ticket - */ -trait DepartmentApis +trait Departments { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -31,12 +23,10 @@ public function getDepartments(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createDepartment'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $departmentId - * @return Department * @throws HttpResponseException */ public function getDepartment(int $departmentId): Department @@ -48,15 +38,11 @@ public function getDepartment(int $departmentId): Department /** * @param array $data - * @return Department */ private function createDepartment(array $data): Department { - /** @var Department $model */ - $model = $this->getModelCollectionFactory()->create(Department::class, $data); - - return $model; + return new Department($data); } - abstract protected function getApiClient(): TicketApiClient; + abstract protected function getApiClient(): TicketClient; } diff --git a/src/Api/Ticket/MessageApis.php b/src/Api/Ticket/Messages.php similarity index 73% rename from src/Api/Ticket/MessageApis.php rename to src/Api/Ticket/Messages.php index 8e6427ef..eca82386 100644 --- a/src/Api/Ticket/MessageApis.php +++ b/src/Api/Ticket/Messages.php @@ -2,25 +2,21 @@ namespace SupportPal\ApiClient\Api\Ticket; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Ticket\Message; use SupportPal\ApiClient\Model\Ticket\Request\CreateMessage; use function array_map; -trait MessageApis +trait Messages { - use ApiAware; - /** * @param CreateMessage $message * @return Message * @throws HttpResponseException - * @throws InvalidArgumentException */ public function postMessage(CreateMessage $message): Message { @@ -30,9 +26,7 @@ public function postMessage(CreateMessage $message): Message } /** - * @param int $ticketId * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -43,12 +37,10 @@ public function getMessages(int $ticketId, array $queryParameters = []): Collect $body = $this->decodeBody($response); $models = array_map([$this, 'createMessage'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $messageId - * @return Message * @throws HttpResponseException */ public function getMessage(int $messageId): Message @@ -60,15 +52,11 @@ public function getMessage(int $messageId): Message /** * @param array $data - * @return Message */ private function createMessage(array $data): Message { - /** @var Message $model */ - $model = $this->getModelCollectionFactory()->create(Message::class, $data); - - return $model; + return new Message($data); } - abstract protected function getApiClient(): TicketApiClient; + abstract protected function getApiClient(): TicketClient; } diff --git a/src/Api/Ticket/PriorityApis.php b/src/Api/Ticket/Priorities.php similarity index 68% rename from src/Api/Ticket/PriorityApis.php rename to src/Api/Ticket/Priorities.php index 97fd4fc4..a9fb3a4e 100644 --- a/src/Api/Ticket/PriorityApis.php +++ b/src/Api/Ticket/Priorities.php @@ -2,22 +2,18 @@ namespace SupportPal\ApiClient\Api\Ticket; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Ticket\Priority; use function array_map; -trait PriorityApis +trait Priorities { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -27,12 +23,10 @@ public function getPriorities(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createPriority'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $priorityId - * @return Priority * @throws HttpResponseException */ public function getPriority(int $priorityId): Priority @@ -44,15 +38,11 @@ public function getPriority(int $priorityId): Priority /** * @param array $data - * @return Priority */ private function createPriority(array $data): Priority { - /** @var Priority $model */ - $model = $this->getModelCollectionFactory()->create(Priority::class, $data); - - return $model; + return new Priority($data); } - abstract protected function getApiClient(): TicketApiClient; + abstract protected function getApiClient(): TicketClient; } diff --git a/src/Api/Ticket/Settings.php b/src/Api/Ticket/Settings.php new file mode 100644 index 00000000..9b9d8c1b --- /dev/null +++ b/src/Api/Ticket/Settings.php @@ -0,0 +1,22 @@ +getApiClient()->getSettings(); + + return new SettingsModel($this->decodeBody($response)['data']); + } + + abstract protected function getApiClient(): TicketClient; +} diff --git a/src/Api/Ticket/SettingsApis.php b/src/Api/Ticket/SettingsApis.php deleted file mode 100644 index dda95f73..00000000 --- a/src/Api/Ticket/SettingsApis.php +++ /dev/null @@ -1,33 +0,0 @@ -getApiClient()->getSettings(); - /** @var Settings $model */ - $model = $this->getModelCollectionFactory()->create(Settings::class, $this->decodeBody($response)['data']); - - return $model; - } - - abstract protected function getApiClient(): TicketApiClient; -} diff --git a/src/Api/Ticket/StatusApis.php b/src/Api/Ticket/Statuses.php similarity index 68% rename from src/Api/Ticket/StatusApis.php rename to src/Api/Ticket/Statuses.php index 53cc9c08..b7476551 100644 --- a/src/Api/Ticket/StatusApis.php +++ b/src/Api/Ticket/Statuses.php @@ -2,22 +2,18 @@ namespace SupportPal\ApiClient\Api\Ticket; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Ticket\Status; use function array_map; -trait StatusApis +trait Statuses { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -27,12 +23,10 @@ public function getStatuses(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createStatus'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $statusId - * @return Status * @throws HttpResponseException */ public function getStatus(int $statusId): Status @@ -44,15 +38,11 @@ public function getStatus(int $statusId): Status /** * @param array $data - * @return Status */ private function createStatus(array $data): Status { - /** @var Status $model */ - $model = $this->getModelCollectionFactory()->create(Status::class, $data); - - return $model; + return new Status($data); } - abstract protected function getApiClient(): TicketApiClient; + abstract protected function getApiClient(): TicketClient; } diff --git a/src/Api/Ticket/TicketApis.php b/src/Api/Ticket/Tickets.php similarity index 76% rename from src/Api/Ticket/TicketApis.php rename to src/Api/Ticket/Tickets.php index 54af429f..c4366d63 100644 --- a/src/Api/Ticket/TicketApis.php +++ b/src/Api/Ticket/Tickets.php @@ -2,24 +2,20 @@ namespace SupportPal\ApiClient\Api\Ticket; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\Ticket\Request\CreateTicket; use SupportPal\ApiClient\Model\Ticket\Ticket; use function array_map; -trait TicketApis +trait Tickets { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -29,12 +25,10 @@ public function getTickets(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createTicket'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $ticketId - * @return Ticket * @throws HttpResponseException */ public function getTicket(int $ticketId): Ticket @@ -45,9 +39,7 @@ public function getTicket(int $ticketId): Ticket } /** - * @param Ticket $ticket * @param array $data - * @return Ticket * @throws InvalidArgumentException * @throws HttpResponseException */ @@ -63,8 +55,6 @@ public function updateTicket(Ticket $ticket, array $data): Ticket } /** - * @param CreateTicket $createTicket - * @return Ticket * @throws HttpResponseException */ public function postTicket(CreateTicket $createTicket): Ticket @@ -76,15 +66,11 @@ public function postTicket(CreateTicket $createTicket): Ticket /** * @param array $data - * @return Ticket */ private function createTicket(array $data): Ticket { - /** @var Ticket $model */ - $model = $this->getModelCollectionFactory()->create(Ticket::class, $data); - - return $model; + return new Ticket($data); } - abstract protected function getApiClient(): TicketApiClient; + abstract protected function getApiClient(): TicketClient; } diff --git a/src/Api/TicketApi.php b/src/Api/TicketApi.php index d8d8b48d..79654182 100644 --- a/src/Api/TicketApi.php +++ b/src/Api/TicketApi.php @@ -2,40 +2,34 @@ namespace SupportPal\ApiClient\Api; -use SupportPal\ApiClient\Api\Ticket\AttachmentApis; -use SupportPal\ApiClient\Api\Ticket\ChannelSettingsApis; -use SupportPal\ApiClient\Api\Ticket\CustomFieldApis; -use SupportPal\ApiClient\Api\Ticket\DepartmentApis; -use SupportPal\ApiClient\Api\Ticket\MessageApis; -use SupportPal\ApiClient\Api\Ticket\PriorityApis; -use SupportPal\ApiClient\Api\Ticket\SettingsApis; -use SupportPal\ApiClient\Api\Ticket\StatusApis; -use SupportPal\ApiClient\Api\Ticket\TicketApis; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Api\Ticket\Attachments; +use SupportPal\ApiClient\Api\Ticket\ChannelSettings; +use SupportPal\ApiClient\Api\Ticket\CustomFields; +use SupportPal\ApiClient\Api\Ticket\Departments; +use SupportPal\ApiClient\Api\Ticket\Messages; +use SupportPal\ApiClient\Api\Ticket\Priorities; +use SupportPal\ApiClient\Api\Ticket\Settings; +use SupportPal\ApiClient\Api\Ticket\Statuses; +use SupportPal\ApiClient\Api\Ticket\Tickets; +use SupportPal\ApiClient\Http\TicketClient; -/** - * Contains all ApiCalls pre and post processing that falls under Tickets Module - * @package SupportPal\ApiClient\Api - */ class TicketApi extends Api { - use AttachmentApis; - use ChannelSettingsApis; - use CustomFieldApis; - use DepartmentApis; - use PriorityApis; - use MessageApis; - use SettingsApis; - use StatusApis; - use TicketApis; + use Attachments; + use ChannelSettings; + use CustomFields; + use Departments; + use Priorities; + use Messages; + use Settings; + use Statuses; + use Tickets; - /** @var TicketApiClient */ - protected $apiClient; + public function __construct(protected readonly TicketClient $apiClient) + { + } - /** - * @return TicketApiClient - */ - protected function getApiClient(): TicketApiClient + protected function getApiClient(): TicketClient { return $this->apiClient; } diff --git a/src/Api/User/CustomFieldApis.php b/src/Api/User/CustomFields.php similarity index 68% rename from src/Api/User/CustomFieldApis.php rename to src/Api/User/CustomFields.php index 0299adda..99567bdb 100644 --- a/src/Api/User/CustomFieldApis.php +++ b/src/Api/User/CustomFields.php @@ -2,22 +2,18 @@ namespace SupportPal\ApiClient\Api\User; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\User\UserCustomField; use function array_map; -trait CustomFieldApis +trait CustomFields { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -27,12 +23,10 @@ public function getCustomFields(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createUserCustomField'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $customFieldId - * @return UserCustomField * @throws HttpResponseException */ public function getCustomField(int $customFieldId): UserCustomField @@ -44,15 +38,11 @@ public function getCustomField(int $customFieldId): UserCustomField /** * @param array $data - * @return UserCustomField */ private function createUserCustomField(array $data): UserCustomField { - /** @var UserCustomField $model */ - $model = $this->getModelCollectionFactory()->create(UserCustomField::class, $data); - - return $model; + return new UserCustomField($data); } - abstract protected function getApiClient(): UserApiClient; + abstract protected function getApiClient(): UserClient; } diff --git a/src/Api/User/UserGroupApis.php b/src/Api/User/UserGroups.php similarity index 69% rename from src/Api/User/UserGroupApis.php rename to src/Api/User/UserGroups.php index c34e8fbb..32c3aebd 100644 --- a/src/Api/User/UserGroupApis.php +++ b/src/Api/User/UserGroups.php @@ -2,22 +2,18 @@ namespace SupportPal\ApiClient\Api\User; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\User\Group; use function array_map; -trait UserGroupApis +trait UserGroups { - use ApiAware; - - /** + /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -27,12 +23,10 @@ public function getGroups(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createGroup'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $userGroupId - * @return Group * @throws HttpResponseException */ public function getGroup(int $userGroupId): Group @@ -48,11 +42,8 @@ public function getGroup(int $userGroupId): Group */ private function createGroup(array $data): Group { - /** @var Group $model */ - $model = $this->getModelCollectionFactory()->create(Group::class, $data); - - return $model; + return new Group($data); } - abstract protected function getApiClient(): UserApiClient; + abstract protected function getApiClient(): UserClient; } diff --git a/src/Api/User/UserApis.php b/src/Api/User/Users.php similarity index 76% rename from src/Api/User/UserApis.php rename to src/Api/User/Users.php index e24b2d89..c4ec8404 100644 --- a/src/Api/User/UserApis.php +++ b/src/Api/User/Users.php @@ -2,24 +2,20 @@ namespace SupportPal\ApiClient\Api\User; -use SupportPal\ApiClient\Api\ApiAware; -use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Model\Collection\Collection; use SupportPal\ApiClient\Model\User\Request\CreateUser; use SupportPal\ApiClient\Model\User\User; use function array_map; -trait UserApis +trait Users { - use ApiAware; - /** * @param array $queryParameters - * @return Collection * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -29,12 +25,10 @@ public function getUsers(array $queryParameters = []): Collection $body = $this->decodeBody($response); $models = array_map([$this, 'createUser'], $body['data']); - return $this->getCollectionFactory()->create($body['count'], $models); + return $this->createCollection($body['count'], $models); } /** - * @param int $userId - * @return User * @throws HttpResponseException */ public function getUser(int $userId): User @@ -45,9 +39,7 @@ public function getUser(int $userId): User } /** - * @param User $user * @param array $data - * @return User * @throws HttpResponseException * @throws InvalidArgumentException */ @@ -63,8 +55,6 @@ public function updateUser(User $user, array $data): User } /** - * @param CreateUser $createUser - * @return User * @throws HttpResponseException */ public function postUser(CreateUser $createUser): User @@ -76,15 +66,11 @@ public function postUser(CreateUser $createUser): User /** * @param array $data - * @return User */ private function createUser(array $data): User { - /** @var User $model */ - $model = $this->getModelCollectionFactory()->create(User::class, $data); - - return $model; + return new User($data); } - abstract protected function getApiClient(): UserApiClient; + abstract protected function getApiClient(): UserClient; } diff --git a/src/Api/UserApi.php b/src/Api/UserApi.php index 520b6ab4..178541a7 100644 --- a/src/Api/UserApi.php +++ b/src/Api/UserApi.php @@ -2,28 +2,22 @@ namespace SupportPal\ApiClient\Api; -use SupportPal\ApiClient\Api\User\CustomFieldApis; -use SupportPal\ApiClient\Api\User\UserApis; -use SupportPal\ApiClient\Api\User\UserGroupApis; -use SupportPal\ApiClient\ApiClient\UserApiClient; +use SupportPal\ApiClient\Api\User\CustomFields; +use SupportPal\ApiClient\Api\User\Users; +use SupportPal\ApiClient\Api\User\UserGroups; +use SupportPal\ApiClient\Http\UserClient; -/** - * Trait UserApis, includes all related ApiCalls pre and post processing related to Users - * @package SupportPal\ApiClient\Api\Core - */ class UserApi extends Api { - use CustomFieldApis; - use UserApis; - use UserGroupApis; + use CustomFields; + use Users; + use UserGroups; - /** @var UserApiClient */ - protected $apiClient; + public function __construct(protected readonly UserClient $apiClient) + { + } - /** - * @inheritDoc - */ - protected function getApiClient(): UserApiClient + protected function getApiClient(): UserClient { return $this->apiClient; } diff --git a/src/ApiClient/CoreApiClient.php b/src/ApiClient/CoreApiClient.php deleted file mode 100644 index dd516eb5..00000000 --- a/src/ApiClient/CoreApiClient.php +++ /dev/null @@ -1,18 +0,0 @@ -factories[$factory->getModel()] = $factory; - } - } - - /** - * This method creates a Model instance - * @param string $key - * @param array $data - * @return Model - */ - public function create(string $key, array $data): Model - { - if (! isset($this->factories[$key])) { - throw new NotSupportedException; - } - - return $this->factories[$key]->create($data); - } -} diff --git a/src/Factory/ModelFactory.php b/src/Factory/ModelFactory.php deleted file mode 100644 index 31beed50..00000000 --- a/src/Factory/ModelFactory.php +++ /dev/null @@ -1,28 +0,0 @@ -getModel(); - - return (new $modelClass)->fill($data); - } - - /** - * @return class-string - */ - abstract public function getModel(): string; -} diff --git a/src/Factory/SelfService/ArticleFactory.php b/src/Factory/SelfService/ArticleFactory.php deleted file mode 100644 index c507ee20..00000000 --- a/src/Factory/SelfService/ArticleFactory.php +++ /dev/null @@ -1,21 +0,0 @@ -httpClient = $httpClient; - $this->requestFactory = $requestFactory; } /** @@ -86,7 +64,7 @@ protected function sendDownloadRequest(RequestInterface $request): ResponseInter */ protected function prepareAndSendGetRequest(string $endpoint, array $queryParameters): ResponseInterface { - $request = $this->getRequestFactory()->create('GET', $endpoint, [], [], $queryParameters); + $request = $this->getRequest()->create('GET', $endpoint, [], [], $queryParameters); return $this->sendRequest($request); } @@ -132,8 +110,8 @@ protected function getHttpClient(): ClientInterface /** * @inheritDoc */ - protected function getRequestFactory(): RequestFactory + protected function getRequest(): Request { - return $this->requestFactory; + return $this->request; } } diff --git a/src/ApiClient/Core/BrandApis.php b/src/Http/Core/BrandApis.php similarity index 89% rename from src/ApiClient/Core/BrandApis.php rename to src/Http/Core/BrandApis.php index 4b4f6fe4..f9ea0f63 100644 --- a/src/ApiClient/Core/BrandApis.php +++ b/src/Http/Core/BrandApis.php @@ -1,11 +1,11 @@ apiUrl . $endpoint); - return new Request( + return new BaseRequest( $method, $uri->withQuery(http_build_query(array_merge($this->defaultParameters, $queryParameters))), $headers, diff --git a/src/ApiClient/SelfService/ArticleApis.php b/src/Http/SelfService/ArticleApis.php similarity index 91% rename from src/ApiClient/SelfService/ArticleApis.php rename to src/Http/SelfService/ArticleApis.php index cafeb6d0..b3bccda0 100644 --- a/src/ApiClient/SelfService/ArticleApis.php +++ b/src/Http/SelfService/ArticleApis.php @@ -1,15 +1,15 @@ getRequestFactory()->create( + $request = $this->getRequest()->create( 'POST', ApiDictionary::SELF_SERVICE_COMMENT, [], diff --git a/src/ApiClient/SelfService/SettingsApis.php b/src/Http/SelfService/SettingsApis.php similarity index 77% rename from src/ApiClient/SelfService/SettingsApis.php rename to src/Http/SelfService/SettingsApis.php index 034dd5a8..076d141d 100644 --- a/src/ApiClient/SelfService/SettingsApis.php +++ b/src/Http/SelfService/SettingsApis.php @@ -1,15 +1,15 @@ getRequestFactory()->create( + $request = $this->getRequest()->create( 'GET', sprintf(ApiDictionary::TICKET_ATTACHMENT_DOWNLOAD, $attachmentId) ); diff --git a/src/ApiClient/Ticket/ChannelSettingsApis.php b/src/Http/Ticket/ChannelSettingsApis.php similarity index 85% rename from src/ApiClient/Ticket/ChannelSettingsApis.php rename to src/Http/Ticket/ChannelSettingsApis.php index 52ea2beb..98c543f6 100644 --- a/src/ApiClient/Ticket/ChannelSettingsApis.php +++ b/src/Http/Ticket/ChannelSettingsApis.php @@ -1,11 +1,11 @@ getRequestFactory()->create( + $request = $this->getRequest()->create( 'POST', ApiDictionary::TICKET_MESSAGE, [], diff --git a/src/ApiClient/Ticket/PriorityApis.php b/src/Http/Ticket/PriorityApis.php similarity index 89% rename from src/ApiClient/Ticket/PriorityApis.php rename to src/Http/Ticket/PriorityApis.php index 383f66a5..b525a8ec 100644 --- a/src/ApiClient/Ticket/PriorityApis.php +++ b/src/Http/Ticket/PriorityApis.php @@ -1,11 +1,11 @@ $queryParameters @@ -59,7 +39,7 @@ public function getTicket(int $ticketId): ResponseInterface */ public function updateTicket(int $ticketId, array $body): ResponseInterface { - $request = $this->getRequestFactory()->create( + $request = $this->getRequest()->create( 'PUT', ApiDictionary::TICKET_TICKET . '/' . $ticketId, [], @@ -76,7 +56,7 @@ public function updateTicket(int $ticketId, array $body): ResponseInterface */ public function postTicket(array $body): ResponseInterface { - $request = $this->getRequestFactory()->create( + $request = $this->getRequest()->create( 'POST', ApiDictionary::TICKET_TICKET, [], diff --git a/src/Http/TicketClient.php b/src/Http/TicketClient.php new file mode 100644 index 00000000..cfe5c1a8 --- /dev/null +++ b/src/Http/TicketClient.php @@ -0,0 +1,26 @@ + $queryParameters @@ -46,7 +39,7 @@ public function getUser(int $userId): ResponseInterface */ public function updateUser(int $userId, array $body): ResponseInterface { - $request = $this->getRequestFactory()->create( + $request = $this->getRequest()->create( 'PUT', ApiDictionary::USER_USER . '/' . $userId, [], @@ -63,7 +56,7 @@ public function updateUser(int $userId, array $body): ResponseInterface */ public function postUser(array $body): ResponseInterface { - $request = $this->getRequestFactory()->create( + $request = $this->getRequest()->create( 'POST', ApiDictionary::USER_USER, [], diff --git a/src/ApiClient/User/UserGroupApis.php b/src/Http/User/UserGroupApis.php similarity index 89% rename from src/ApiClient/User/UserGroupApis.php rename to src/Http/User/UserGroupApis.php index e5501597..b2f456e4 100644 --- a/src/ApiClient/User/UserGroupApis.php +++ b/src/Http/User/UserGroupApis.php @@ -1,11 +1,11 @@ setParameter('defaultBodyContent', $requestDefaults->getDefaultBodyContent()); $containerBuilder->set( - Client::class, + GuzzleClient::class, $this->getGuzzleClient($apiContext, $requestDefaults->getDefaultRequestOptions(), $cacheDir) ); @@ -123,15 +124,14 @@ public function getUserApi(): UserApi } /** - * @return RequestFactory * @throws Exception */ - public function getRequestFactory(): RequestFactory + public function getRequestFactory(): Request { - /** @var RequestFactory $requestFactory */ - $requestFactory = $this->containerBuilder->get(RequestFactory::class); + /** @var Request $request */ + $request = $this->containerBuilder->get(Request::class); - return $requestFactory; + return $request; } /** @@ -141,8 +141,8 @@ public function getRequestFactory(): RequestFactory */ public function sendRequest(RequestInterface $request): ResponseInterface { - /** @var ApiClient $apiClient */ - $apiClient = $this->containerBuilder->get(ApiClient::class); + /** @var Client $apiClient */ + $apiClient = $this->containerBuilder->get(Client::class); return $apiClient->sendRequest($request); } @@ -158,7 +158,7 @@ private function getGuzzleClient(ApiContext $apiContext, array $requestDefaults, $stack = HandlerStack::create(); $stack->push(new CacheMiddleware($this->buildCacheStrategy($apiContext, $cacheDir))); - return new Client(array_merge(['handler' => $stack,], $requestDefaults)); + return new GuzzleClient(array_merge(['handler' => $stack], $requestDefaults)); } /** diff --git a/test/Cache/CacheableApisTest.php b/test/Cache/CacheableApisTest.php index 88d2b464..959bacfb 100644 --- a/test/Cache/CacheableApisTest.php +++ b/test/Cache/CacheableApisTest.php @@ -3,19 +3,19 @@ namespace SupportPal\ApiClient\Tests\Cache; use Exception; -use GuzzleHttp\Client; +use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\HandlerStack; use GuzzleHttp\Psr7\Response; use Kevinrob\GuzzleCache\CacheMiddleware; use Kevinrob\GuzzleCache\Strategy\CacheStrategyInterface; -use SupportPal\ApiClient\ApiClient; -use SupportPal\ApiClient\ApiClient\CoreApiClient; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; -use SupportPal\ApiClient\ApiClient\TicketApiClient; -use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Cache\ApiCacheMap; use SupportPal\ApiClient\Cache\CacheStrategyConfigurator; +use SupportPal\ApiClient\Http\Client; +use SupportPal\ApiClient\Http\CoreClient; +use SupportPal\ApiClient\Http\SelfServiceClient; +use SupportPal\ApiClient\Http\TicketClient; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Tests\ContainerAwareBaseTestCase; use SupportPal\ApiClient\Tests\DataFixtures\Core\BrandData; use SupportPal\ApiClient\Tests\DataFixtures\Core\CoreSettingsData; @@ -60,7 +60,7 @@ public function testGetCacheableApiTestCacheHit( array $parameters, string $apiClientClass ): void { - /** @var ApiClient $apiClient */ + /** @var Client $apiClient */ $apiClient = $this->getContainer()->get($apiClientClass); $this->mockResponses($data); @@ -92,7 +92,7 @@ public function testGetCacheableApiTestCacheMiss( array $parameters, string $apiClientClass ): void { - /** @var ApiClient $apiClient */ + /** @var Client $apiClient */ $apiClient = $this->getContainer()->get($apiClientClass); $response = new Response(200, [], (string) json_encode($data)); @@ -140,7 +140,7 @@ public function testNonCacheableApisAlwaysMiss( array $parameters, string $apiClientClass ): void { - /** @var ApiClient $apiClient */ + /** @var Client $apiClient */ $apiClient = $this->getContainer()->get($apiClientClass); $this->mockResponses($data); [$response1, $response2] = $this->sendRequests($apiClient, $endpoint, $parameters); @@ -172,9 +172,9 @@ protected function tearDown(): void public function provideCacheableApiCalls(): iterable { /** core Apis */ - yield ['getSettings', (new CoreSettingsData)->getResponse(), [], CoreApiClient::class]; - yield ['getBrand', (new BrandData)->getResponse(), [1], CoreApiClient::class]; - yield ['getBrands', (new BrandData)->getAllResponse(), [[]], CoreApiClient::class]; + yield [ 'getSettings', (new CoreSettingsData)->getResponse(), [], CoreClient::class]; + yield [ 'getBrand', (new BrandData)->getResponse(), [1], CoreClient::class]; + yield [ 'getBrands', (new BrandData)->getAllResponse(), [[]], CoreClient::class]; /** SelfService Apis */ $typeData = new TypeData; @@ -183,17 +183,17 @@ public function provideCacheableApiCalls(): iterable $articleData = new ArticleData; $tagData = new TagData; - yield ['getCategory', $categoryData->getResponse(), [1], SelfServiceApiClient::class]; - yield ['getCategories', $categoryData->getAllResponse(), [[]], SelfServiceApiClient::class]; - yield ['getArticle', $articleData->getResponse(), [1, []], SelfServiceApiClient::class]; - yield ['getArticlesByTerm', $articleData->getAllResponse(), [['test']], SelfServiceApiClient::class]; - yield ['getArticles', $articleData->getAllResponse(), [[]], SelfServiceApiClient::class]; - yield ['getRelatedArticles', $articleData->getAllResponse(), [[1, 'test', []]], SelfServiceApiClient::class]; - yield ['getTag', $tagData->getResponse(), [1], SelfServiceApiClient::class]; - yield ['getTags', $tagData->getAllResponse(), [[]], SelfServiceApiClient::class]; - yield ['getSettings', $selfServiceSettingsData->getResponse(), [], SelfServiceApiClient::class]; - yield ['getType', $typeData->getResponse(), [1], SelfServiceApiClient::class]; - yield ['getTypes', $typeData->getAllResponse(), [[]], SelfServiceApiClient::class]; + yield [ 'getCategory', $categoryData->getResponse(), [1], SelfServiceClient::class]; + yield [ 'getCategories', $categoryData->getAllResponse(), [[]], SelfServiceClient::class]; + yield [ 'getArticle', $articleData->getResponse(), [1, []], SelfServiceClient::class]; + yield [ 'getArticlesByTerm', $articleData->getAllResponse(), [['test']], SelfServiceClient::class]; + yield [ 'getArticles', $articleData->getAllResponse(), [[]], SelfServiceClient::class]; + yield [ 'getRelatedArticles', $articleData->getAllResponse(), [[1, 'test', []]], SelfServiceClient::class]; + yield [ 'getTag', $tagData->getResponse(), [1], SelfServiceClient::class]; + yield [ 'getTags', $tagData->getAllResponse(), [[]], SelfServiceClient::class]; + yield [ 'getSettings', $selfServiceSettingsData->getResponse(), [], SelfServiceClient::class]; + yield [ 'getType', $typeData->getResponse(), [1], SelfServiceClient::class]; + yield [ 'getTypes', $typeData->getAllResponse(), [[]], SelfServiceClient::class]; $departmentData = new DepartmentData; $ticketCustomFieldData = new TicketCustomFieldData; @@ -202,24 +202,24 @@ public function provideCacheableApiCalls(): iterable $ticketSettingsData = new TicketSettingsData; /** Ticket Apis */ - yield ['getDepartments', $departmentData->getAllResponse(), [[]], TicketApiClient::class]; - yield ['getDepartment', $departmentData->getResponse(), [1], TicketApiClient::class]; - yield ['getCustomFields', $ticketCustomFieldData->getAllResponse(), [[]], TicketApiClient::class]; - yield ['getCustomField', $ticketCustomFieldData->getResponse(), [1], TicketApiClient::class]; - yield ['getPriorities', $priorityData->getAllResponse(), [[]], TicketApiClient::class]; - yield ['getPriority', $statusData->getResponse(), [1], TicketApiClient::class]; - yield ['getStatuses', $statusData->getAllResponse(), [[]], TicketApiClient::class]; - yield ['getStatus', $statusData->getResponse(), [1], TicketApiClient::class]; - yield ['getSettings', $ticketSettingsData->getResponse(), [], TicketApiClient::class]; + yield [ 'getDepartments', $departmentData->getAllResponse(), [[]], TicketClient::class]; + yield [ 'getDepartment', $departmentData->getResponse(), [1], TicketClient::class]; + yield [ 'getCustomFields', $ticketCustomFieldData->getAllResponse(), [[]], TicketClient::class]; + yield [ 'getCustomField', $ticketCustomFieldData->getResponse(), [1], TicketClient::class]; + yield [ 'getPriorities', $priorityData->getAllResponse(), [[]], TicketClient::class]; + yield [ 'getPriority', $statusData->getResponse(), [1], TicketClient::class]; + yield [ 'getStatuses', $statusData->getAllResponse(), [[]], TicketClient::class]; + yield [ 'getStatus', $statusData->getResponse(), [1], TicketClient::class]; + yield [ 'getSettings', $ticketSettingsData->getResponse(), [], TicketClient::class]; /** User Apis */ $userGroupsData = new GroupData; $customFieldData = new UserCustomFieldData; - yield ['getGroups', $userGroupsData->getAllResponse(), [[]], UserApiClient::class]; - yield ['getGroup', $userGroupsData->getAllResponse(), [1], UserApiClient::class]; - yield ['getCustomFields', $customFieldData->getAllResponse(), [[]], UserApiClient::class]; - yield ['getCustomField', $customFieldData->getResponse(), [1], UserApiClient::class]; + yield [ 'getGroups', $userGroupsData->getAllResponse(), [[]], UserClient::class]; + yield [ 'getGroup', $userGroupsData->getAllResponse(), [1], UserClient::class]; + yield [ 'getCustomFields', $customFieldData->getAllResponse(), [[]], UserClient::class]; + yield [ 'getCustomField', $customFieldData->getResponse(), [1], UserClient::class]; } /** @@ -234,27 +234,27 @@ public function provideNonCacheableApis(): iterable /** SelfService Apis */ $commentData = new CommentData; - yield ['getComment', $commentData->getResponse(), [1], SelfServiceApiClient::class]; - yield ['getComments', $commentData->getAllResponse(), [[]], SelfServiceApiClient::class]; + yield [ 'getComment', $commentData->getResponse(), [1], SelfServiceClient::class]; + yield [ 'getComments', $commentData->getAllResponse(), [[]], SelfServiceClient::class]; /** Ticket Apis */ - yield ['getAttachments', $attachmentData->getAllResponse(), [[]], TicketApiClient::class]; - yield ['getAttachment', $attachmentData->getResponse(), [1], TicketApiClient::class]; - yield ['getTickets', $ticketData->getAllResponse(), [[]], TicketApiClient::class]; - yield ['getTicket', $ticketData->getResponse(), [1], TicketApiClient::class]; - yield ['getMessage', $messageData->getResponse(), [1], TicketApiClient::class]; - yield ['getMessages', $messageData->getAllResponse(), [[]], TicketApiClient::class]; + yield [ 'getAttachments', $attachmentData->getAllResponse(), [[]], TicketClient::class]; + yield [ 'getAttachment', $attachmentData->getResponse(), [1], TicketClient::class]; + yield [ 'getTickets', $ticketData->getAllResponse(), [[]], TicketClient::class]; + yield [ 'getTicket', $ticketData->getResponse(), [1], TicketClient::class]; + yield [ 'getMessage', $messageData->getResponse(), [1], TicketClient::class]; + yield [ 'getMessages', $messageData->getAllResponse(), [[]], TicketClient::class]; /** User Apis */ $userData = new UserData; - yield ['getUsers', $userData->getAllResponse(), [[]], UserApiClient::class]; + yield [ 'getUsers', $userData->getAllResponse(), [[]], UserClient::class]; } /** * @inheritDoc */ - protected function getGuzzleClient(): Client + protected function getGuzzleClient(): GuzzleClient { /** * replace GuzzleClient with MockClient @@ -263,7 +263,7 @@ protected function getGuzzleClient(): Client $handlerStack = HandlerStack::create($this->mockRequestHandler); $handlerStack->push(new CacheMiddleware($this->buildCacheStrategy(sys_get_temp_dir()))); - return new Client(['handler' => $handlerStack]); + return new GuzzleClient(['handler' => $handlerStack]); } /** @@ -296,12 +296,12 @@ protected function mockResponses(array $data): void } /** - * @param ApiClient $apiClient + * @param Client $apiClient * @param string $endpoint * @param array $parameters * @return Response[] */ - protected function sendRequests(ApiClient $apiClient, string $endpoint, array $parameters): array + protected function sendRequests(Client $apiClient, string $endpoint, array $parameters): array { /** @var callable $callable */ $callable = [$apiClient, $endpoint]; diff --git a/test/CollectionFactoryTestCase.php b/test/CollectionFactoryTestCase.php deleted file mode 100644 index 8cfb957d..00000000 --- a/test/CollectionFactoryTestCase.php +++ /dev/null @@ -1,57 +0,0 @@ - $input - * @dataProvider provideInvalidInputs - */ - public function testCreateWithInvalidInput(array $input): void - { - self::expectException(InvalidArgumentException::class); - $this->collectionFactory->create(1, $input); - } - - public function testCreateWithValidInput(): void - { - $input = [new Comment, new Comment, new Comment]; - $collection = $this->collectionFactory->create(count($input), $input); - self::assertSame(count($input), $collection->getCount()); - self::assertSame(count($input), $collection->getModelsCount()); - self::assertSame($input, $collection->getModels()); - } - - public function testTotalModelsNotMatchingModelsCount(): void - { - $input = [new Comment, new Comment, new Comment]; - $collection = $this->collectionFactory->create(count($input) + 10, $input); - self::assertSame(count($input) + 10, $collection->getCount()); - self::assertSame(count($input), $collection->getModelsCount()); - self::assertSame($input, $collection->getModels()); - } - - /** - * @return iterable - */ - public function provideInvalidInputs(): iterable - { - return [ - 'all invalid types' => [['test', 'test']], - 'mixed invalid types with comment' => [['test', new Comment]], - 'mixed invalid types with tag' => [[new Tag, 'test', new Tag]], - 'mixed valid types' => [[new Tag, new Tag, new Comment]], - ]; - } -} diff --git a/test/FactoryTestCase.php b/test/FactoryTestCase.php deleted file mode 100644 index 261e4a03..00000000 --- a/test/FactoryTestCase.php +++ /dev/null @@ -1,27 +0,0 @@ - - */ - abstract protected function getModelData(): array; - - /** - * @return class-string - */ - abstract protected function getModel(): string; - - /** - * @return ModelFactory - */ - abstract protected function getModelFactory(): ModelFactory; -} diff --git a/test/Functional/SupportPalTest.php b/test/Functional/SupportPalTest.php index 292d9593..bbeac4a7 100644 --- a/test/Functional/SupportPalTest.php +++ b/test/Functional/SupportPalTest.php @@ -6,7 +6,7 @@ use GuzzleHttp\Psr7\Response; use SupportPal\ApiClient\Config\ApiContext; use SupportPal\ApiClient\Exception\HttpResponseException; -use SupportPal\ApiClient\Factory\RequestFactory; +use SupportPal\ApiClient\Http\Request; use SupportPal\ApiClient\SupportPal; use SupportPal\ApiClient\Tests\ContainerAwareBaseTestCase; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; @@ -23,7 +23,7 @@ class SupportPalTest extends ContainerAwareBaseTestCase { public function testGetRequestFactory(): void { - self::assertInstanceOf(RequestFactory::class, $this->getSupportPal()->getRequestFactory()); + self::assertInstanceOf(Request::class, $this->getSupportPal()->getRequestFactory()); } public function testSendRequestSuccessful(): void diff --git a/test/Integration/ApiClient/CoreApisTest.php b/test/Integration/ApiClient/CoreApisTest.php index 55e4abba..b8a31404 100644 --- a/test/Integration/ApiClient/CoreApisTest.php +++ b/test/Integration/ApiClient/CoreApisTest.php @@ -2,7 +2,7 @@ namespace SupportPal\ApiClient\Tests\Integration\ApiClient; -use SupportPal\ApiClient\ApiClient\CoreApiClient; +use SupportPal\ApiClient\Http\CoreClient; use SupportPal\ApiClient\Tests\DataFixtures\Core\BrandData; use SupportPal\ApiClient\Tests\DataFixtures\Core\CoreSettingsData; use SupportPal\ApiClient\Tests\Integration\ApiClientTest; @@ -48,6 +48,6 @@ protected function getPutEndpoints(): array */ protected function getApiClientClass() { - return CoreApiClient::class; + return CoreClient::class; } } diff --git a/test/Integration/ApiClient/SelfServiceApisTest.php b/test/Integration/ApiClient/SelfServiceApisTest.php index c56bc40d..eb83c773 100644 --- a/test/Integration/ApiClient/SelfServiceApisTest.php +++ b/test/Integration/ApiClient/SelfServiceApisTest.php @@ -2,7 +2,7 @@ namespace SupportPal\ApiClient\Tests\Integration\ApiClient; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\ArticleData; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CategoryData; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; @@ -73,6 +73,6 @@ public function getPutEndpoints(): array */ protected function getApiClientClass() { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Integration/ApiClient/TicketApisTest.php b/test/Integration/ApiClient/TicketApisTest.php index 56720a40..f38f3d8b 100644 --- a/test/Integration/ApiClient/TicketApisTest.php +++ b/test/Integration/ApiClient/TicketApisTest.php @@ -2,7 +2,7 @@ namespace SupportPal\ApiClient\Tests\Integration\ApiClient; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\AttachmentData; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\ChannelSettingsData; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\DepartmentData; @@ -97,6 +97,6 @@ protected function getDownloadsEndpoints(): array */ protected function getApiClientClass() { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Integration/ApiClient/UserApisTest.php b/test/Integration/ApiClient/UserApisTest.php index 1d6e7df4..a2ec5994 100644 --- a/test/Integration/ApiClient/UserApisTest.php +++ b/test/Integration/ApiClient/UserApisTest.php @@ -2,7 +2,7 @@ namespace SupportPal\ApiClient\Tests\Integration\ApiClient; -use SupportPal\ApiClient\ApiClient\UserApiClient; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Tests\DataFixtures\User\GroupData; use SupportPal\ApiClient\Tests\DataFixtures\User\Request\CreateUserData; use SupportPal\ApiClient\Tests\DataFixtures\User\UserCustomFieldData; @@ -63,6 +63,6 @@ protected function getPutEndpoints(): array */ protected function getApiClientClass() { - return UserApiClient::class; + return UserClient::class; } } diff --git a/test/Integration/ApiClientTest.php b/test/Integration/ApiClientTest.php index f2d3f0f1..f110d3d7 100644 --- a/test/Integration/ApiClientTest.php +++ b/test/Integration/ApiClientTest.php @@ -7,8 +7,8 @@ use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; use Psr\Http\Message\ResponseInterface; -use SupportPal\ApiClient\ApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\Client; use SupportPal\ApiClient\Tests\ApiDataProviders; use SupportPal\ApiClient\Tests\ContainerAwareBaseTestCase; @@ -16,15 +16,11 @@ use function json_decode; use function json_encode; -/** - * Class ApiClientTest - * @package SupportPal\ApiClient\Tests\Integration - */ class ApiClientTest extends ContainerAwareBaseTestCase { use ApiDataProviders; - /** @var ApiClient */ + /** @var Client */ protected $apiClient; /** @@ -35,7 +31,7 @@ class ApiClientTest extends ContainerAwareBaseTestCase protected function setUp(): void { parent::setUp(); - /** @var ApiClient $apiClient */ + /** @var Client $apiClient */ $apiClient = $this->getContainer()->get($this->getApiClientClass()); $this->apiClient = $apiClient; } @@ -226,6 +222,6 @@ protected function makeClientCall(string $endpoint, array $parameters): Response */ protected function getApiClientClass() { - return ApiClient::class; + return Client::class; } } diff --git a/test/Integration/Factory/BaseModelFactoryTestCase.php b/test/Integration/Factory/BaseModelFactoryTestCase.php deleted file mode 100644 index c6faf13b..00000000 --- a/test/Integration/Factory/BaseModelFactoryTestCase.php +++ /dev/null @@ -1,76 +0,0 @@ -getModelData(); - $model = $this->getModelFactory()->create($modelData); - self::assertInstanceOf($this->getModel(), $model); - $this->assertArrayEqualsObjectFields($model, $modelData); - } - - /** - * @dataProvider provideDataWithInvalidTypes - * @param array $data - * @param string $invalidKey - */ - public function testCreateWithInvalidTypes(array $data, string $invalidKey): void - { - self::expectException(InvalidArgumentException::class); - if (! $data[$invalidKey] instanceof stdClass) { - self::expectExceptionMessage(gettype(self::ATOMIC_VALUE)); - } - - if ($data[$invalidKey] instanceof stdClass) { - self::expectExceptionMessage($this->snakeCaseToCamelCase($invalidKey)); - } - - $this->getModelFactory()->create($data); - } - - /** - * @return iterable - */ - public function provideDataWithInvalidTypes(): iterable - { - foreach ($this->getModelData() as $key => $value) { - $commentDataCopy = $this->getModelData(); - - /** - * test only support atomic values. - * Serializer dependency returns empty objects in case of not matching data attributes - * This shouldn't be a problem, since factories are only used internally (mapping API responses) - * Null values are also not processed. - */ - if (is_array($value) || $value === null) { - continue; - } - - $commentDataCopy[$key] = new stdClass; - - yield [$commentDataCopy, $key]; - } - } -} diff --git a/test/Integration/Factory/Collection/CollectionFactoryTest.php b/test/Integration/Factory/Collection/CollectionFactoryTest.php deleted file mode 100644 index 9b7a4305..00000000 --- a/test/Integration/Factory/Collection/CollectionFactoryTest.php +++ /dev/null @@ -1,17 +0,0 @@ -getContainer()->get(CollectionFactory::class); - $this->collectionFactory = $collectionFactory; - } -} diff --git a/test/Integration/Factory/Core/BrandFactoryTest.php b/test/Integration/Factory/Core/BrandFactoryTest.php deleted file mode 100644 index edbf9c0e..00000000 --- a/test/Integration/Factory/Core/BrandFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Brand::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(BrandFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Core/UserFactoryTest.php b/test/Integration/Factory/Core/UserFactoryTest.php deleted file mode 100644 index 491d9ef7..00000000 --- a/test/Integration/Factory/Core/UserFactoryTest.php +++ /dev/null @@ -1,43 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return User::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(UserFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/ModelCollectionFactoryTest.php b/test/Integration/Factory/ModelCollectionFactoryTest.php deleted file mode 100644 index 8d7010f2..00000000 --- a/test/Integration/Factory/ModelCollectionFactoryTest.php +++ /dev/null @@ -1,110 +0,0 @@ - CommentData::class, - Article::class => ArticleData::class, - User::class => UserData::class, - Ticket::class => TicketData::class, - Department::class => DepartmentData::class, - ]; - - /** @var ModelCollectionFactory */ - private $modelCollectionFactory; - - protected function setUp(): void - { - parent::setUp(); - /** @var ModelCollectionFactory $modelCollection */ - $modelCollection = $this->getContainer()->get(ModelCollectionFactory::class); - $this->modelCollectionFactory = $modelCollection; - } - - /** - * @param array $data - * @param string $model - * @dataProvider provideValidModelData - */ - public function testCreateValidModel(array $data, string $model): void - { - $model = $this->modelCollectionFactory->create($model, $data); - $this->assertArrayEqualsObjectFields($model, $data); - } - - /** - * @dataProvider provideDataWithInvalidTypes - * @param array $data - * @param string $model - * @param string $invalidKey - */ - public function testCreateWithInvalidTypes(array $data, string $model, string $invalidKey): void - { - self::expectException(InvalidArgumentException::class); - self::expectExceptionMessage($this->snakeCaseToCamelCase($invalidKey)); - $this->modelCollectionFactory->create($model, $data); - } - - /** - * @return iterable - * @SuppressWarnings(PHPMD.MissingImport) - */ - public function provideValidModelData(): iterable - { - foreach (self::MODELS_MAP as $model => $dataModel) { - $modelData = (new $dataModel)->getArrayData(); - - yield [$modelData, $model]; - } - } - - /** - * @return iterable - * @SuppressWarnings(PHPMD.MissingImport) - */ - public function provideDataWithInvalidTypes(): iterable - { - foreach (self::MODELS_MAP as $model => $data) { - $modelData = (new $data)->getArrayData(); - foreach ($modelData as $key => $value) { - /** - * test only support atomic values. - * Serializer dependency returns empty objects in case of not matching data attributes - * This shouldn't be a problem, since factories are only used internally (mapping API responses) - * Null values are also not processed. - */ - if (is_array($value) || $value === null) { - continue; - } - - $dataCopy = $modelData; - $dataCopy[$key] = new stdClass; - - yield [$dataCopy, $model, $key]; - } - } - } -} diff --git a/test/Integration/Factory/RequestFactoryTest.php b/test/Integration/Factory/RequestFactoryTest.php deleted file mode 100644 index 03809073..00000000 --- a/test/Integration/Factory/RequestFactoryTest.php +++ /dev/null @@ -1,138 +0,0 @@ - */ - private $defaultBodyContent; - - /** @var array */ - private $defaultParameters; - - public function setUp(): void - { - parent::setUp(); - /** @var RequestFactory $requestFactory */ - $requestFactory = $this->getContainer()->get(RequestFactory::class); - $this->requestFactory = $requestFactory; - /** @var string $apiToken */ - $apiToken = $this->getContainer()->getParameter('apiToken'); - $this->apiToken = $apiToken; - /** @var string $apiContentType */ - $apiContentType = $this->getContainer()->getParameter('apiContentType'); - $this->apiContentType = $apiContentType; - /** @var array $defaultBodyContent */ - $defaultBodyContent = $this->getContainer()->getParameter('defaultBodyContent'); - $this->defaultBodyContent = $defaultBodyContent; - /** @var array $defaultParameters */ - $defaultParameters = $this->getContainer()->getParameter('defaultParameters'); - $this->defaultParameters = $defaultParameters; - } - - /** - * @param array $data - * @dataProvider provideRequestTestCases - * @throws Exception - */ - public function testCreateRequest(array $data): void - { - $request = $this->requestFactory->create( - $data['method'], - $data['endpoint'], - $data['headers'], - $data['body'], - $data['parameters'] - ); - - $headersArray = []; - foreach ($data['headers'] as $header => $value) { - $headersArray[$header] = [$value]; - } - - if (! isset($headersArray['Authorization'])) { - $headersArray['Authorization'] = ['Basic ' . base64_encode($this->apiToken . ':X')]; - } - - if (! isset($headersArray['Content-Type'])) { - $headersArray['Content-Type'] = [$this->apiContentType]; - } - - $headersArray['Host'] = [$request->getUri()->getHost() . ':' . $request->getUri()->getPort()]; - - $encodedBody = ! empty($data['body']) || ! empty($this->defaultBodyContent) - ? json_encode(array_merge($data['body'], $this->defaultBodyContent)) - : ''; - - self::assertInstanceOf(Request::class, $request); - self::assertSame($data['method'], $request->getMethod()); - self::assertStringContainsString($data['endpoint'], $request->getUri()->getPath()); - self::assertSame($encodedBody, $request->getBody()->getContents()); - self::assertEquals($headersArray, $request->getHeaders()); - self::assertSame( - http_build_query(array_merge($data['parameters'], $this->defaultParameters)), - $request->getUri()->getQuery() - ); - } - - /** - * @return iterable - * @throws ReflectionException - */ - public function provideRequestTestCases(): iterable - { - yield [ - [ - 'method' => 'POST', - 'endpoint' => 'api/comment', - 'headers' => [], - 'body' => ['test' => 'test'], - 'parameters' => [] - ] - ]; - - yield [ - [ - 'method' => 'GET', - 'endpoint' => 'api/core', - 'headers' => ['test' => 'header'], - 'body' => [], - 'parameters' => ['test' => 'test'] - ] - ]; - - yield [ - [ - 'method' => 'DELETE', - 'endpoint' => 'test/api/core', - 'headers' => ['Authorization' => 'header'], - 'body' => [], - 'parameters' => ['test' => 'test'] - ] - ]; - } -} diff --git a/test/Integration/Factory/SelfService/ArticleFactoryTest.php b/test/Integration/Factory/SelfService/ArticleFactoryTest.php deleted file mode 100644 index 0e5fbe94..00000000 --- a/test/Integration/Factory/SelfService/ArticleFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Article::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(ArticleFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/SelfService/CategoryFactoryTest.php b/test/Integration/Factory/SelfService/CategoryFactoryTest.php deleted file mode 100644 index 1b9adacf..00000000 --- a/test/Integration/Factory/SelfService/CategoryFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Category::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(CategoryFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/SelfService/CommentFactoryTest.php b/test/Integration/Factory/SelfService/CommentFactoryTest.php deleted file mode 100644 index 0283185d..00000000 --- a/test/Integration/Factory/SelfService/CommentFactoryTest.php +++ /dev/null @@ -1,43 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Comment::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(CommentFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/SelfService/TagFactoryTest.php b/test/Integration/Factory/SelfService/TagFactoryTest.php deleted file mode 100644 index 0c18d11e..00000000 --- a/test/Integration/Factory/SelfService/TagFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Tag::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(TagFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/SelfService/TypeFactoryTest.php b/test/Integration/Factory/SelfService/TypeFactoryTest.php deleted file mode 100644 index fd5b01ad..00000000 --- a/test/Integration/Factory/SelfService/TypeFactoryTest.php +++ /dev/null @@ -1,43 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Type::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(TypeFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Ticket/AttachmentFactoryTest.php b/test/Integration/Factory/Ticket/AttachmentFactoryTest.php deleted file mode 100644 index ff85d7d2..00000000 --- a/test/Integration/Factory/Ticket/AttachmentFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Attachment::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(AttachmentFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Ticket/ChannelSettingsFactoryTest.php b/test/Integration/Factory/Ticket/ChannelSettingsFactoryTest.php deleted file mode 100644 index 50f93e62..00000000 --- a/test/Integration/Factory/Ticket/ChannelSettingsFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return ChannelSettings::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(ChannelSettingsFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Ticket/CustomFieldFactoryTest.php b/test/Integration/Factory/Ticket/CustomFieldFactoryTest.php deleted file mode 100644 index bc2b737f..00000000 --- a/test/Integration/Factory/Ticket/CustomFieldFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return TicketCustomField::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(CustomFieldFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Ticket/DepartmentFactoryTest.php b/test/Integration/Factory/Ticket/DepartmentFactoryTest.php deleted file mode 100644 index 07a24aca..00000000 --- a/test/Integration/Factory/Ticket/DepartmentFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Department::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(DepartmentFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Ticket/MessageFactoryTest.php b/test/Integration/Factory/Ticket/MessageFactoryTest.php deleted file mode 100644 index 3b854278..00000000 --- a/test/Integration/Factory/Ticket/MessageFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Message::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(MessageFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Ticket/PriorityFactoryTest.php b/test/Integration/Factory/Ticket/PriorityFactoryTest.php deleted file mode 100644 index 9dd366e8..00000000 --- a/test/Integration/Factory/Ticket/PriorityFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Priority::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(PriorityFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Ticket/StatusFactoryTest.php b/test/Integration/Factory/Ticket/StatusFactoryTest.php deleted file mode 100644 index fbba58d1..00000000 --- a/test/Integration/Factory/Ticket/StatusFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Status::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(StatusFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/Ticket/TicketFactoryTest.php b/test/Integration/Factory/Ticket/TicketFactoryTest.php deleted file mode 100644 index fd36167d..00000000 --- a/test/Integration/Factory/Ticket/TicketFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Ticket::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(TicketFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/User/GroupFactoryTest.php b/test/Integration/Factory/User/GroupFactoryTest.php deleted file mode 100644 index 58270e74..00000000 --- a/test/Integration/Factory/User/GroupFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Group::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(GroupFactory::class); - - return $modelFactory; - } -} diff --git a/test/Integration/Factory/User/UserCustomFieldFactoryTest.php b/test/Integration/Factory/User/UserCustomFieldFactoryTest.php deleted file mode 100644 index ef2545a4..00000000 --- a/test/Integration/Factory/User/UserCustomFieldFactoryTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return UserCustomField::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - /** @var ModelFactory $modelFactory */ - $modelFactory = $this->getContainer()->get(UserCustomFieldFactory::class); - - return $modelFactory; - } -} diff --git a/test/Resources/services_test.yml b/test/Resources/services_test.yml index c0bde52e..7faa39f0 100644 --- a/test/Resources/services_test.yml +++ b/test/Resources/services_test.yml @@ -16,7 +16,7 @@ services: autowire: true public: true - SupportPal\ApiClient\Factory\RequestFactory: + SupportPal\ApiClient\Http\Request: public: true arguments: $apiUrl: '%apiUrl%' @@ -25,105 +25,7 @@ services: $defaultBodyContent: '%defaultBodyContent%' $defaultParameters: '%defaultParameters%' - SupportPal\ApiClient\ApiClient: + SupportPal\ApiClient\Http\Client: public: true arguments: $httpClient: '@GuzzleHttp\Client' - - SupportPal\ApiClient\Factory\SelfService\TypeFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\User\UserFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\SelfService\ArticleFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\SelfService\CategoryFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\Ticket\DepartmentFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\SelfService\CommentFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\Shared\SettingsFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\Ticket\ChannelSettingsFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\SelfService\TagFactory: - public: true - tags: [ 'factory.model_factory' ] - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - - SupportPal\ApiClient\Factory\Ticket\CustomFieldFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\Ticket\PriorityFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\Ticket\StatusFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\Ticket\AttachmentFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\Ticket\TicketFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\Ticket\MessageFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\Core\BrandFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\User\GroupFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\User\UserCustomFieldFactory: - public: true - parent: 'SupportPal\ApiClient\Factory\ModelFactory' - tags: [ 'factory.model_factory' ] - - SupportPal\ApiClient\Factory\Collection\CollectionFactory: - public: true - - SupportPal\ApiClient\Factory\ModelCollectionFactory: - public: true - arguments: - $factories: !tagged factory.model_factory diff --git a/test/Unit/Api/Core/BrandApisTest.php b/test/Unit/Api/Core/BrandApisTest.php index e4445fa2..e16ccb50 100644 --- a/test/Unit/Api/Core/BrandApisTest.php +++ b/test/Unit/Api/Core/BrandApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Core; use SupportPal\ApiClient\Api\CoreApi; -use SupportPal\ApiClient\ApiClient\CoreApiClient; +use SupportPal\ApiClient\Http\CoreClient; use SupportPal\ApiClient\Model\Core\Brand; use SupportPal\ApiClient\Tests\DataFixtures\Core\BrandData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class BrandApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Core - * @covers \SupportPal\ApiClient\Api\Core\BrandApis + * @covers \SupportPal\ApiClient\Api\Core\Brands * @covers \SupportPal\ApiClient\Api\Api */ class BrandApisTest extends ApiTest @@ -33,7 +33,7 @@ public function testGetBrand(): void ->willReturn($response->reveal()); $returnedBrand = $this->api->getBrand(1); - self::assertSame($expectedOutput, $returnedBrand); + self::assertEquals($expectedOutput, $returnedBrand); } public function testGetBrands(): void @@ -50,7 +50,7 @@ public function testGetBrands(): void ->willReturn($response->reveal()); $returnedBrands = $this->api->getBrands([]); - self::assertSame($expectedOutput, $returnedBrands); + self::assertEquals($expectedOutput, $returnedBrands); } /** @@ -66,6 +66,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return CoreApiClient::class; + return CoreClient::class; } } diff --git a/test/Unit/Api/Core/SettingsApisTest.php b/test/Unit/Api/Core/SettingsApisTest.php index e836a8a3..6cc60c95 100644 --- a/test/Unit/Api/Core/SettingsApisTest.php +++ b/test/Unit/Api/Core/SettingsApisTest.php @@ -3,17 +3,11 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Core; use SupportPal\ApiClient\Api\CoreApi; -use SupportPal\ApiClient\ApiClient\CoreApiClient; +use SupportPal\ApiClient\Http\CoreClient; use SupportPal\ApiClient\Model\Shared\Settings; use SupportPal\ApiClient\Tests\DataFixtures\Core\CoreSettingsData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class CoreApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api - * @covers \SupportPal\ApiClient\Api\Core\SettingsApis - * @covers \SupportPal\ApiClient\Api\Api - */ class SettingsApisTest extends ApiTest { /** @var CoreApi */ @@ -33,7 +27,7 @@ public function testGetCoreSettings(): void ->willReturn($response->reveal()); $coreSettings = $this->api->getSettings(); - self::assertSame($expectedOutput, $coreSettings); + self::assertEquals($expectedOutput, $coreSettings); } /** @@ -49,6 +43,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return CoreApiClient::class; + return CoreClient::class; } } diff --git a/test/Unit/Api/SelfService/ArticleApisTest.php b/test/Unit/Api/SelfService/ArticleApisTest.php index d647ce6c..d280c78d 100644 --- a/test/Unit/Api/SelfService/ArticleApisTest.php +++ b/test/Unit/Api/SelfService/ArticleApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\SelfService; use SupportPal\ApiClient\Api\SelfServiceApi; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\SelfService\Article; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\ArticleData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class ArticleApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\ArticleApis + * @covers \SupportPal\ApiClient\Api\SelfService\Articles * @covers \SupportPal\ApiClient\Api\Api */ class ArticleApisTest extends ApiTest @@ -36,7 +36,7 @@ public function testGetArticlesByTerm(): void ->willReturn($response->reveal()); $articles = $this->api->getArticlesByTerm('test', []); - self::assertSame($expectedOutput, $articles); + self::assertEquals($expectedOutput, $articles); } public function testGetArticle(): void @@ -53,7 +53,7 @@ public function testGetArticle(): void ->willReturn($response->reveal()); $returnedArticle = $this->api->getArticle($this->testArticleId, []); - self::assertSame($expectedOutput, $returnedArticle); + self::assertEquals($expectedOutput, $returnedArticle); } public function testGetArticles(): void @@ -69,7 +69,7 @@ public function testGetArticles(): void ->shouldBeCalled() ->willReturn($response->reveal()); $articles = $this->api->getArticles([]); - self::assertSame($expectedOutput, $articles); + self::assertEquals($expectedOutput, $articles); } public function testGetRelatedArticles(): void @@ -89,7 +89,7 @@ public function testGetRelatedArticles(): void ->willReturn($response->reveal()); $articles = $this->api->getRelatedArticles(1, 'test', []); - self::assertSame($expectedOutput, $articles); + self::assertEquals($expectedOutput, $articles); } /** @@ -105,6 +105,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/Api/SelfService/CategoryApisTest.php b/test/Unit/Api/SelfService/CategoryApisTest.php index 7c19fe31..dd59e64e 100644 --- a/test/Unit/Api/SelfService/CategoryApisTest.php +++ b/test/Unit/Api/SelfService/CategoryApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\SelfService; use SupportPal\ApiClient\Api\SelfServiceApi; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\SelfService\Category; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CategoryData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class CategoryApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\CategoryApis + * @covers \SupportPal\ApiClient\Api\SelfService\Categories * @covers \SupportPal\ApiClient\Api\Api */ class CategoryApisTest extends ApiTest @@ -33,7 +33,7 @@ public function testGetCategory(): void ->willReturn($response->reveal()); $returnedCategory = $this->api->getCategory(1); - self::assertSame($expectedOutput, $returnedCategory); + self::assertEquals($expectedOutput, $returnedCategory); } public function testGetCategories(): void @@ -50,7 +50,7 @@ public function testGetCategories(): void ->willReturn($response->reveal()); $returnedCategories = $this->api->getCategories([]); - self::assertSame($expectedOutput, $returnedCategories); + self::assertEquals($expectedOutput, $returnedCategories); } /** @@ -66,6 +66,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/Api/SelfService/CommentApisTest.php b/test/Unit/Api/SelfService/CommentApisTest.php index 3f76dff8..de7504f8 100644 --- a/test/Unit/Api/SelfService/CommentApisTest.php +++ b/test/Unit/Api/SelfService/CommentApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\SelfService; use SupportPal\ApiClient\Api\SelfServiceApi; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\SelfService\Comment; use SupportPal\ApiClient\Model\SelfService\Request\CreateComment; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; @@ -12,7 +12,7 @@ /** * Class CommentApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\CommentApis + * @covers \SupportPal\ApiClient\Api\SelfService\Comments * @covers \SupportPal\ApiClient\Api\Api */ class CommentApisTest extends ApiTest @@ -38,7 +38,7 @@ public function testPostComment(): void ->willReturn($response->reveal()); $comment = $this->api->postComment(new CreateComment($arrayData)); - self::assertSame($commentOutput->reveal(), $comment); + self::assertEquals($commentOutput, $comment); } public function testGetComments(): void @@ -54,7 +54,7 @@ public function testGetComments(): void ->shouldBeCalled() ->willReturn($response->reveal()); $comments = $this->api->getComments([]); - self::assertSame($expectedOutput, $comments); + self::assertEquals($expectedOutput, $comments); } public function testGetComment(): void @@ -71,7 +71,7 @@ public function testGetComment(): void ->willReturn($response->reveal()); $returnedComment = $this->api->getComment($this->testCommentId); - self::assertSame($expectedOutput, $returnedComment); + self::assertEquals($expectedOutput, $returnedComment); } /** @@ -87,6 +87,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/Api/SelfService/SettingsApisTest.php b/test/Unit/Api/SelfService/SettingsApisTest.php index a90a3f61..7601f38a 100644 --- a/test/Unit/Api/SelfService/SettingsApisTest.php +++ b/test/Unit/Api/SelfService/SettingsApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\SelfService; use SupportPal\ApiClient\Api\SelfServiceApi; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\Shared\Settings; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\SettingsData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class SettingsApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\SettingsApis + * @covers \SupportPal\ApiClient\Api\SelfService\Settings * @covers \SupportPal\ApiClient\Api\Api */ class SettingsApisTest extends ApiTest @@ -33,7 +33,7 @@ public function testGetSettings(): void ->willReturn($response->reveal()); $articles = $this->api->getSettings(); - self::assertSame($expectedOutput, $articles); + self::assertEquals($expectedOutput, $articles); } /** @@ -49,6 +49,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/Api/SelfService/TagApisTest.php b/test/Unit/Api/SelfService/TagApisTest.php index 45abfee0..325ce648 100644 --- a/test/Unit/Api/SelfService/TagApisTest.php +++ b/test/Unit/Api/SelfService/TagApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\SelfService; use SupportPal\ApiClient\Api\SelfServiceApi; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\SelfService\Tag; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TagData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class TagApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\TagApis + * @covers \SupportPal\ApiClient\Api\SelfService\Tags * @covers \SupportPal\ApiClient\Api\Api */ class TagApisTest extends ApiTest @@ -33,7 +33,7 @@ public function testGetTag(): void ->willReturn($response->reveal()); $tag = $this->api->getTag(1); - self::assertSame($expectedOutput, $tag); + self::assertEquals($expectedOutput, $tag); } public function testGetTags(): void @@ -49,7 +49,7 @@ public function testGetTags(): void ->shouldBeCalled() ->willReturn($response->reveal()); $tags = $this->api->getTags([]); - self::assertSame($expectedOutput, $tags); + self::assertEquals($expectedOutput, $tags); } /** @@ -65,6 +65,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/Api/SelfService/TypeApiTest.php b/test/Unit/Api/SelfService/TypeApiTest.php index db3a3800..31a3efad 100644 --- a/test/Unit/Api/SelfService/TypeApiTest.php +++ b/test/Unit/Api/SelfService/TypeApiTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\SelfService; use SupportPal\ApiClient\Api\SelfServiceApi; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Model\SelfService\Type; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TypeData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class TypeApiTest * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\TypeApis + * @covers \SupportPal\ApiClient\Api\SelfService\Types * @covers \SupportPal\ApiClient\Api\Api */ class TypeApiTest extends ApiTest @@ -32,7 +32,7 @@ public function testGetArticleTypes(): void ->shouldBeCalled() ->willReturn($response->reveal()); $articleTypes = $this->api->getTypes(); - self::assertSame($expectedOutput, $articleTypes); + self::assertEquals($expectedOutput, $articleTypes); } public function testGetType(): void @@ -48,7 +48,7 @@ public function testGetType(): void ->shouldBeCalled() ->willReturn($response->reveal()); $types = $this->api->getType(1); - self::assertSame($expectedOutput, $types); + self::assertEquals($expectedOutput, $types); } /** @@ -64,6 +64,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/Api/Ticket/AttachmentApisTest.php b/test/Unit/Api/Ticket/AttachmentApisTest.php index ab98f23b..98426765 100644 --- a/test/Unit/Api/Ticket/AttachmentApisTest.php +++ b/test/Unit/Api/Ticket/AttachmentApisTest.php @@ -5,7 +5,7 @@ use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Ticket\Attachment; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\AttachmentData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -13,7 +13,7 @@ /** * Class AttachmentApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\AttachmentApis + * @covers \SupportPal\ApiClient\Api\Ticket\Attachments * @covers \SupportPal\ApiClient\Api\Api */ class AttachmentApisTest extends ApiTest @@ -35,7 +35,7 @@ public function testGetAttachments(): void ->willReturn($response->reveal()); $ticketAttachments = $this->api->getAttachments(); - self::assertSame($expectedOutput, $ticketAttachments); + self::assertEquals($expectedOutput, $ticketAttachments); } public function testGetAttachment(): void @@ -52,7 +52,7 @@ public function testGetAttachment(): void ->willReturn($response->reveal()); $ticketAttachment = $this->api->getAttachment(1); - self::assertSame($expectedOutput, $ticketAttachment); + self::assertEquals($expectedOutput, $ticketAttachment); } public function testDownloadAttachment(): void @@ -78,6 +78,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/Ticket/ChannelApisTest.php b/test/Unit/Api/Ticket/ChannelApisTest.php index 803e2559..5f950d7a 100644 --- a/test/Unit/Api/Ticket/ChannelApisTest.php +++ b/test/Unit/Api/Ticket/ChannelApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Ticket; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Ticket\ChannelSettings; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\ChannelSettingsData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class ChannelApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\ChannelSettingsApis + * @covers \SupportPal\ApiClient\Api\Ticket\ChannelSettings * @covers \SupportPal\ApiClient\Api\Api */ class ChannelApisTest extends ApiTest @@ -33,7 +33,7 @@ public function testGetChannelSettings(): void ->willReturn($response->reveal()); $channelSettings = $this->api->getChannelSettings('web'); - self::assertSame($expectedOutput, $channelSettings); + self::assertEquals($expectedOutput, $channelSettings); } /** @@ -49,6 +49,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/Ticket/CustomFieldApisTest.php b/test/Unit/Api/Ticket/CustomFieldApisTest.php index 70082152..49d6ae70 100644 --- a/test/Unit/Api/Ticket/CustomFieldApisTest.php +++ b/test/Unit/Api/Ticket/CustomFieldApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Ticket; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Ticket\TicketCustomField; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\TicketCustomFieldData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class CustomFieldApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\CustomFieldApis + * @covers \SupportPal\ApiClient\Api\Ticket\CustomFields * @covers \SupportPal\ApiClient\Api\Api */ class CustomFieldApisTest extends ApiTest @@ -36,7 +36,7 @@ public function testGetCustomFields(): void ->willReturn($response->reveal()); $customFields = $this->api->getCustomFields([]); - self::assertSame($expectedOutput, $customFields); + self::assertEquals($expectedOutput, $customFields); } public function testGetTicketCustomField(): void @@ -53,7 +53,7 @@ public function testGetTicketCustomField(): void ->willReturn($response->reveal()); $ticketCustomFields = $this->api->getCustomField($this->testId); - self::assertSame($expectedOutput, $ticketCustomFields); + self::assertEquals($expectedOutput, $ticketCustomFields); } /** @@ -69,6 +69,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/Ticket/DepartmentApisTest.php b/test/Unit/Api/Ticket/DepartmentApisTest.php index 9d378f93..4c8bc786 100644 --- a/test/Unit/Api/Ticket/DepartmentApisTest.php +++ b/test/Unit/Api/Ticket/DepartmentApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Ticket; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Department\Department; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\DepartmentData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class DepartmentApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\DepartmentApis + * @covers \SupportPal\ApiClient\Api\Ticket\Departments * @covers \SupportPal\ApiClient\Api\Api */ class DepartmentApisTest extends ApiTest @@ -36,7 +36,7 @@ public function testGetDepartments(): void ->willReturn($response->reveal()); $departments = $this->api->getDepartments([]); - self::assertSame($expectedOutput, $departments); + self::assertEquals($expectedOutput, $departments); } public function testGetDepartment(): void @@ -53,7 +53,7 @@ public function testGetDepartment(): void ->willReturn($response->reveal()); $returnedDepartment = $this->api->getDepartment($this->testDepartmentId); - self::assertSame($expectedOutput, $returnedDepartment); + self::assertEquals($expectedOutput, $returnedDepartment); } /** @@ -69,6 +69,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/Ticket/MessageApisTest.php b/test/Unit/Api/Ticket/MessageApisTest.php index b8c34cd4..44f97fad 100644 --- a/test/Unit/Api/Ticket/MessageApisTest.php +++ b/test/Unit/Api/Ticket/MessageApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Ticket; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Ticket\Message; use SupportPal\ApiClient\Model\Ticket\Request\CreateMessage; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\MessageData; @@ -12,7 +12,7 @@ /** * Class MessageApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\MessageApis + * @covers \SupportPal\ApiClient\Api\Ticket\Messages * @covers \SupportPal\ApiClient\Api\Api */ class MessageApisTest extends ApiTest @@ -37,7 +37,7 @@ public function testGetMessages(): void ->willReturn($response->reveal()); $departments = $this->api->getMessages($this->testMessageId); - self::assertSame($expectedOutput, $departments); + self::assertEquals($expectedOutput, $departments); } public function testGetMessage(): void @@ -54,7 +54,7 @@ public function testGetMessage(): void ->willReturn($response->reveal()); $returnedDepartment = $this->api->getMessage($this->testMessageId); - self::assertSame($expectedOutput, $returnedDepartment); + self::assertEquals($expectedOutput, $returnedDepartment); } public function testPostMessage(): void @@ -74,7 +74,7 @@ public function testPostMessage(): void ->willReturn($response->reveal()); $message = $this->api->postMessage(new CreateMessage($arrayData)); - self::assertSame($messageOutput->reveal(), $message); + self::assertEquals($messageOutput, $message); } /** @@ -90,6 +90,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/Ticket/PriorityApisTest.php b/test/Unit/Api/Ticket/PriorityApisTest.php index 002b7c7a..7532c9a2 100644 --- a/test/Unit/Api/Ticket/PriorityApisTest.php +++ b/test/Unit/Api/Ticket/PriorityApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Ticket; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Ticket\Priority; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\PriorityData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class PriorityApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\PriorityApis + * @covers \SupportPal\ApiClient\Api\Ticket\Priorities * @covers \SupportPal\ApiClient\Api\Api */ class PriorityApisTest extends ApiTest @@ -33,7 +33,7 @@ public function testGetPriorities(): void ->willReturn($response->reveal()); $ticketsPriority = $this->api->getPriorities(); - self::assertSame($expectedOutput, $ticketsPriority); + self::assertEquals($expectedOutput, $ticketsPriority); } public function testGetsPriority(): void @@ -50,7 +50,7 @@ public function testGetsPriority(): void ->willReturn($response->reveal()); $ticketsPriority = $this->api->getPriority(1); - self::assertSame($expectedOutput, $ticketsPriority); + self::assertEquals($expectedOutput, $ticketsPriority); } /** @@ -66,6 +66,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/Ticket/StatusApisTest.php b/test/Unit/Api/Ticket/StatusApisTest.php index e36cb366..4f59169d 100644 --- a/test/Unit/Api/Ticket/StatusApisTest.php +++ b/test/Unit/Api/Ticket/StatusApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Ticket; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Ticket\Status; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\StatusData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class StatusApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\StatusApis + * @covers \SupportPal\ApiClient\Api\Ticket\Statuses * @covers \SupportPal\ApiClient\Api\Api */ class StatusApisTest extends ApiTest @@ -33,7 +33,7 @@ public function testGetStatuses(): void ->willReturn($response->reveal()); $ticketsStatus = $this->api->getStatuses(); - self::assertSame($expectedOutput, $ticketsStatus); + self::assertEquals($expectedOutput, $ticketsStatus); } public function testGetStatus(): void @@ -50,7 +50,7 @@ public function testGetStatus(): void ->willReturn($response->reveal()); $ticketsStatus = $this->api->getStatus(1); - self::assertSame($expectedOutput, $ticketsStatus); + self::assertEquals($expectedOutput, $ticketsStatus); } /** @@ -66,6 +66,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/Ticket/TicketApisTest.php b/test/Unit/Api/Ticket/TicketApisTest.php index 4edc5d2b..4e75fcca 100644 --- a/test/Unit/Api/Ticket/TicketApisTest.php +++ b/test/Unit/Api/Ticket/TicketApisTest.php @@ -3,8 +3,8 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Ticket; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Exception\MissingIdentifierException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Ticket\Request\CreateTicket; use SupportPal\ApiClient\Model\Ticket\Ticket; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\Request\CreateTicketData; @@ -36,7 +36,7 @@ public function testGetTickets(): void ->willReturn($response->reveal()); $tickets = $this->api->getTickets(); - self::assertSame($expectedOutput, $tickets); + self::assertEquals($expectedOutput, $tickets); } public function testGetTicket(): void @@ -53,7 +53,7 @@ public function testGetTicket(): void ->willReturn($response->reveal()); $tickets = $this->api->getTicket(1); - self::assertSame($expectedOutput, $tickets); + self::assertEquals($expectedOutput, $tickets); } public function testPostTicket(): void @@ -73,16 +73,16 @@ public function testPostTicket(): void ->willReturn($response->reveal()); $ticket = $this->api->postTicket(new CreateTicket($arrayData)); - self::assertSame($ticketOutput->reveal(), $ticket); + self::assertEquals($ticketOutput, $ticket); } public function testPutTicket(): void { $ticketData = new TicketData; - [$response, $output] = $this->putCommonExpectations( + [$response, $output] = $this->postCommonExpectations( + $ticketData->getResponse(), Ticket::class, - $ticketData->getResponse() ); $this @@ -92,7 +92,7 @@ public function testPutTicket(): void ->shouldBeCalled(); $ticket = $this->api->updateTicket(new Ticket(['id' => self::TEST_ID]), $ticketData->getArrayData()); - self::assertSame($output->reveal(), $ticket); + self::assertEquals($output, $ticket); } public function testPutTicketWithoutIdentifier(): void @@ -118,6 +118,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/Ticket/TicketSettingsApisTest.php b/test/Unit/Api/Ticket/TicketSettingsApisTest.php index 33259f87..7bfa3919 100644 --- a/test/Unit/Api/Ticket/TicketSettingsApisTest.php +++ b/test/Unit/Api/Ticket/TicketSettingsApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\Ticket; use SupportPal\ApiClient\Api\TicketApi; -use SupportPal\ApiClient\ApiClient\TicketApiClient; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Model\Shared\Settings; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\SettingsData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class TicketApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\SettingsApis + * @covers \SupportPal\ApiClient\Api\Ticket\Settings * @covers \SupportPal\ApiClient\Api\Api */ class TicketSettingsApisTest extends ApiTest @@ -33,7 +33,7 @@ public function testGetTicketsSettings(): void ->willReturn($response->reveal()); $ticketSettings = $this->api->getSettings(); - self::assertSame($expectedOutput, $ticketSettings); + self::assertEquals($expectedOutput, $ticketSettings); } /** @@ -49,6 +49,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/Api/User/UserApisTest.php b/test/Unit/Api/User/UserApisTest.php index 8741d858..3cf78ac6 100644 --- a/test/Unit/Api/User/UserApisTest.php +++ b/test/Unit/Api/User/UserApisTest.php @@ -3,8 +3,8 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\User; use SupportPal\ApiClient\Api\UserApi; -use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Exception\MissingIdentifierException; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Model\User\Request\CreateUser; use SupportPal\ApiClient\Model\User\User; use SupportPal\ApiClient\Tests\DataFixtures\User\Request\CreateUserData; @@ -35,7 +35,7 @@ public function testGetUsers(): void ->shouldBeCalled() ->willReturn($response->reveal()); $users = $this->api->getUsers([]); - self::assertSame($expectedOutput, $users); + self::assertEquals($expectedOutput, $users); } public function testGetUser(): void @@ -52,7 +52,7 @@ public function testGetUser(): void ->willReturn($response->reveal()); $user = $this->api->getUser(1); - self::assertSame($expectedOutput, $user); + self::assertEquals($expectedOutput, $user); } public function testPostUser(): void @@ -72,16 +72,16 @@ public function testPostUser(): void ->willReturn($response->reveal()); $user = $this->api->postUser(new CreateUser($arrayData)); - self::assertSame($userOutput->reveal(), $user); + self::assertEquals($userOutput, $user); } public function testPutUser(): void { $userData = new UserData; - [$response, $output] = $this->putCommonExpectations( + [$response, $output] = $this->postCommonExpectations( + $userData->getResponse(), User::class, - $userData->getResponse() ); $this @@ -91,7 +91,7 @@ public function testPutUser(): void ->shouldBeCalled(); $user = $this->api->updateUser(new User(['id' => self::TEST_ID]), $userData->getArrayData()); - self::assertSame($output->reveal(), $user); + self::assertEquals($output, $user); } public function testPutUserWithoutIdentifier(): void @@ -117,6 +117,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return UserApiClient::class; + return UserClient::class; } } diff --git a/test/Unit/Api/User/UserCustomFieldApisTest.php b/test/Unit/Api/User/UserCustomFieldApisTest.php index b6a0056f..f455e54b 100644 --- a/test/Unit/Api/User/UserCustomFieldApisTest.php +++ b/test/Unit/Api/User/UserCustomFieldApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\User; use SupportPal\ApiClient\Api\UserApi; -use SupportPal\ApiClient\ApiClient\UserApiClient; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Model\User\UserCustomField; use SupportPal\ApiClient\Tests\DataFixtures\User\UserCustomFieldData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class UserCustomFieldApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\User - * @covers \SupportPal\ApiClient\Api\User\CustomFieldApis + * @covers \SupportPal\ApiClient\Api\User\CustomFields * @covers \SupportPal\ApiClient\Api\Api */ class UserCustomFieldApisTest extends ApiTest @@ -32,7 +32,7 @@ public function testGetUserCustomFields(): void ->shouldBeCalled() ->willReturn($response->reveal()); $customFields = $this->api->getCustomFields([]); - self::assertSame($expectedOutput, $customFields); + self::assertEquals($expectedOutput, $customFields); } public function testGetUserCustomField(): void @@ -49,7 +49,7 @@ public function testGetUserCustomField(): void ->willReturn($response->reveal()); $customField = $this->api->getCustomField(1); - self::assertSame($expectedOutput, $customField); + self::assertEquals($expectedOutput, $customField); } /** @@ -65,6 +65,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return UserApiClient::class; + return UserClient::class; } } diff --git a/test/Unit/Api/User/UserGroupApisTest.php b/test/Unit/Api/User/UserGroupApisTest.php index 602dc41a..3ecc55c3 100644 --- a/test/Unit/Api/User/UserGroupApisTest.php +++ b/test/Unit/Api/User/UserGroupApisTest.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\Unit\Api\User; use SupportPal\ApiClient\Api\UserApi; -use SupportPal\ApiClient\ApiClient\UserApiClient; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Model\User\Group; use SupportPal\ApiClient\Tests\DataFixtures\User\GroupData; use SupportPal\ApiClient\Tests\Unit\ApiTest; @@ -11,7 +11,7 @@ /** * Class UserGroupApisTest * @package SupportPal\ApiClient\Tests\Unit\Api\User - * @covers \SupportPal\ApiClient\Api\User\UserGroupApis + * @covers \SupportPal\ApiClient\Api\User\UserGroups * @covers \SupportPal\ApiClient\Api\Api */ class UserGroupApisTest extends ApiTest @@ -32,7 +32,7 @@ public function testGetUserGroups(): void ->shouldBeCalled() ->willReturn($response->reveal()); $userGroups = $this->api->getGroups([]); - self::assertSame($expectedOutput, $userGroups); + self::assertEquals($expectedOutput, $userGroups); } public function testGetUserCustomField(): void @@ -49,7 +49,7 @@ public function testGetUserCustomField(): void ->willReturn($response->reveal()); $userGroup = $this->api->getGroup(1); - self::assertSame($expectedOutput, $userGroup); + self::assertEquals($expectedOutput, $userGroup); } /** @@ -65,6 +65,6 @@ protected function getApiName(): string */ protected function getApiClientName(): string { - return UserApiClient::class; + return UserClient::class; } } diff --git a/test/Unit/ApiClient/Core/BrandApisTest.php b/test/Unit/ApiClient/Core/BrandApisTest.php index e5435976..f860150b 100644 --- a/test/Unit/ApiClient/Core/BrandApisTest.php +++ b/test/Unit/ApiClient/Core/BrandApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Core; -use SupportPal\ApiClient\ApiClient\CoreApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\CoreClient; use SupportPal\ApiClient\Tests\DataFixtures\Core\BrandData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -12,7 +12,7 @@ class BrandApisTest extends ApiClientTest { - /** @var CoreApiClient */ + /** @var CoreClient */ protected $apiClient; /** @var int */ @@ -109,6 +109,6 @@ public function testUnsuccessfulGetBrand(int $statusCode, string $responseBody): */ protected function getApiClientName(): string { - return CoreApiClient::class; + return CoreClient::class; } } diff --git a/test/Unit/ApiClient/Core/CoreApisTest.php b/test/Unit/ApiClient/Core/CoreApisTest.php index de6242b5..3f9d371b 100644 --- a/test/Unit/ApiClient/Core/CoreApisTest.php +++ b/test/Unit/ApiClient/Core/CoreApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Core; -use SupportPal\ApiClient\ApiClient\CoreApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\CoreClient; use SupportPal\ApiClient\Tests\DataFixtures\Core\CoreSettingsData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class CoreApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient - * @covers \SupportPal\ApiClient\ApiClient\Core\SettingsApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\Core\SettingsApis + * @covers \SupportPal\ApiClient\Http\Client */ class CoreApisTest extends ApiClientTest { - /** @var CoreApiClient */ + /** @var CoreClient */ protected $apiClient; public function testSuccessfulGetCoreSettings(): void @@ -60,6 +60,6 @@ public function testHttpExceptionGetCoreSettings(): void */ protected function getApiClientName(): string { - return CoreApiClient::class; + return CoreClient::class; } } diff --git a/test/Unit/ApiClient/SelfService/ArticleApisTest.php b/test/Unit/ApiClient/SelfService/ArticleApisTest.php index d7128af2..dc430ebf 100644 --- a/test/Unit/ApiClient/SelfService/ArticleApisTest.php +++ b/test/Unit/ApiClient/SelfService/ArticleApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\ArticleData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class ArticleApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\ApiClient\SelfService\ArticleApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\SelfService\ArticleApis + * @covers \SupportPal\ApiClient\Http\Client */ class ArticleApisTest extends ApiClientTest { - /** @var SelfServiceApiClient */ + /** @var SelfServiceClient */ protected $apiClient; /** @var int */ @@ -202,6 +202,6 @@ public function testUnsuccessfulGetRelatedArticles(int $statusCode, string $resp */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/ApiClient/SelfService/CategoryApisTest.php b/test/Unit/ApiClient/SelfService/CategoryApisTest.php index 6a8d8ce1..c095d265 100644 --- a/test/Unit/ApiClient/SelfService/CategoryApisTest.php +++ b/test/Unit/ApiClient/SelfService/CategoryApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CategoryData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class CategoryApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\ApiClient\SelfService\CategoryApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\SelfService\CategoryApis + * @covers \SupportPal\ApiClient\Http\Client */ class CategoryApisTest extends ApiClientTest { - /** @var SelfServiceApiClient */ + /** @var SelfServiceClient */ protected $apiClient; /** @var int */ @@ -115,6 +115,6 @@ public function testUnsuccessfulGetCategory(int $statusCode, string $responseBod */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/ApiClient/SelfService/CommentApisTest.php b/test/Unit/ApiClient/SelfService/CommentApisTest.php index a5a64c83..5763729c 100644 --- a/test/Unit/ApiClient/SelfService/CommentApisTest.php +++ b/test/Unit/ApiClient/SelfService/CommentApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class CommentApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\ApiClient\SelfService\CommentApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\SelfService\CommentApis + * @covers \SupportPal\ApiClient\Http\Client */ class CommentApisTest extends ApiClientTest { - /** @var SelfServiceApiClient */ + /** @var SelfServiceClient */ protected $apiClient; /** @var int */ @@ -149,6 +149,6 @@ public function testUnsuccessfulGetComment(int $statusCode, string $responseBody */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/ApiClient/SelfService/SettingsApisTest.php b/test/Unit/ApiClient/SelfService/SettingsApisTest.php index b2edcb44..92f9f29a 100644 --- a/test/Unit/ApiClient/SelfService/SettingsApisTest.php +++ b/test/Unit/ApiClient/SelfService/SettingsApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\SettingsData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class SettingsApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\ApiClient\SelfService\SettingsApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\SelfService\SettingsApis + * @covers \SupportPal\ApiClient\Http\Client */ class SettingsApisTest extends ApiClientTest { - /** @var SelfServiceApiClient */ + /** @var SelfServiceClient */ protected $apiClient; public function testGetSettings(): void @@ -60,6 +60,6 @@ public function testUnsuccessfulGetSettings(int $statusCode, string $responseBod */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/ApiClient/SelfService/TagApisTest.php b/test/Unit/ApiClient/SelfService/TagApisTest.php index 475c306c..0687bfff 100644 --- a/test/Unit/ApiClient/SelfService/TagApisTest.php +++ b/test/Unit/ApiClient/SelfService/TagApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TagData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class TagApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\ApiClient\SelfService\TagApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\SelfService\TagApis + * @covers \SupportPal\ApiClient\Http\Client */ class TagApisTest extends ApiClientTest { - /** @var SelfServiceApiClient */ + /** @var SelfServiceClient */ protected $apiClient; /** @var int */ @@ -115,6 +115,6 @@ public function testUnsuccessfulGetTags(int $statusCode, string $responseBody): */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/ApiClient/SelfService/TypeApisTest.php b/test/Unit/ApiClient/SelfService/TypeApisTest.php index d7106c5f..cac21012 100644 --- a/test/Unit/ApiClient/SelfService/TypeApisTest.php +++ b/test/Unit/ApiClient/SelfService/TypeApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService; -use SupportPal\ApiClient\ApiClient\SelfServiceApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\SelfServiceClient; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TypeData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class TypeApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\ApiClient\SelfService\TypeApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\SelfService\TypeApis + * @covers \SupportPal\ApiClient\Http\Client */ class TypeApisTest extends ApiClientTest { - /** @var SelfServiceApiClient */ + /** @var SelfServiceClient */ protected $apiClient; /** @var int */ @@ -115,6 +115,6 @@ public function testUnsuccessfulGetType(int $statusCode, string $responseBody): */ protected function getApiClientName(): string { - return SelfServiceApiClient::class; + return SelfServiceClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/AttachmentApisTest.php b/test/Unit/ApiClient/Ticket/AttachmentApisTest.php index 188e5975..d5d2f374 100644 --- a/test/Unit/ApiClient/Ticket/AttachmentApisTest.php +++ b/test/Unit/ApiClient/Ticket/AttachmentApisTest.php @@ -4,9 +4,9 @@ use GuzzleHttp\Psr7\Request; use Psr\Http\Message\ResponseInterface; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\AttachmentData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -16,12 +16,12 @@ /** * Class AttachmentApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\Ticket\AttachmentApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\Ticket\AttachmentApis + * @covers \SupportPal\ApiClient\Http\Client */ class AttachmentApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; /** @var int */ @@ -144,6 +144,6 @@ public function testSuccessfulDownloadAttachmentClientException(): void */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/ChannelSettingsApisTest.php b/test/Unit/ApiClient/Ticket/ChannelSettingsApisTest.php index 026f8cb8..66a7af92 100644 --- a/test/Unit/ApiClient/Ticket/ChannelSettingsApisTest.php +++ b/test/Unit/ApiClient/Ticket/ChannelSettingsApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\ChannelSettingsData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -14,12 +14,12 @@ /** * Class ChannelSettingsApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\Ticket\ChannelSettingsApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\Ticket\ChannelSettingsApis + * @covers \SupportPal\ApiClient\Http\Client */ class ChannelSettingsApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; private const TEST_CHANNEL = 'web'; @@ -82,6 +82,6 @@ public function testHttpExceptionGetChannelSettings(): void */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/CustomFieldApisTest.php b/test/Unit/ApiClient/Ticket/CustomFieldApisTest.php index 92f5ba96..46f476a9 100644 --- a/test/Unit/ApiClient/Ticket/CustomFieldApisTest.php +++ b/test/Unit/ApiClient/Ticket/CustomFieldApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\TicketCustomFieldData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class DepartmentApis * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\Ticket\CustomFieldApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\Ticket\CustomFieldApis + * @covers \SupportPal\ApiClient\Http\Client */ class CustomFieldApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; /** @var int */ @@ -115,6 +115,6 @@ public function testUnsuccessfulGetCustomField(int $statusCode, string $response */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/DepartmentApisTest.php b/test/Unit/ApiClient/Ticket/DepartmentApisTest.php index bc64dc18..d43f2301 100644 --- a/test/Unit/ApiClient/Ticket/DepartmentApisTest.php +++ b/test/Unit/ApiClient/Ticket/DepartmentApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\DepartmentData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class DepartmentApis * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\Ticket\DepartmentApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\Ticket\DepartmentApis + * @covers \SupportPal\ApiClient\Http\Client */ class DepartmentApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; /** @var int */ @@ -115,6 +115,6 @@ public function testUnsuccessfulGetDepartment(int $statusCode, string $responseB */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/MessageApisTest.php b/test/Unit/ApiClient/Ticket/MessageApisTest.php index f131087f..c5a19444 100644 --- a/test/Unit/ApiClient/Ticket/MessageApisTest.php +++ b/test/Unit/ApiClient/Ticket/MessageApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\DepartmentData; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\MessageData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -14,12 +14,12 @@ /** * Class MessageApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\Ticket\MessageApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\Ticket\MessageApis + * @covers \SupportPal\ApiClient\Http\Client */ class MessageApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; /** @var int */ @@ -154,6 +154,6 @@ public function testHttpExceptionTicketMessage(): void */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/PriorityApisTest.php b/test/Unit/ApiClient/Ticket/PriorityApisTest.php index dae5c609..42f6998c 100644 --- a/test/Unit/ApiClient/Ticket/PriorityApisTest.php +++ b/test/Unit/ApiClient/Ticket/PriorityApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\PriorityData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class PriorityApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\Ticket\PriorityApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\Ticket\PriorityApis + * @covers \SupportPal\ApiClient\Http\Client */ class PriorityApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; /** @var int */ @@ -115,6 +115,6 @@ public function testUnsuccessfulGetPriority(int $statusCode, string $responseBod */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/StatusApisTest.php b/test/Unit/ApiClient/Ticket/StatusApisTest.php index fe83757f..28e80f5f 100644 --- a/test/Unit/ApiClient/Ticket/StatusApisTest.php +++ b/test/Unit/ApiClient/Ticket/StatusApisTest.php @@ -2,9 +2,9 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\StatusData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; @@ -13,12 +13,12 @@ /** * Class StatusApisTest * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\Ticket\StatusApis - * @covers \SupportPal\ApiClient\ApiClient + * @covers \SupportPal\ApiClient\Http\Ticket\StatusApis + * @covers \SupportPal\ApiClient\Http\Client */ class StatusApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; /** @var int */ @@ -115,6 +115,6 @@ public function testUnsuccessfulGetStatus(int $statusCode, string $responseBody) */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/TicketApisTest.php b/test/Unit/ApiClient/Ticket/TicketApisTest.php index 7c4470af..bd9d6515 100644 --- a/test/Unit/ApiClient/Ticket/TicketApisTest.php +++ b/test/Unit/ApiClient/Ticket/TicketApisTest.php @@ -2,23 +2,17 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\TicketData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; use function json_encode; -/** - * Class PriorityApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\TicketApiClient - * @covers \SupportPal\ApiClient\ApiClient - */ class TicketApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; /** @var int */ @@ -205,6 +199,6 @@ public function testUnsuccessfulUpdateTicket(int $statusCode, string $responseBo */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/Ticket/TicketSettingsApisTest.php b/test/Unit/ApiClient/Ticket/TicketSettingsApisTest.php index c271ec1f..579c02dd 100644 --- a/test/Unit/ApiClient/Ticket/TicketSettingsApisTest.php +++ b/test/Unit/ApiClient/Ticket/TicketSettingsApisTest.php @@ -2,23 +2,17 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket; -use SupportPal\ApiClient\ApiClient\TicketApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\TicketClient; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\SettingsData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; use function json_encode; -/** - * Class TicketSettingsApis - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\ApiClient\Ticket\SettingsApis - * @covers \SupportPal\ApiClient\ApiClient - */ class TicketSettingsApisTest extends ApiClientTest { - /** @var TicketApiClient */ + /** @var TicketClient */ protected $apiClient; public function testSuccessfulGetTicketSettings(): void @@ -60,6 +54,6 @@ public function testHttpExceptionGetTicketSettings(): void */ protected function getApiClientName(): string { - return TicketApiClient::class; + return TicketClient::class; } } diff --git a/test/Unit/ApiClient/User/CustomFieldApisTest.php b/test/Unit/ApiClient/User/CustomFieldApisTest.php index b319e25d..bcacd008 100644 --- a/test/Unit/ApiClient/User/CustomFieldApisTest.php +++ b/test/Unit/ApiClient/User/CustomFieldApisTest.php @@ -2,23 +2,17 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\User; -use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Tests\DataFixtures\User\UserCustomFieldData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; use function json_encode; -/** - * Class CustomFieldApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\User - * @covers \SupportPal\ApiClient\ApiClient\User\CustomFieldApis - * @covers \SupportPal\ApiClient\ApiClient - */ class CustomFieldApisTest extends ApiClientTest { - /** @var UserApiClient */ + /** @var UserClient */ protected $apiClient; /** @var int */ @@ -115,6 +109,6 @@ public function testUnsuccessfulGetUserCustomField(int $statusCode, string $resp */ protected function getApiClientName(): string { - return UserApiClient::class; + return UserClient::class; } } diff --git a/test/Unit/ApiClient/User/UserApisTest.php b/test/Unit/ApiClient/User/UserApisTest.php index d66f2799..e0990ff7 100644 --- a/test/Unit/ApiClient/User/UserApisTest.php +++ b/test/Unit/ApiClient/User/UserApisTest.php @@ -2,23 +2,17 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\User; -use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Tests\DataFixtures\User\UserData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; use function json_encode; -/** - * Class UserApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient - * @covers \SupportPal\ApiClient\ApiClient\UserApiClient - * @covers \SupportPal\ApiClient\ApiClient - */ class UserApisTest extends ApiClientTest { - /** @var UserApiClient */ + /** @var UserClient */ protected $apiClient; /** @var int */ @@ -203,6 +197,6 @@ public function testUnsuccessfulUpdateUser(int $statusCode, string $responseBody */ protected function getApiClientName(): string { - return UserApiClient::class; + return UserClient::class; } } diff --git a/test/Unit/ApiClient/User/UserGroupApisTest.php b/test/Unit/ApiClient/User/UserGroupApisTest.php index 56b71dd7..f582a922 100644 --- a/test/Unit/ApiClient/User/UserGroupApisTest.php +++ b/test/Unit/ApiClient/User/UserGroupApisTest.php @@ -2,23 +2,17 @@ namespace SupportPal\ApiClient\Tests\Unit\ApiClient\User; -use SupportPal\ApiClient\ApiClient\UserApiClient; use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Exception\HttpResponseException; +use SupportPal\ApiClient\Http\UserClient; use SupportPal\ApiClient\Tests\DataFixtures\User\GroupData; use SupportPal\ApiClient\Tests\Unit\ApiClientTest; use function json_encode; -/** - * Class UserGroupApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\User - * @covers \SupportPal\ApiClient\ApiClient\User\UserGroupApis - * @covers \SupportPal\ApiClient\ApiClient - */ class UserGroupApisTest extends ApiClientTest { - /** @var UserApiClient */ + /** @var UserClient */ protected $apiClient; /** @var int */ @@ -115,6 +109,6 @@ public function testUnsuccessfulGetUserGroup(int $statusCode, string $responseBo */ protected function getApiClientName(): string { - return UserApiClient::class; + return UserClient::class; } } diff --git a/test/Unit/ApiClientTest.php b/test/Unit/ApiClientTest.php index 897f7584..8b7e440d 100644 --- a/test/Unit/ApiClientTest.php +++ b/test/Unit/ApiClientTest.php @@ -3,27 +3,23 @@ namespace SupportPal\ApiClient\Tests\Unit; use Exception; -use GuzzleHttp\Client; +use GuzzleHttp\Client as GuzzleClient; use GuzzleHttp\Exception\ClientException; -use GuzzleHttp\Psr7\Request; +use GuzzleHttp\Psr7\Request as BaseRequest; use PHPUnit\Framework\TestCase; use Prophecy\Prophecy\ObjectProphecy; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; -use SupportPal\ApiClient\ApiClient; use SupportPal\ApiClient\Exception\HttpResponseException; -use SupportPal\ApiClient\Factory\RequestFactory; +use SupportPal\ApiClient\Http\Client; +use SupportPal\ApiClient\Http\CoreClient; +use SupportPal\ApiClient\Http\Request; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; use function json_encode; -/** - * Class ApiClientTest - * @package SupportPal\ApiClient\Tests\Unit - * @covers \SupportPal\ApiClient\ApiClient - */ class ApiClientTest extends TestCase { use PhpUnitCompatibilityTrait; @@ -38,21 +34,21 @@ class ApiClientTest extends TestCase /** @var ObjectProphecy|ClientInterface */ protected $httpClient; - /** @var ObjectProphecy|RequestFactory */ + /** @var ObjectProphecy|Request */ protected $requestFactory; - /** @var ApiClient */ + /** @var Client $apiClient */ protected $apiClient; protected function setUp(): void { parent::setUp(); $this->httpClient = $this->prophesize(ClientInterface::class); - $this->requestFactory = $this->prophesize(RequestFactory::class); + $this->requestFactory = $this->prophesize(Request::class); - /** @var Client $httpClient */ + /** @var GuzzleClient $httpClient */ $httpClient = $this->httpClient->reveal(); - /** @var RequestFactory $requestFactory */ + /** @var Request $requestFactory */ $requestFactory = $this->requestFactory->reveal(); $apiClassName = $this->getApiClientName(); @@ -126,7 +122,7 @@ public function provideUnsuccessfulTestCases(): iterable * @param string $endpoint * @param array $parameters * @param array $body - * @return ObjectProphecy|Request + * @return ObjectProphecy|BaseRequest */ protected function requestCommonExpectations( string $method, @@ -134,7 +130,7 @@ protected function requestCommonExpectations( array $parameters, array $body = [] ): ObjectProphecy { - $request = $this->prophesize(Request::class); + $request = $this->prophesize(BaseRequest::class); if ($method === 'GET') { $create = $this->requestFactory->create($method, $endpoint, [], [], $parameters); $create->shouldBeCalled()->willReturn($request->reveal()); @@ -151,7 +147,7 @@ protected function requestCommonExpectations( /** * @param int $statusCode * @param string $responseBody - * @param ObjectProphecy|Request $request + * @param ObjectProphecy|BaseRequest $request * @return ObjectProphecy|ResponseInterface */ protected function sendRequestCommonExpectations( @@ -168,7 +164,7 @@ protected function sendRequestCommonExpectations( } /** - * @param ObjectProphecy|Request $request + * @param ObjectProphecy|BaseRequest $request */ protected function throwClientExceptionCommonExpectations(ObjectProphecy $request): void { @@ -181,10 +177,10 @@ protected function throwClientExceptionCommonExpectations(ObjectProphecy $reques } /** - * @return class-string + * @return class-string */ protected function getApiClientName(): string { - return ApiClient::class; + return CoreClient::class; } } diff --git a/test/Unit/ApiTest.php b/test/Unit/ApiTest.php index 5fd0522e..a6de77f7 100644 --- a/test/Unit/ApiTest.php +++ b/test/Unit/ApiTest.php @@ -5,149 +5,76 @@ use Prophecy\Prophecy\ObjectProphecy; use Psr\Http\Message\ResponseInterface; use SupportPal\ApiClient\Api\Api; -use SupportPal\ApiClient\ApiClient; -use SupportPal\ApiClient\Factory\Collection\CollectionFactory; -use SupportPal\ApiClient\Factory\ModelCollectionFactory; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Http\Client; +use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Tests\TestCase; -use function array_push; use function current; use function is_array; use function json_encode; -/** - * Class ApiTest - * @package SupportPal\ApiClient\Tests\Unit - * @covers \SupportPal\ApiClient\Api\Api - */ abstract class ApiTest extends TestCase { protected const TEST_ID = 1; - /** @var ObjectProphecy|ApiClient */ + /** @var ObjectProphecy|Client */ protected $apiClient; - /** @var string */ - protected $serializationType; - - /** @var ObjectProphecy|ModelCollectionFactory */ - protected $modelCollectionFactory; - /** @var Api */ protected $api; - /** @var ObjectProphecy|CollectionFactory */ - private $collectionFactory; - protected function setUp(): void { parent::setUp(); $this->apiClient = $this->prophesize($this->getApiClientName()); - $this->modelCollectionFactory = $this->prophesize(ModelCollectionFactory::class); - $this->collectionFactory = $this->prophesize(CollectionFactory::class); - /** @var ApiClient $apiClient */ + /** @var Client $apiClient */ $apiClient = $this->apiClient->reveal(); - /** @var ModelCollectionFactory $modelCollectionFactory */ - $modelCollectionFactory = $this->modelCollectionFactory->reveal(); - /** @var CollectionFactory $collectionFactory */ - $collectionFactory = $this->collectionFactory->reveal(); $apiName = $this->getApiName(); - $this->api = new $apiName( - $modelCollectionFactory, - $collectionFactory, - $apiClient - ); + $this->api = new $apiName($apiClient); } /** * @param array $responseData - * @param class-string $expectedClass + * @param class-string $model * @return array */ - protected function makeCommonExpectations(array $responseData, string $expectedClass): array + protected function makeCommonExpectations(array $responseData, string $model): array { $response = $this->prophesize(ResponseInterface::class); - $response - ->getBody() + $response->getBody() ->willReturn(json_encode($responseData)); if (is_array(current($responseData['data']))) { $models = []; foreach ($responseData['data'] as $value) { - $model = $this->prophesize($expectedClass); - $this->modelCollectionFactory - ->create($expectedClass, $value) - ->shouldBeCalled() - ->willReturn($model->reveal()); - array_push($models, $model->reveal()); + /** @var Model[] $models */ + $models[] = new $model($value); } - $collection = $this->prophesize(Collection::class); - $this->collectionFactory->create( - $responseData['count'], - $models - )->shouldBeCalled() - ->willReturn($collection->reveal()); + $collection = $this->api->createCollection($responseData['count'], $models); - return [$collection->reveal(), $response]; + return [$collection, $response]; } - $expectedOutput = $this->prophesize($expectedClass); - $this->modelCollectionFactory - ->create($expectedClass, $responseData['data']) - ->shouldBeCalled() - ->willReturn($expectedOutput->reveal()); - - return [$expectedOutput->reveal(), $response]; + return [new $model($responseData['data']), $response]; } /** * @param array $responseData - * @param class-string|null $outputClassName + * @param class-string $model * @return array */ protected function postCommonExpectations( array $responseData, - ?string $outputClassName = null - ): array { - $output = $this->prophesize($outputClassName); - - $response = $this->prophesize(ResponseInterface::class); - $response - ->getBody() - ->willReturn(json_encode($responseData)); - - $this->modelCollectionFactory - ->create($outputClassName, $responseData['data']) - ->willReturn($output); - - return [$response, $output]; - } - - /** - * @param class-string $className - * @param array $responseData - * @return array - */ - protected function putCommonExpectations( - string $className, - array $responseData + string $model ): array { - $output = $this->prophesize($className); - - $this->modelCollectionFactory - ->create($className, $responseData['data']) - ->willReturn($output); - $response = $this->prophesize(ResponseInterface::class); - $response - ->getBody() + $response->getBody() ->willReturn(json_encode($responseData)); - return [$response, $output]; + return [$response, new $model($responseData['data'])]; } /** @@ -156,7 +83,7 @@ protected function putCommonExpectations( abstract protected function getApiName(): string; /** - * @return class-string + * @return class-string */ abstract protected function getApiClientName(): string; } diff --git a/test/Unit/Factory/BaseModelFactoryTest.php b/test/Unit/Factory/BaseModelFactoryTest.php deleted file mode 100644 index 4f4fc337..00000000 --- a/test/Unit/Factory/BaseModelFactoryTest.php +++ /dev/null @@ -1,54 +0,0 @@ - - */ - protected function getModelData(): array - { - return (new CommentData)->getArrayData(); - } - - /** - * @return string - */ - protected function getModel(): string - { - return Comment::class; - } - - /** - * @return ModelFactory - */ - protected function getModelFactory(): ModelFactory - { - $mock = $this->getMockForAbstractClass(ModelFactory::class); - - $mock->expects($this->any()) - ->method('getModel') - ->will($this->returnValue(Comment::class)); - - return $mock; - } -} diff --git a/test/Unit/Factory/BaseModelFactoryTestCase.php b/test/Unit/Factory/BaseModelFactoryTestCase.php deleted file mode 100644 index c7ec6d87..00000000 --- a/test/Unit/Factory/BaseModelFactoryTestCase.php +++ /dev/null @@ -1,32 +0,0 @@ -getModelFactory()->create($this->getModelData()); - self::assertInstanceOf($this->getModel(), $model); - } - - /** - * @return Model - */ - abstract protected function getModelInstance(): Model; -} diff --git a/test/Unit/Factory/Collection/CollectionFactoryTest.php b/test/Unit/Factory/Collection/CollectionFactoryTest.php deleted file mode 100644 index 2a6b1bda..00000000 --- a/test/Unit/Factory/Collection/CollectionFactoryTest.php +++ /dev/null @@ -1,20 +0,0 @@ -collectionFactory = new CollectionFactory; - } -} diff --git a/test/Unit/Factory/Core/BrandFactoryTest.php b/test/Unit/Factory/Core/BrandFactoryTest.php deleted file mode 100644 index 91422d7b..00000000 --- a/test/Unit/Factory/Core/BrandFactoryTest.php +++ /dev/null @@ -1,45 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new BrandData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Brand::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new BrandFactory; - } -} diff --git a/test/Unit/Factory/ModelCollectionFactoryTest.php b/test/Unit/Factory/ModelCollectionFactoryTest.php deleted file mode 100644 index 20c2406f..00000000 --- a/test/Unit/Factory/ModelCollectionFactoryTest.php +++ /dev/null @@ -1,105 +0,0 @@ - */ - private $factories; - - protected function setUp(): void - { - parent::setUp(); - $this->commentFactory = $this->prophesize(CommentFactory::class); - $this->commentFactory->getModel()->willReturn(Comment::class); - $this->settingsFactory = $this->prophesize(SettingsFactory::class); - $this->settingsFactory->getModel()->willReturn(Settings::class); - $this->factories = [ - Comment::class => $this->commentFactory, - Settings::class => $this->settingsFactory, - ]; - - $this->modelCollectionFactory = new ModelCollectionFactory( - $this->getFactories() - ); - } - - public function testCreateWithInvalidFactory(): void - { - self::expectException(InvalidArgumentException::class); - $api = $this->prophesize(ApiClient::class); - /** @var iterable $iterable */ - $iterable = [$api->reveal()]; - new ModelCollectionFactory($iterable); - } - - public function testCreateWithUnsupportedModel(): void - { - self::expectException(NotSupportedException::class); - $this->modelCollectionFactory->create(Model::class, [ 'test' => 'test']); - } - - /** - * @dataProvider provideValidModelsData - * @param class-string $factoryModel - */ - public function testCreateWithSupportedModel(string $factoryModel): void - { - $this->factories[$factoryModel] - ->create(['test' => 'test']) - ->shouldBeCalled() - ->willReturn($this->prophesize($factoryModel)->reveal()); - $model = $this->modelCollectionFactory->create($factoryModel, ['test' => 'test']); - self::assertInstanceOf($factoryModel, $model); - } - - /** - * @return iterable> - */ - public function provideValidModelsData(): iterable - { - yield [Comment::class]; - yield [Settings::class]; - } - - /** - * @return iterable - */ - private function getFactories(): iterable - { - foreach ($this->factories as $factoryProphecy) { - $factory = $factoryProphecy->reveal(); - - yield $factory; - } - } -} diff --git a/test/Unit/Factory/RequestFactoryTest.php b/test/Unit/Factory/RequestFactoryTest.php deleted file mode 100644 index ddf1afa3..00000000 --- a/test/Unit/Factory/RequestFactoryTest.php +++ /dev/null @@ -1,232 +0,0 @@ -requestFactory = new RequestFactory('test', 'test', 'test'); - } - - /** - * @param array $data - * @dataProvider provideRequestWithBodyTestCases - */ - public function testCreateRequestWithBody(array $data): void - { - $encodedBody = json_encode($data['body']); - - $request = $this->requestFactory->create( - $data['method'], - $data['endpoint'], - $data['headers'], - $data['body'], - $data['parameters'] - ); - - $headersArray = $this->createExpectedHeadersArray($data['headers']); - - self::assertInstanceOf(Request::class, $request); - 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(http_build_query($data['parameters']), $request->getUri()->getQuery()); - } - - /** - * @param array $data - * @dataProvider provideRequestWithoutBodyTestCases - */ - public function testCreateRequestWithoutBody(array $data): void - { - $request = $this->requestFactory->create( - $data['method'], - $data['endpoint'], - $data['headers'], - $data['body'], - $data['parameters'] - ); - - $headersArray = $this->createExpectedHeadersArray($data['headers']); - - self::assertInstanceOf(Request::class, $request); - self::assertSame($data['method'], $request->getMethod()); - self::assertSame('test' . $data['endpoint'], $request->getUri()->getPath()); - self::assertEquals($headersArray, $request->getHeaders()); - self::assertSame('', $request->getBody()->getContents()); - self::assertSame(http_build_query($data['parameters']), $request->getUri()->getQuery()); - } - - /** - * @dataProvider provideRequestWithBodyTestCases - * @param array $data - */ - public function testDefaultValues(array $data): void - { - $defaultParameters = ['testparams' => 'value', 'test_data2' => 'not_overwriten']; - $defaultBody = ['testbody' => 'value', 'test_data2' => 'not_overwriten']; - - $this->createAndAssert($defaultBody, $data, $defaultParameters); - } - - public function testProvidedDataOverwritesDefaults(): void - { - $defaultParameters = ['testparams' => 'value']; - $defaultBody = ['testbody' => 'value']; - - $data = [ - 'method' => 'DELETE', - 'endpoint' => 'test/api/core', - 'headers' => ['Authorization' => 'header'], - 'body' => ['testbody' => 'overwrite_value'], - 'parameters' => ['testparams' => 'overwrite_value'] - ]; - - $this->createAndAssert($defaultBody, $data, $defaultParameters); - } - - /** - * @return iterable - */ - public function provideRequestWithBodyTestCases(): iterable - { - yield [ - [ - 'method' => 'POST', - 'endpoint' => 'api/comment', - 'headers' => [], - 'body' => ['test' => 'test'], - 'parameters' => [] - ] - ]; - } - - /** - * @return iterable - */ - public function provideRequestWithoutBodyTestCases(): iterable - { - yield [ - [ - 'method' => 'GET', - 'endpoint' => 'api/core', - 'headers' => ['test' => 'header'], - 'body' => [], - 'parameters' => [] - ] - ]; - - yield [ - [ - 'method' => 'DELETE', - 'endpoint' => 'test/api/core', - 'headers' => ['Authorization' => 'header'], - 'body' => [], - 'parameters' => ['test' => 'test'] - ] - ]; - } - - /** - * @param array $headers - * @return array - */ - private function createExpectedHeadersArray(array $headers): array - { - $headersArray = []; - foreach ($headers as $header => $value) { - $headersArray[$header] = [$value]; - } - - if (! isset($headersArray['Authorization'])) { - $headersArray['Authorization'] = ['Basic ' . base64_encode('test' . ':X')]; - } - - if (! isset($headersArray['Content-Type'])) { - $headersArray['Content-Type'] = ['test']; - } - - return $headersArray; - } - - /** - * @param array $expectedBody - * @param array $defaultBody - * @param array $defaultParameters - * @param array $data - * @return array - */ - private function commonCreateRequest( - array $expectedBody, - array $defaultBody, - array $defaultParameters, - array $data - ): array { - $requestFactory = new RequestFactory( - 'test', - 'test', - 'test', - $defaultBody, - $defaultParameters - ); - - $headersArray = $this->createExpectedHeadersArray($data['headers']); - $request = $requestFactory->create( - $data['method'], - $data['endpoint'], - $data['headers'], - $data['body'], - $data['parameters'] - ); - - return [$expectedBody, $headersArray, $request]; - } - - /** - * @param mixed[] $defaultBody - * @param mixed[] $data - * @param mixed[] $defaultParameters - * @return void - */ - private function createAndAssert(array $defaultBody, array $data, array $defaultParameters): void - { - $expectedBody = array_merge($defaultBody, $data['body']); - [$encodedBody, $headersArray, $request] = $this - ->commonCreateRequest($expectedBody, $defaultBody, $defaultParameters, $data); - - self::assertInstanceOf(Request::class, $request); - self::assertSame($data['method'], $request->getMethod()); - self::assertSame('test' . $data['endpoint'], $request->getUri()->getPath()); - self::assertEquals($headersArray, $request->getHeaders()); - self::assertSame($encodedBody, json_decode($request->getBody()->getContents(), true)); - self::assertSame( - http_build_query(array_merge($defaultParameters, $data['parameters'])), - $request->getUri()->getQuery() - ); - } -} diff --git a/test/Unit/Factory/SelfService/ArticleFactoryTest.php b/test/Unit/Factory/SelfService/ArticleFactoryTest.php deleted file mode 100644 index 8ceb5045..00000000 --- a/test/Unit/Factory/SelfService/ArticleFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModelInstance(): Model - { - return (new ArticleData)->getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Article::class; - } -} diff --git a/test/Unit/Factory/SelfService/CategoryFactoryTest.php b/test/Unit/Factory/SelfService/CategoryFactoryTest.php deleted file mode 100644 index 2dbe3238..00000000 --- a/test/Unit/Factory/SelfService/CategoryFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModelInstance(): Model - { - return (new CategoryData)->getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Category::class; - } -} diff --git a/test/Unit/Factory/SelfService/CommentFactoryTest.php b/test/Unit/Factory/SelfService/CommentFactoryTest.php deleted file mode 100644 index 2bf5a710..00000000 --- a/test/Unit/Factory/SelfService/CommentFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModelInstance(): Model - { - return (new CommentData)->getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Comment::class; - } -} diff --git a/test/Unit/Factory/SelfService/TagFactoryTest.php b/test/Unit/Factory/SelfService/TagFactoryTest.php deleted file mode 100644 index a2d7da27..00000000 --- a/test/Unit/Factory/SelfService/TagFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModelInstance(): Model - { - return (new TagData)->getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Tag::class; - } -} diff --git a/test/Unit/Factory/SelfService/TypeFactoryTest.php b/test/Unit/Factory/SelfService/TypeFactoryTest.php deleted file mode 100644 index 0baf57fd..00000000 --- a/test/Unit/Factory/SelfService/TypeFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModelInstance(): Model - { - return (new TypeData)->getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Type::class; - } -} diff --git a/test/Unit/Factory/Shared/SettingsFactoryTest.php b/test/Unit/Factory/Shared/SettingsFactoryTest.php deleted file mode 100644 index 5c24cee5..00000000 --- a/test/Unit/Factory/Shared/SettingsFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new CoreSettingsData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Settings::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new SettingsFactory; - } -} diff --git a/test/Unit/Factory/Ticket/AttachmentFactoryTest.php b/test/Unit/Factory/Ticket/AttachmentFactoryTest.php deleted file mode 100644 index 1397557c..00000000 --- a/test/Unit/Factory/Ticket/AttachmentFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new AttachmentData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Attachment::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new AttachmentFactory; - } -} diff --git a/test/Unit/Factory/Ticket/ChannelSettingsFactoryTest.php b/test/Unit/Factory/Ticket/ChannelSettingsFactoryTest.php deleted file mode 100644 index ad35b91f..00000000 --- a/test/Unit/Factory/Ticket/ChannelSettingsFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new ChannelSettingsData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return ChannelSettings::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new ChannelSettingsFactory; - } -} diff --git a/test/Unit/Factory/Ticket/CustomFieldFactoryTest.php b/test/Unit/Factory/Ticket/CustomFieldFactoryTest.php deleted file mode 100644 index 52b9b0d0..00000000 --- a/test/Unit/Factory/Ticket/CustomFieldFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new TicketCustomFieldData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return TicketCustomField::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new CustomFieldFactory; - } -} diff --git a/test/Unit/Factory/Ticket/DepartmentFactoryTest.php b/test/Unit/Factory/Ticket/DepartmentFactoryTest.php deleted file mode 100644 index 6c68a68d..00000000 --- a/test/Unit/Factory/Ticket/DepartmentFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new DepartmentData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Department::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new DepartmentFactory; - } -} diff --git a/test/Unit/Factory/Ticket/MessageFactoryTest.php b/test/Unit/Factory/Ticket/MessageFactoryTest.php deleted file mode 100644 index f75d9aac..00000000 --- a/test/Unit/Factory/Ticket/MessageFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new MessageData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Message::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new MessageFactory; - } -} diff --git a/test/Unit/Factory/Ticket/PriorityFactoryTest.php b/test/Unit/Factory/Ticket/PriorityFactoryTest.php deleted file mode 100644 index ca6de360..00000000 --- a/test/Unit/Factory/Ticket/PriorityFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new PriorityData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Priority::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new PriorityFactory; - } -} diff --git a/test/Unit/Factory/Ticket/StatusFactoryTest.php b/test/Unit/Factory/Ticket/StatusFactoryTest.php deleted file mode 100644 index 5b01c017..00000000 --- a/test/Unit/Factory/Ticket/StatusFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new StatusData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Status::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new StatusFactory; - } -} diff --git a/test/Unit/Factory/Ticket/TicketFactoryTest.php b/test/Unit/Factory/Ticket/TicketFactoryTest.php deleted file mode 100644 index 2b4b1ae0..00000000 --- a/test/Unit/Factory/Ticket/TicketFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModelData(): array - { - return (new TicketData)->getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Ticket::class; - } - - /** - * @inheritDoc - */ - protected function getModelFactory(): ModelFactory - { - return new TicketFactory; - } -} diff --git a/test/Unit/Factory/User/UserCustomFieldFactoryTest.php b/test/Unit/Factory/User/UserCustomFieldFactoryTest.php deleted file mode 100644 index 3d560dc0..00000000 --- a/test/Unit/Factory/User/UserCustomFieldFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModelInstance(): Model - { - return (new UserCustomFieldData)->getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return UserCustomField::class; - } -} diff --git a/test/Unit/Factory/User/UserFactoryTest.php b/test/Unit/Factory/User/UserFactoryTest.php deleted file mode 100644 index ab711452..00000000 --- a/test/Unit/Factory/User/UserFactoryTest.php +++ /dev/null @@ -1,50 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModelInstance(): Model - { - return (new UserData)->getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return User::class; - } -} diff --git a/test/Unit/Factory/User/UserGroupFactoryTest.php b/test/Unit/Factory/User/UserGroupFactoryTest.php deleted file mode 100644 index 791aada5..00000000 --- a/test/Unit/Factory/User/UserGroupFactoryTest.php +++ /dev/null @@ -1,45 +0,0 @@ -getArrayData(); - } - - /** - * @inheritDoc - */ - protected function getModelInstance(): Model - { - return (new GroupData)->getFilledInstance(); - } - - /** - * @inheritDoc - */ - protected function getModel(): string - { - return Group::class; - } -} From 070a514d18011a35fdbe8bd1c9aab52ff530758b Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Tue, 28 May 2024 18:18:11 +0100 Subject: [PATCH 07/20] fix phpcs --- src/Api/UserApi.php | 4 ++-- test/Unit/ApiTest.php | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/Api/UserApi.php b/src/Api/UserApi.php index 178541a7..d2376cab 100644 --- a/src/Api/UserApi.php +++ b/src/Api/UserApi.php @@ -3,15 +3,15 @@ namespace SupportPal\ApiClient\Api; use SupportPal\ApiClient\Api\User\CustomFields; -use SupportPal\ApiClient\Api\User\Users; use SupportPal\ApiClient\Api\User\UserGroups; +use SupportPal\ApiClient\Api\User\Users; use SupportPal\ApiClient\Http\UserClient; class UserApi extends Api { use CustomFields; - use Users; use UserGroups; + use Users; public function __construct(protected readonly UserClient $apiClient) { diff --git a/test/Unit/ApiTest.php b/test/Unit/ApiTest.php index a6de77f7..9c4615a9 100644 --- a/test/Unit/ApiTest.php +++ b/test/Unit/ApiTest.php @@ -49,8 +49,10 @@ protected function makeCommonExpectations(array $responseData, string $model): a if (is_array(current($responseData['data']))) { $models = []; foreach ($responseData['data'] as $value) { - /** @var Model[] $models */ - $models[] = new $model($value); + /** @var Model $model */ + $model = new $model($value); + + $models[] = $model; } $collection = $this->api->createCollection($responseData['count'], $models); From 761e931123b49e8680eed195f181526f4ecdef40 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 12:04:26 +0100 Subject: [PATCH 08/20] update request classes and remove uninitialised post tests --- .../SelfService/Request/CreateComment.php | 30 +++---- src/Model/Ticket/Request/CreateMessage.php | 39 +++------ src/Model/Ticket/Request/CreateTicket.php | 83 ++++++------------- src/Model/User/Request/CreateUser.php | 57 +++++-------- test/ApiDataProviders.php | 12 --- test/ApiTestCase.php | 21 ----- 6 files changed, 70 insertions(+), 172 deletions(-) diff --git a/src/Model/SelfService/Request/CreateComment.php b/src/Model/SelfService/Request/CreateComment.php index 272ec2cf..af454fc3 100644 --- a/src/Model/SelfService/Request/CreateComment.php +++ b/src/Model/SelfService/Request/CreateComment.php @@ -6,25 +6,15 @@ class CreateComment extends Model { - public const REQUIRED_FIELDS = [ - 'article_id', - 'type_id', - 'text', + /** @var array */ + protected $casts = [ + 'article_id' => 'int', + 'type_id' => 'int', + 'parent_id' => 'int', + 'author_id' => 'int', + 'name' => 'string', + 'text' => 'string', + 'status' => 'int', + 'notify_reply' => 'bool', ]; - - protected int $articleId; - - protected int $typeId; - - protected ?int $parentId; - - protected ?int $authorId; - - protected ?string $name; - - protected string $text; - - protected ?int $status; - - protected ?bool $notifyReply; } diff --git a/src/Model/Ticket/Request/CreateMessage.php b/src/Model/Ticket/Request/CreateMessage.php index 2be87b0c..ef01d591 100644 --- a/src/Model/Ticket/Request/CreateMessage.php +++ b/src/Model/Ticket/Request/CreateMessage.php @@ -6,31 +6,18 @@ class CreateMessage extends Model { - public const REQUIRED_FIELDS = [ - 'ticket_id', - 'user_id', - 'text', + /** @var array */ + protected $casts = [ + 'ticket_id' => 'int', + 'user_id' => 'int', + 'user_ip_address' => 'string', + 'message_type' => 'int', + 'text' => 'string', + 'attachment' => 'array', + 'cc' => 'array', + 'is_draft' => 'bool', + 'send_user_email' => 'bool', + 'send_operators_email' => 'bool', + 'created_at' => 'int', ]; - - protected int $ticketId; - - protected int $userId; - - protected string|null $userIpAddress; - - protected int|null $messageType; - - protected string $text; - - /** @var string[]|null */ - protected array|null $cc; - - protected bool|null $isDraft; - - protected bool|null $sendUserEmail; - - protected bool|null $sendOperatorsEmail; - - /** @var string[]|null */ - protected array|null $attachment; } diff --git a/src/Model/Ticket/Request/CreateTicket.php b/src/Model/Ticket/Request/CreateTicket.php index f1915a36..b7a610e4 100644 --- a/src/Model/Ticket/Request/CreateTicket.php +++ b/src/Model/Ticket/Request/CreateTicket.php @@ -6,63 +6,30 @@ class CreateTicket extends Model { - public const REQUIRED_FIELDS = [ - 'department', - 'status', - 'priority', - 'subject', - 'text', + /** @var array */ + protected $casts = [ + 'user' => 'int', + 'on_behalf_of' => 'int', + 'user_firstname' => 'string', + 'user_lastname' => 'string', + 'user_email' => 'string', + 'user_organisation' => 'string', + 'user_ip_address' => 'string', + 'department' => 'int', + 'brand' => 'int', + 'status' => 'int', + 'priority' => 'int', + 'internal' => 'bool', + 'subject' => 'string', + 'text' => 'string', + 'tag' => 'array', + 'assignedto' => 'array', + 'watching' => 'array', + 'customfield' => 'array', + 'cc' => 'array', + 'send_user_email' => 'int', + 'send_operators_email' => 'int', + 'attachment' => 'array', + 'created_at' => 'int', ]; - - protected int|null $user; - - protected int|null $onBehalfOf; - - protected string|null $userFirstname; - - protected string|null $userLastname; - - protected string|null $userEmail; - - protected string|null $userOrganisation; - - protected string|null $userIpAddress; - - protected int $department; - - protected int|null $brand; - - protected int $status; - - protected int $priority; - - protected bool|null $internal; - - protected string $subject; - - protected string $text; - - /** @var int[]|null */ - protected array|null $tag; - - /** @var int[]|null */ - protected array|null $assignedto; - - /** @var int[]|null */ - protected array|null $watching; - - /** @var int[]|null */ - protected array|null $customfield; - - /** @var string[]|null */ - protected array|null $cc; - - protected int|null $sendUserEmail; - - protected int|null $sendOperatorsEmail; - - /** @var string[]|null */ - protected array|null $attachment; - - protected int|null $createdAt; } diff --git a/src/Model/User/Request/CreateUser.php b/src/Model/User/Request/CreateUser.php index 9f907811..7a302daf 100644 --- a/src/Model/User/Request/CreateUser.php +++ b/src/Model/User/Request/CreateUser.php @@ -6,39 +6,26 @@ class CreateUser extends Model { - public const REQUIRED_FIELDS = ['email']; - - protected int|null $brandId; - - protected string|null $firstname; - - protected string|null $lastname; - - protected string $email; - - protected string|null $password; - - protected string|null $country; - - protected string|null $languageCode; - - protected string|null $timezone; - - protected bool|null $confirmed; - - protected int|null $active; - - protected string|null $organisation; - - protected int|null $organisationId; - - protected int|null $organisationAccessLevel; - - protected int|null $organisationNotifications; - - /** @var int[]|null */ - protected array|null $customfield; - - /** @var int[]|null */ - protected array|null $groups; + /** @var array */ + protected $casts = [ + 'brand_id' => 'int', + 'firstname' => 'string', + 'lastname' => 'string', + 'email' => 'string', + 'additional_email' => 'array', + 'password' => 'string', + 'send_email' => 'bool', + 'phone' => 'array', + 'country' => 'string', + 'language_code' => 'string', + 'timezone' => 'string', + 'email_verified' => 'bool', + 'active' => 'int', + 'organisation' => 'string', + 'organisation_id' => 'int', + 'organisation_access_level' => 'int', + 'organisation_notifications' => 'int', + 'customfield' => 'array', + 'groups' => 'array', + ]; } diff --git a/test/ApiDataProviders.php b/test/ApiDataProviders.php index 50cdae73..de33961b 100644 --- a/test/ApiDataProviders.php +++ b/test/ApiDataProviders.php @@ -83,18 +83,6 @@ public function providePutEndpointsUnsuccessfulTestCases(): iterable } } - /** - * @return iterable - */ - public function providePostEndpointsUninitializedTestCases(): iterable - { - foreach ($this->getPostEndpoints() as $endpoint => $value) { - $model = current($value); - - yield [get_class($model), $endpoint]; - } - } - /** * @return iterable */ diff --git a/test/ApiTestCase.php b/test/ApiTestCase.php index 4fcb8907..88e892d2 100644 --- a/test/ApiTestCase.php +++ b/test/ApiTestCase.php @@ -6,7 +6,6 @@ use GuzzleHttp\Psr7\Response; use Psr\Http\Message\StreamInterface; use SupportPal\ApiClient\Api\Api; -use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; use SupportPal\ApiClient\Model\Model; @@ -125,26 +124,6 @@ public function testUnsuccessfulPutEndpoint(Response $response, string $endpoint call_user_func_array($callable, $parameters); } - /** - * Tries to send an API request with an empty data object. We expect symfony/serializer - * to throw a TypeError / UninitializedPropertyException due to null property values during - * object serialization. - * - * @param string $modelClass - * @param string $endpoint - * @throws Exception - * @dataProvider providePostEndpointsUninitializedTestCases - * @SuppressWarnings(PHPMD.MissingImport) - */ - public function testUninitializedPostEndpoint(string $modelClass, string $endpoint): void - { - $model = new $modelClass; - /** @var callable $callable */ - $callable = [$this->getApi(), $endpoint]; - self::expectException(InvalidArgumentException::class); - call_user_func_array($callable, [$model]); - } - /** * @param Model $model * @param array $modelData From dd4807fcde3e5419f026944d70611a1896cde8f6 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 12:08:04 +0100 Subject: [PATCH 09/20] fix phpcs --- test/ApiDataProviders.php | 1 - 1 file changed, 1 deletion(-) diff --git a/test/ApiDataProviders.php b/test/ApiDataProviders.php index de33961b..b4e7fd41 100644 --- a/test/ApiDataProviders.php +++ b/test/ApiDataProviders.php @@ -3,7 +3,6 @@ namespace SupportPal\ApiClient\Tests; use function current; -use function get_class; use function next; trait ApiDataProviders From edfd5dc662b62778d9eabb89ae4e05a888222e31 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 12:32:05 +0100 Subject: [PATCH 10/20] refactor --- src/Api/Api.php | 2 +- src/Api/Core/Brands.php | 2 +- src/Api/SelfService/Articles.php | 2 +- src/Api/SelfService/Categories.php | 2 +- src/Api/SelfService/Comments.php | 2 +- src/Api/SelfService/Tags.php | 2 +- src/Api/SelfService/Types.php | 2 +- src/Api/Ticket/Attachments.php | 2 +- src/Api/Ticket/CustomFields.php | 2 +- src/Api/Ticket/Departments.php | 4 +- src/Api/Ticket/Messages.php | 2 +- src/Api/Ticket/Priorities.php | 2 +- src/Api/Ticket/Statuses.php | 2 +- src/Api/Ticket/Tickets.php | 2 +- src/Api/User/CustomFields.php | 2 +- src/Api/User/UserGroups.php | 2 +- src/Api/User/Users.php | 2 +- src/Cache/ApiCacheMap.php | 5 -- src/Dictionary/ApiDictionary.php | 2 - src/Exception/Exception.php | 4 -- src/Exception/HttpResponseException.php | 4 -- src/Exception/InvalidArgumentException.php | 4 -- .../MissingRequiredFieldsException.php | 4 -- src/Exception/NotSupportedException.php | 4 -- src/Exception/RuntimeException.php | 4 -- src/Helper/StringHelper.php | 33 ---------- src/Http/Core/SettingsApis.php | 4 -- src/Http/SelfService/ArticleApis.php | 4 -- src/Http/SelfService/CategoryApis.php | 4 -- src/Http/SelfService/CommentApis.php | 4 -- src/Http/SelfService/SettingsApis.php | 4 -- src/Http/SelfService/TagApis.php | 4 -- src/Http/SelfService/TypeApis.php | 4 -- src/Http/Ticket/DepartmentApis.php | 4 -- src/Http/Ticket/SettingsApis.php | 4 -- src/Model/{Collection => }/Collection.php | 23 +++---- src/Model/Department/Operator.php | 9 --- .../{Department => Ticket}/Department.php | 11 ++-- .../Email.php => Ticket/DepartmentEmail.php} | 4 +- .../DepartmentEmailTemplates.php} | 4 +- .../DepartmentTranslation.php | 2 +- src/Model/Ticket/Priority.php | 1 - src/Model/Ticket/Ticket.php | 5 -- src/Model/Ticket/TicketCustomField.php | 1 - src/SupportPal.php | 4 -- test/ContainerAwareBaseTestCase.php | 5 -- test/DataFixtures/Ticket/DepartmentData.php | 2 +- .../Ticket/DepartmentTranslationData.php | 2 +- test/DataFixtures/Ticket/EmailData.php | 4 +- .../Ticket/EmailTemplatesData.php | 4 +- test/Functional/Api/CoreApisTest.php | 4 -- test/Functional/Api/SelfServiceApisTest.php | 4 -- test/Functional/Api/UserApisTest.php | 4 -- test/Functional/ApiComponentTest.php | 4 -- test/Functional/StringHelperTest.php | 63 ------------------- test/Functional/SupportPalTest.php | 4 -- .../Integration/Api/CoreApisComponentTest.php | 4 -- .../Api/SelfServiceApisComponentTest.php | 4 -- .../Integration/Api/UserApisComponentTest.php | 4 -- test/Integration/ApiClient/CoreApisTest.php | 4 -- .../ApiClient/SelfServiceApisTest.php | 4 -- test/Integration/ApiClient/UserApisTest.php | 4 -- test/Integration/ApiComponentTest.php | 4 -- test/TestCase.php | 8 +-- test/Unit/Api/Core/BrandApisTest.php | 6 -- test/Unit/Api/SelfService/ArticleApisTest.php | 6 -- .../Unit/Api/SelfService/CategoryApisTest.php | 6 -- test/Unit/Api/SelfService/CommentApisTest.php | 6 -- .../Unit/Api/SelfService/SettingsApisTest.php | 6 -- test/Unit/Api/SelfService/TagApisTest.php | 6 -- test/Unit/Api/SelfService/TypeApiTest.php | 6 -- test/Unit/Api/Ticket/AttachmentApisTest.php | 6 -- test/Unit/Api/Ticket/ChannelApisTest.php | 6 -- test/Unit/Api/Ticket/CustomFieldApisTest.php | 6 -- test/Unit/Api/Ticket/DepartmentApisTest.php | 8 +-- test/Unit/Api/Ticket/MessageApisTest.php | 6 -- test/Unit/Api/Ticket/PriorityApisTest.php | 6 -- test/Unit/Api/Ticket/StatusApisTest.php | 6 -- test/Unit/Api/Ticket/TicketApisTest.php | 6 -- .../Api/Ticket/TicketSettingsApisTest.php | 6 -- test/Unit/Api/User/UserApisTest.php | 6 -- .../Unit/Api/User/UserCustomFieldApisTest.php | 6 -- test/Unit/Api/User/UserGroupApisTest.php | 6 -- test/Unit/ApiClient/Core/CoreApisTest.php | 6 -- .../ApiClient/SelfService/ArticleApisTest.php | 6 -- .../SelfService/CategoryApisTest.php | 6 -- .../ApiClient/SelfService/CommentApisTest.php | 6 -- .../SelfService/SettingsApisTest.php | 6 -- .../ApiClient/SelfService/TagApisTest.php | 6 -- .../ApiClient/SelfService/TypeApisTest.php | 6 -- .../ApiClient/Ticket/AttachmentApisTest.php | 6 -- .../Ticket/ChannelSettingsApisTest.php | 6 -- .../ApiClient/Ticket/CustomFieldApisTest.php | 6 -- .../ApiClient/Ticket/DepartmentApisTest.php | 6 -- .../Unit/ApiClient/Ticket/MessageApisTest.php | 6 -- .../ApiClient/Ticket/PriorityApisTest.php | 6 -- test/Unit/ApiClient/Ticket/StatusApisTest.php | 6 -- .../Cache/CacheStrategyConfiguratorTest.php | 5 -- .../Cache/CacheableRequestMatcherTest.php | 5 -- test/Unit/Model/BaseModelTestCase.php | 5 -- .../Model/{Collection => }/CollectionTest.php | 17 ++--- test/Unit/Model/Core/BrandTest.php | 5 -- test/Unit/Model/Core/BrandTranslationTest.php | 5 -- test/Unit/Model/Core/UploadTest.php | 5 -- test/Unit/Model/Department/OperatorTest.php | 32 ---------- .../SelfService/ArticleAttachmentTest.php | 5 -- test/Unit/Model/SelfService/ArticleTest.php | 5 -- .../SelfService/ArticleTranslationTest.php | 5 -- test/Unit/Model/SelfService/CategoryTest.php | 5 -- .../SelfService/CategoryTranslationTest.php | 5 -- test/Unit/Model/SelfService/CommentTest.php | 6 -- .../SelfService/Request/CreateCommentTest.php | 5 -- test/Unit/Model/SelfService/TagTest.php | 5 -- test/Unit/Model/SelfService/TypeTest.php | 5 -- .../Model/SelfService/TypeTranslationTest.php | 5 -- test/Unit/Model/Shared/OptionTest.php | 5 -- .../Model/Shared/OptionTranslationTest.php | 5 -- test/Unit/Model/Ticket/AttachmentTest.php | 6 -- .../Unit/Model/Ticket/ChannelSettingsTest.php | 5 -- test/Unit/Model/Ticket/ChannelTest.php | 5 -- .../DepartmentEmailTemplatesTest.php} | 13 ++-- .../DepartmentEmailTest.php} | 13 ++-- .../{Department => Ticket}/DepartmentTest.php | 9 +-- .../Ticket/DepartmentTranslationTest.php | 7 +-- test/Unit/Model/Ticket/ExtraTest.php | 5 -- test/Unit/Model/Ticket/MessageTest.php | 5 -- test/Unit/Model/Ticket/PriorityTest.php | 5 -- .../Model/Ticket/PriorityTranslationTest.php | 5 -- .../Ticket/Request/CreateMessageTest.php | 5 -- .../Model/Ticket/Request/CreateTicketTest.php | 5 -- test/Unit/Model/Ticket/SlaPlanTest.php | 5 -- .../Model/Ticket/SlaPlanTranslationTest.php | 5 -- test/Unit/Model/Ticket/StatusTest.php | 5 -- .../Model/Ticket/StatusTranslationTest.php | 5 -- test/Unit/Model/Ticket/TagTest.php | 5 -- test/Unit/Model/Ticket/TagTranslationTest.php | 5 -- .../Model/Ticket/TicketCustomFieldTest.php | 6 -- .../TicketCustomFieldTranslationTest.php | 5 -- test/Unit/Model/Ticket/TicketTest.php | 5 -- test/Unit/Model/User/DomainTest.php | 5 -- test/Unit/Model/User/GroupTest.php | 5 -- test/Unit/Model/User/GroupTranslationTest.php | 5 -- test/Unit/Model/User/OrganisationTest.php | 5 -- .../Model/User/Request/CreateUserTest.php | 5 -- test/Unit/Model/User/UserCustomFieldTest.php | 6 -- .../User/UserCustomFieldTranslationTest.php | 5 -- test/Unit/Model/User/UserTest.php | 5 -- 147 files changed, 61 insertions(+), 790 deletions(-) delete mode 100644 src/Helper/StringHelper.php rename src/Model/{Collection => }/Collection.php (85%) delete mode 100644 src/Model/Department/Operator.php rename src/Model/{Department => Ticket}/Department.php (75%) rename src/Model/{Department/Email.php => Ticket/DepartmentEmail.php} (90%) rename src/Model/{Department/EmailTemplates.php => Ticket/DepartmentEmailTemplates.php} (90%) rename src/Model/{Department => Ticket}/DepartmentTranslation.php (87%) delete mode 100644 test/Functional/StringHelperTest.php rename test/Unit/Model/{Collection => }/CollectionTest.php (91%) delete mode 100644 test/Unit/Model/Department/OperatorTest.php rename test/Unit/Model/{Department/EmailTemplatesTest.php => Ticket/DepartmentEmailTemplatesTest.php} (55%) rename test/Unit/Model/{Department/EmailTest.php => Ticket/DepartmentEmailTest.php} (57%) rename test/Unit/Model/{Department => Ticket}/DepartmentTest.php (66%) diff --git a/src/Api/Api.php b/src/Api/Api.php index e04ce765..52c50458 100644 --- a/src/Api/Api.php +++ b/src/Api/Api.php @@ -4,7 +4,7 @@ use Psr\Http\Message\ResponseInterface; use SupportPal\ApiClient\Exception\InvalidArgumentException; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Model; use function json_decode; diff --git a/src/Api/Core/Brands.php b/src/Api/Core/Brands.php index c1c40908..f347ed5c 100644 --- a/src/Api/Core/Brands.php +++ b/src/Api/Core/Brands.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\CoreClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Core\Brand; use function array_map; diff --git a/src/Api/SelfService/Articles.php b/src/Api/SelfService/Articles.php index 66d4d9cb..e4333356 100644 --- a/src/Api/SelfService/Articles.php +++ b/src/Api/SelfService/Articles.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\SelfServiceClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\SelfService\Article; use function array_map; diff --git a/src/Api/SelfService/Categories.php b/src/Api/SelfService/Categories.php index 115a2206..6ec85c57 100644 --- a/src/Api/SelfService/Categories.php +++ b/src/Api/SelfService/Categories.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\SelfServiceClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\SelfService\Category; use function array_map; diff --git a/src/Api/SelfService/Comments.php b/src/Api/SelfService/Comments.php index 2ee00557..29b6a395 100644 --- a/src/Api/SelfService/Comments.php +++ b/src/Api/SelfService/Comments.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\SelfServiceClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\SelfService\Comment; use SupportPal\ApiClient\Model\SelfService\Request\CreateComment; diff --git a/src/Api/SelfService/Tags.php b/src/Api/SelfService/Tags.php index 80b67c30..fa00b4fd 100644 --- a/src/Api/SelfService/Tags.php +++ b/src/Api/SelfService/Tags.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\SelfServiceClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\SelfService\Tag; use function array_map; diff --git a/src/Api/SelfService/Types.php b/src/Api/SelfService/Types.php index 744711f7..dffe33eb 100644 --- a/src/Api/SelfService/Types.php +++ b/src/Api/SelfService/Types.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\SelfServiceClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\SelfService\Type; use function array_map; diff --git a/src/Api/Ticket/Attachments.php b/src/Api/Ticket/Attachments.php index 1f290108..36a968c5 100644 --- a/src/Api/Ticket/Attachments.php +++ b/src/Api/Ticket/Attachments.php @@ -7,7 +7,7 @@ use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; use SupportPal\ApiClient\Http\TicketClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Ticket\Attachment; use function array_map; diff --git a/src/Api/Ticket/CustomFields.php b/src/Api/Ticket/CustomFields.php index 8d2a79cd..69516180 100644 --- a/src/Api/Ticket/CustomFields.php +++ b/src/Api/Ticket/CustomFields.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\TicketClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Shared\CustomField; use SupportPal\ApiClient\Model\Ticket\TicketCustomField; diff --git a/src/Api/Ticket/Departments.php b/src/Api/Ticket/Departments.php index bb5f76e5..9bd7ff0b 100644 --- a/src/Api/Ticket/Departments.php +++ b/src/Api/Ticket/Departments.php @@ -5,8 +5,8 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\TicketClient; -use SupportPal\ApiClient\Model\Collection\Collection; -use SupportPal\ApiClient\Model\Department\Department; +use SupportPal\ApiClient\Model\Collection; +use SupportPal\ApiClient\Model\Ticket\Department; use function array_map; diff --git a/src/Api/Ticket/Messages.php b/src/Api/Ticket/Messages.php index eca82386..646727dd 100644 --- a/src/Api/Ticket/Messages.php +++ b/src/Api/Ticket/Messages.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\TicketClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Ticket\Message; use SupportPal\ApiClient\Model\Ticket\Request\CreateMessage; diff --git a/src/Api/Ticket/Priorities.php b/src/Api/Ticket/Priorities.php index a9fb3a4e..26926a4d 100644 --- a/src/Api/Ticket/Priorities.php +++ b/src/Api/Ticket/Priorities.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\TicketClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Ticket\Priority; use function array_map; diff --git a/src/Api/Ticket/Statuses.php b/src/Api/Ticket/Statuses.php index b7476551..cc3eac6b 100644 --- a/src/Api/Ticket/Statuses.php +++ b/src/Api/Ticket/Statuses.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\TicketClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Ticket\Status; use function array_map; diff --git a/src/Api/Ticket/Tickets.php b/src/Api/Ticket/Tickets.php index c4366d63..b20ce3e6 100644 --- a/src/Api/Ticket/Tickets.php +++ b/src/Api/Ticket/Tickets.php @@ -6,7 +6,7 @@ use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; use SupportPal\ApiClient\Http\TicketClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Ticket\Request\CreateTicket; use SupportPal\ApiClient\Model\Ticket\Ticket; diff --git a/src/Api/User/CustomFields.php b/src/Api/User/CustomFields.php index 99567bdb..38ad7e43 100644 --- a/src/Api/User/CustomFields.php +++ b/src/Api/User/CustomFields.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\UserClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\User\UserCustomField; use function array_map; diff --git a/src/Api/User/UserGroups.php b/src/Api/User/UserGroups.php index 32c3aebd..f24cb53e 100644 --- a/src/Api/User/UserGroups.php +++ b/src/Api/User/UserGroups.php @@ -5,7 +5,7 @@ use SupportPal\ApiClient\Exception\HttpResponseException; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Http\UserClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\User\Group; use function array_map; diff --git a/src/Api/User/Users.php b/src/Api/User/Users.php index c4ec8404..84f265e1 100644 --- a/src/Api/User/Users.php +++ b/src/Api/User/Users.php @@ -6,7 +6,7 @@ use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Exception\MissingIdentifierException; use SupportPal\ApiClient\Http\UserClient; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\User\Request\CreateUser; use SupportPal\ApiClient\Model\User\User; diff --git a/src/Cache/ApiCacheMap.php b/src/Cache/ApiCacheMap.php index 1d09b851..b1148b76 100644 --- a/src/Cache/ApiCacheMap.php +++ b/src/Cache/ApiCacheMap.php @@ -6,11 +6,6 @@ use function ltrim; -/** - * This class includes the list of cachable apis related to their behaviour - * Class ApiCacheMap - * @package SupportPal\ApiClient\Cache - */ class ApiCacheMap { protected const DEFAULT_CACHE_TTL = 600; diff --git a/src/Dictionary/ApiDictionary.php b/src/Dictionary/ApiDictionary.php index 9fc2b8cf..a28b493d 100644 --- a/src/Dictionary/ApiDictionary.php +++ b/src/Dictionary/ApiDictionary.php @@ -5,8 +5,6 @@ /** * This class includes the names of all the supported endpoints. * The defined APIs should only include the resource path without the API `/` prefix and postfix. - * Class APIDictionary - * @package SupportPal\ApiClient\Dictionary */ final class ApiDictionary { diff --git a/src/Exception/Exception.php b/src/Exception/Exception.php index 4a163d25..cb5dd60e 100644 --- a/src/Exception/Exception.php +++ b/src/Exception/Exception.php @@ -4,10 +4,6 @@ use Exception as PhpException; -/** - * Class BaseException - * @package SupportPal\ApiClient\Exception - */ class Exception extends PhpException { } diff --git a/src/Exception/HttpResponseException.php b/src/Exception/HttpResponseException.php index 363b7863..d5c7171e 100644 --- a/src/Exception/HttpResponseException.php +++ b/src/Exception/HttpResponseException.php @@ -6,10 +6,6 @@ use Psr\Http\Message\ResponseInterface; use Throwable; -/** - * Class HttpResponseException - * @package SupportPal\ApiClient\Exception - */ class HttpResponseException extends Exception { /** @var RequestInterface */ diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 139f4785..91b31cb0 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -2,10 +2,6 @@ namespace SupportPal\ApiClient\Exception; -/** - * Class InvalidArgumentException - * @package SupportPal\ApiClient\Exception - */ class InvalidArgumentException extends Exception { } diff --git a/src/Exception/MissingRequiredFieldsException.php b/src/Exception/MissingRequiredFieldsException.php index ab1ce948..77aa4d55 100644 --- a/src/Exception/MissingRequiredFieldsException.php +++ b/src/Exception/MissingRequiredFieldsException.php @@ -2,10 +2,6 @@ namespace SupportPal\ApiClient\Exception; -/** - * Class MissingRequiredFieldsException - * @package SupportPal\ApiClient\Exception - */ class MissingRequiredFieldsException extends RuntimeException { } diff --git a/src/Exception/NotSupportedException.php b/src/Exception/NotSupportedException.php index bd984bf8..146def7d 100644 --- a/src/Exception/NotSupportedException.php +++ b/src/Exception/NotSupportedException.php @@ -2,10 +2,6 @@ namespace SupportPal\ApiClient\Exception; -/** - * Class NotSupportedException - * @package SupportPal\ApiClient\Exception - */ class NotSupportedException extends RuntimeException { } diff --git a/src/Exception/RuntimeException.php b/src/Exception/RuntimeException.php index 77bdb409..c4a2e3b1 100644 --- a/src/Exception/RuntimeException.php +++ b/src/Exception/RuntimeException.php @@ -4,10 +4,6 @@ use RuntimeException as PhpRuntimeException; -/** - * Class BaseRuntimeException - * @package SupportPal\ApiClient\Exception - */ class RuntimeException extends PhpRuntimeException { } diff --git a/src/Helper/StringHelper.php b/src/Helper/StringHelper.php deleted file mode 100644 index 105cb528..00000000 --- a/src/Helper/StringHelper.php +++ /dev/null @@ -1,33 +0,0 @@ - 'int', 'created_at' => 'int', 'updated_at' => 'int', - 'email_templates' => 'array:' . EmailTemplates::class, - 'emails' => 'array:' . Email::class, + 'email_templates' => 'array:' . DepartmentEmailTemplates::class, + 'emails' => 'array:' . DepartmentEmail::class, 'translations' => 'array:' . DepartmentTranslation::class, 'groups' => 'array:' . Group::class, - 'operators' => 'array:' . Operator::class, + 'operators' => 'array:' . User::class, 'parent' => 'array:' . self::class, - 'default_assignedto' => 'array:' . Operator::class, + 'default_assignedto' => 'array:' . User::class, ]; } diff --git a/src/Model/Department/Email.php b/src/Model/Ticket/DepartmentEmail.php similarity index 90% rename from src/Model/Department/Email.php rename to src/Model/Ticket/DepartmentEmail.php index 792fd9cc..dc3cc71e 100644 --- a/src/Model/Department/Email.php +++ b/src/Model/Ticket/DepartmentEmail.php @@ -1,10 +1,10 @@ */ protected $casts = [ diff --git a/src/Model/Department/EmailTemplates.php b/src/Model/Ticket/DepartmentEmailTemplates.php similarity index 90% rename from src/Model/Department/EmailTemplates.php rename to src/Model/Ticket/DepartmentEmailTemplates.php index eaab20cb..d82d6789 100644 --- a/src/Model/Department/EmailTemplates.php +++ b/src/Model/Ticket/DepartmentEmailTemplates.php @@ -1,10 +1,10 @@ */ protected $casts = [ diff --git a/src/Model/Department/DepartmentTranslation.php b/src/Model/Ticket/DepartmentTranslation.php similarity index 87% rename from src/Model/Department/DepartmentTranslation.php rename to src/Model/Ticket/DepartmentTranslation.php index 224af8ba..8ce2aae5 100644 --- a/src/Model/Department/DepartmentTranslation.php +++ b/src/Model/Ticket/DepartmentTranslation.php @@ -1,6 +1,6 @@ */ diff --git a/test/DataFixtures/Ticket/DepartmentData.php b/test/DataFixtures/Ticket/DepartmentData.php index 0cd4f0ad..82daf9c1 100644 --- a/test/DataFixtures/Ticket/DepartmentData.php +++ b/test/DataFixtures/Ticket/DepartmentData.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\DataFixtures\Ticket; use SupportPal\ApiClient\Exception\InvalidArgumentException; -use SupportPal\ApiClient\Model\Department\Department; +use SupportPal\ApiClient\Model\Ticket\Department; use SupportPal\ApiClient\Tests\DataFixtures\BaseModelData; use SupportPal\ApiClient\Tests\DataFixtures\User\GroupData; diff --git a/test/DataFixtures/Ticket/DepartmentTranslationData.php b/test/DataFixtures/Ticket/DepartmentTranslationData.php index 917a66aa..31c81073 100644 --- a/test/DataFixtures/Ticket/DepartmentTranslationData.php +++ b/test/DataFixtures/Ticket/DepartmentTranslationData.php @@ -2,7 +2,7 @@ namespace SupportPal\ApiClient\Tests\DataFixtures\Ticket; -use SupportPal\ApiClient\Model\Department\DepartmentTranslation; +use SupportPal\ApiClient\Model\Ticket\DepartmentTranslation; use SupportPal\ApiClient\Tests\DataFixtures\BaseModelData; class DepartmentTranslationData extends BaseModelData diff --git a/test/DataFixtures/Ticket/EmailData.php b/test/DataFixtures/Ticket/EmailData.php index 16d1fe82..42986f2b 100644 --- a/test/DataFixtures/Ticket/EmailData.php +++ b/test/DataFixtures/Ticket/EmailData.php @@ -2,7 +2,7 @@ namespace SupportPal\ApiClient\Tests\DataFixtures\Ticket; -use SupportPal\ApiClient\Model\Department\Email; +use SupportPal\ApiClient\Model\Ticket\DepartmentEmail; use SupportPal\ApiClient\Tests\DataFixtures\BaseModelData; class EmailData extends BaseModelData @@ -32,6 +32,6 @@ class EmailData extends BaseModelData */ public function getModel(): string { - return Email::class; + return DepartmentEmail::class; } } diff --git a/test/DataFixtures/Ticket/EmailTemplatesData.php b/test/DataFixtures/Ticket/EmailTemplatesData.php index 5fc9e3e4..9535de5c 100644 --- a/test/DataFixtures/Ticket/EmailTemplatesData.php +++ b/test/DataFixtures/Ticket/EmailTemplatesData.php @@ -2,7 +2,7 @@ namespace SupportPal\ApiClient\Tests\DataFixtures\Ticket; -use SupportPal\ApiClient\Model\Department\EmailTemplates; +use SupportPal\ApiClient\Model\Ticket\DepartmentEmailTemplates; use SupportPal\ApiClient\Tests\DataFixtures\BaseModelData; class EmailTemplatesData extends BaseModelData @@ -32,6 +32,6 @@ class EmailTemplatesData extends BaseModelData */ public function getModel(): string { - return EmailTemplates::class; + return DepartmentEmailTemplates::class; } } diff --git a/test/Functional/Api/CoreApisTest.php b/test/Functional/Api/CoreApisTest.php index 4f65f94f..08c748d7 100644 --- a/test/Functional/Api/CoreApisTest.php +++ b/test/Functional/Api/CoreApisTest.php @@ -7,10 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\ApiCalls\CoreApisData; use SupportPal\ApiClient\Tests\Functional\ApiComponentTest; -/** - * Class CoreApisTest - * @package SupportPal\ApiClient\Tests\Functional\Api - */ class CoreApisTest extends ApiComponentTest { /** diff --git a/test/Functional/Api/SelfServiceApisTest.php b/test/Functional/Api/SelfServiceApisTest.php index 7ca902e3..f63e3735 100644 --- a/test/Functional/Api/SelfServiceApisTest.php +++ b/test/Functional/Api/SelfServiceApisTest.php @@ -8,10 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\ApiCalls\SelfServiceApisData; use SupportPal\ApiClient\Tests\Functional\ApiComponentTest; -/** - * Class SelfServiceApisTest - * @package SupportPal\ApiClient\Tests\Functional\Api - */ class SelfServiceApisTest extends ApiComponentTest { /** diff --git a/test/Functional/Api/UserApisTest.php b/test/Functional/Api/UserApisTest.php index 46e2be79..3a0bb0a3 100644 --- a/test/Functional/Api/UserApisTest.php +++ b/test/Functional/Api/UserApisTest.php @@ -8,10 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\ApiCalls\UserApisData; use SupportPal\ApiClient\Tests\Functional\ApiComponentTest; -/** - * Class UserApisTest - * @package SupportPal\ApiClient\Tests\Functional\Api - */ class UserApisTest extends ApiComponentTest { /** diff --git a/test/Functional/ApiComponentTest.php b/test/Functional/ApiComponentTest.php index 3f40a2de..007bb835 100644 --- a/test/Functional/ApiComponentTest.php +++ b/test/Functional/ApiComponentTest.php @@ -5,10 +5,6 @@ use SupportPal\ApiClient\Tests\ApiDataProviders; use SupportPal\ApiClient\Tests\ApiTestCase; -/** - * Class ApiComponentTest - * @package SupportPal\ApiClient\Tests\Functional - */ abstract class ApiComponentTest extends ApiTestCase { use ApiDataProviders; diff --git a/test/Functional/StringHelperTest.php b/test/Functional/StringHelperTest.php deleted file mode 100644 index da88c9f4..00000000 --- a/test/Functional/StringHelperTest.php +++ /dev/null @@ -1,63 +0,0 @@ -snakeCaseToCamelCase($string)); - } - - /** - * @param string $string - * @param string $expected - * @dataProvider provideSnakeCaseToPascalCase - */ - public function testSnakeCaseToPascalCase(string $string, string $expected): void - { - self::assertSame($expected, $this->snakeCaseToPascalCase($string)); - } - - /** - * @return string[][] - */ - public function provideSnakeCaseToCamelCase(): array - { - return [ - ['test', 'test'], - ['test_case', 'testCase'], - ['test_case_multiple', 'testCaseMultiple'], - ['', ''], - ]; - } - - /** - * @return string[][] - */ - public function provideSnakeCaseToPascalCase(): array - { - return [ - ['test', 'Test'], - ['test_case', 'TestCase'], - ['test_case_multiple', 'TestCaseMultiple'], - ['', ''], - ]; - } -} diff --git a/test/Functional/SupportPalTest.php b/test/Functional/SupportPalTest.php index bbeac4a7..5c040080 100644 --- a/test/Functional/SupportPalTest.php +++ b/test/Functional/SupportPalTest.php @@ -15,10 +15,6 @@ use function current; use function json_encode; -/** - * Class SupportPalTest - * @package SupportPal\ApiClient\Tests\Functional - */ class SupportPalTest extends ContainerAwareBaseTestCase { public function testGetRequestFactory(): void diff --git a/test/Integration/Api/CoreApisComponentTest.php b/test/Integration/Api/CoreApisComponentTest.php index 28c02665..64546cfa 100644 --- a/test/Integration/Api/CoreApisComponentTest.php +++ b/test/Integration/Api/CoreApisComponentTest.php @@ -6,10 +6,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\ApiCalls\CoreApisData; use SupportPal\ApiClient\Tests\Integration\ApiComponentTest; -/** - * Class CoreApisTest - * @package SupportPal\ApiClient\Tests\Integration\Api - */ class CoreApisComponentTest extends ApiComponentTest { /** diff --git a/test/Integration/Api/SelfServiceApisComponentTest.php b/test/Integration/Api/SelfServiceApisComponentTest.php index 36ee38bb..1c37fdf7 100644 --- a/test/Integration/Api/SelfServiceApisComponentTest.php +++ b/test/Integration/Api/SelfServiceApisComponentTest.php @@ -6,10 +6,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\ApiCalls\SelfServiceApisData; use SupportPal\ApiClient\Tests\Integration\ApiComponentTest; -/** - * Class SelfServiceApisTest - * @package SupportPal\ApiClient\Tests\Integration\Api - */ class SelfServiceApisComponentTest extends ApiComponentTest { /** diff --git a/test/Integration/Api/UserApisComponentTest.php b/test/Integration/Api/UserApisComponentTest.php index b5796e7e..6ee39cdb 100644 --- a/test/Integration/Api/UserApisComponentTest.php +++ b/test/Integration/Api/UserApisComponentTest.php @@ -7,10 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\ApiCalls\UserApisData; use SupportPal\ApiClient\Tests\Integration\ApiComponentTest; -/** - * Class UsersApisTest - * @package SupportPal\ApiClient\Tests\Integration\Api - */ class UserApisComponentTest extends ApiComponentTest { /** diff --git a/test/Integration/ApiClient/CoreApisTest.php b/test/Integration/ApiClient/CoreApisTest.php index b8a31404..81fe94a2 100644 --- a/test/Integration/ApiClient/CoreApisTest.php +++ b/test/Integration/ApiClient/CoreApisTest.php @@ -7,10 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Core\CoreSettingsData; use SupportPal\ApiClient\Tests\Integration\ApiClientTest; -/** - * Class CoreApisTest - * @package SupportPal\ApiClient\Tests\Integration\ApiClient - */ class CoreApisTest extends ApiClientTest { /** diff --git a/test/Integration/ApiClient/SelfServiceApisTest.php b/test/Integration/ApiClient/SelfServiceApisTest.php index eb83c773..d583629c 100644 --- a/test/Integration/ApiClient/SelfServiceApisTest.php +++ b/test/Integration/ApiClient/SelfServiceApisTest.php @@ -12,10 +12,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TypeData; use SupportPal\ApiClient\Tests\Integration\ApiClientTest; -/** - * Class SelfServiceApisTest - * @package SupportPal\ApiClient\Tests\Integration\ApiClient - */ class SelfServiceApisTest extends ApiClientTest { /** diff --git a/test/Integration/ApiClient/UserApisTest.php b/test/Integration/ApiClient/UserApisTest.php index a2ec5994..86d21708 100644 --- a/test/Integration/ApiClient/UserApisTest.php +++ b/test/Integration/ApiClient/UserApisTest.php @@ -9,10 +9,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\User\UserData; use SupportPal\ApiClient\Tests\Integration\ApiClientTest; -/** - * Class UsersApisTest - * @package SupportPal\ApiClient\Tests\Integration\ApiClient - */ class UserApisTest extends ApiClientTest { /** diff --git a/test/Integration/ApiComponentTest.php b/test/Integration/ApiComponentTest.php index e1499ed5..4f94fa03 100644 --- a/test/Integration/ApiComponentTest.php +++ b/test/Integration/ApiComponentTest.php @@ -6,10 +6,6 @@ use SupportPal\ApiClient\Tests\ApiDataProviders; use SupportPal\ApiClient\Tests\ApiTestCase; -/** - * Class ApiTestCase - * @package SupportPal\ApiClient\Tests - */ abstract class ApiComponentTest extends ApiTestCase { use ApiDataProviders; diff --git a/test/TestCase.php b/test/TestCase.php index 94a558f8..c1e638f9 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -2,8 +2,7 @@ namespace SupportPal\ApiClient\Tests; -use SupportPal\ApiClient\Helper\StringHelper; -use SupportPal\ApiClient\Model\Collection\Collection; +use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; @@ -13,13 +12,8 @@ use function is_bool; use function is_object; -/** - * Class TestCase - * @package SupportPal\ApiClient\Tests - */ class TestCase extends \PHPUnit\Framework\TestCase { - use StringHelper; use PhpUnitCompatibilityTrait; /** diff --git a/test/Unit/Api/Core/BrandApisTest.php b/test/Unit/Api/Core/BrandApisTest.php index e16ccb50..889d83fe 100644 --- a/test/Unit/Api/Core/BrandApisTest.php +++ b/test/Unit/Api/Core/BrandApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Core\BrandData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class BrandApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Core - * @covers \SupportPal\ApiClient\Api\Core\Brands - * @covers \SupportPal\ApiClient\Api\Api - */ class BrandApisTest extends ApiTest { /** @var CoreApi */ diff --git a/test/Unit/Api/SelfService/ArticleApisTest.php b/test/Unit/Api/SelfService/ArticleApisTest.php index d280c78d..4bcd6ccd 100644 --- a/test/Unit/Api/SelfService/ArticleApisTest.php +++ b/test/Unit/Api/SelfService/ArticleApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\ArticleData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class ArticleApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\Articles - * @covers \SupportPal\ApiClient\Api\Api - */ class ArticleApisTest extends ApiTest { /** @var SelfServiceApi */ diff --git a/test/Unit/Api/SelfService/CategoryApisTest.php b/test/Unit/Api/SelfService/CategoryApisTest.php index dd59e64e..cc870af3 100644 --- a/test/Unit/Api/SelfService/CategoryApisTest.php +++ b/test/Unit/Api/SelfService/CategoryApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CategoryData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class CategoryApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\Categories - * @covers \SupportPal\ApiClient\Api\Api - */ class CategoryApisTest extends ApiTest { /** @var SelfServiceApi */ diff --git a/test/Unit/Api/SelfService/CommentApisTest.php b/test/Unit/Api/SelfService/CommentApisTest.php index de7504f8..24f49338 100644 --- a/test/Unit/Api/SelfService/CommentApisTest.php +++ b/test/Unit/Api/SelfService/CommentApisTest.php @@ -9,12 +9,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class CommentApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\Comments - * @covers \SupportPal\ApiClient\Api\Api - */ class CommentApisTest extends ApiTest { /** @var SelfServiceApi */ diff --git a/test/Unit/Api/SelfService/SettingsApisTest.php b/test/Unit/Api/SelfService/SettingsApisTest.php index 7601f38a..48109b43 100644 --- a/test/Unit/Api/SelfService/SettingsApisTest.php +++ b/test/Unit/Api/SelfService/SettingsApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\SettingsData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class SettingsApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\Settings - * @covers \SupportPal\ApiClient\Api\Api - */ class SettingsApisTest extends ApiTest { /** @var SelfServiceApi */ diff --git a/test/Unit/Api/SelfService/TagApisTest.php b/test/Unit/Api/SelfService/TagApisTest.php index 325ce648..369d8adc 100644 --- a/test/Unit/Api/SelfService/TagApisTest.php +++ b/test/Unit/Api/SelfService/TagApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TagData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class TagApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\Tags - * @covers \SupportPal\ApiClient\Api\Api - */ class TagApisTest extends ApiTest { /** @var SelfServiceApi */ diff --git a/test/Unit/Api/SelfService/TypeApiTest.php b/test/Unit/Api/SelfService/TypeApiTest.php index 31a3efad..230337dd 100644 --- a/test/Unit/Api/SelfService/TypeApiTest.php +++ b/test/Unit/Api/SelfService/TypeApiTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TypeData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class TypeApiTest - * @package SupportPal\ApiClient\Tests\Unit\Api\SelfService - * @covers \SupportPal\ApiClient\Api\SelfService\Types - * @covers \SupportPal\ApiClient\Api\Api - */ class TypeApiTest extends ApiTest { /** @var SelfServiceApi */ diff --git a/test/Unit/Api/Ticket/AttachmentApisTest.php b/test/Unit/Api/Ticket/AttachmentApisTest.php index 98426765..366cc2e8 100644 --- a/test/Unit/Api/Ticket/AttachmentApisTest.php +++ b/test/Unit/Api/Ticket/AttachmentApisTest.php @@ -10,12 +10,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\AttachmentData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class AttachmentApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\Attachments - * @covers \SupportPal\ApiClient\Api\Api - */ class AttachmentApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/Ticket/ChannelApisTest.php b/test/Unit/Api/Ticket/ChannelApisTest.php index 5f950d7a..3071e3d3 100644 --- a/test/Unit/Api/Ticket/ChannelApisTest.php +++ b/test/Unit/Api/Ticket/ChannelApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\ChannelSettingsData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class ChannelApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\ChannelSettings - * @covers \SupportPal\ApiClient\Api\Api - */ class ChannelApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/Ticket/CustomFieldApisTest.php b/test/Unit/Api/Ticket/CustomFieldApisTest.php index 49d6ae70..3663b025 100644 --- a/test/Unit/Api/Ticket/CustomFieldApisTest.php +++ b/test/Unit/Api/Ticket/CustomFieldApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\TicketCustomFieldData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class CustomFieldApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\CustomFields - * @covers \SupportPal\ApiClient\Api\Api - */ class CustomFieldApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/Ticket/DepartmentApisTest.php b/test/Unit/Api/Ticket/DepartmentApisTest.php index 4c8bc786..e5284b16 100644 --- a/test/Unit/Api/Ticket/DepartmentApisTest.php +++ b/test/Unit/Api/Ticket/DepartmentApisTest.php @@ -4,16 +4,10 @@ use SupportPal\ApiClient\Api\TicketApi; use SupportPal\ApiClient\Http\TicketClient; -use SupportPal\ApiClient\Model\Department\Department; +use SupportPal\ApiClient\Model\Ticket\Department; use SupportPal\ApiClient\Tests\DataFixtures\Ticket\DepartmentData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class DepartmentApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\Departments - * @covers \SupportPal\ApiClient\Api\Api - */ class DepartmentApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/Ticket/MessageApisTest.php b/test/Unit/Api/Ticket/MessageApisTest.php index 44f97fad..29e4463f 100644 --- a/test/Unit/Api/Ticket/MessageApisTest.php +++ b/test/Unit/Api/Ticket/MessageApisTest.php @@ -9,12 +9,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\MessageData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class MessageApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\Messages - * @covers \SupportPal\ApiClient\Api\Api - */ class MessageApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/Ticket/PriorityApisTest.php b/test/Unit/Api/Ticket/PriorityApisTest.php index 7532c9a2..91414791 100644 --- a/test/Unit/Api/Ticket/PriorityApisTest.php +++ b/test/Unit/Api/Ticket/PriorityApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\PriorityData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class PriorityApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\Priorities - * @covers \SupportPal\ApiClient\Api\Api - */ class PriorityApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/Ticket/StatusApisTest.php b/test/Unit/Api/Ticket/StatusApisTest.php index 4f59169d..82c5a3a5 100644 --- a/test/Unit/Api/Ticket/StatusApisTest.php +++ b/test/Unit/Api/Ticket/StatusApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\StatusData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class StatusApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\Statuses - * @covers \SupportPal\ApiClient\Api\Api - */ class StatusApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/Ticket/TicketApisTest.php b/test/Unit/Api/Ticket/TicketApisTest.php index 4e75fcca..5aeb24f1 100644 --- a/test/Unit/Api/Ticket/TicketApisTest.php +++ b/test/Unit/Api/Ticket/TicketApisTest.php @@ -11,12 +11,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\TicketData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class ApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\TicketApi - * @covers \SupportPal\ApiClient\Api\Api - */ class TicketApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/Ticket/TicketSettingsApisTest.php b/test/Unit/Api/Ticket/TicketSettingsApisTest.php index 7bfa3919..7e061b0d 100644 --- a/test/Unit/Api/Ticket/TicketSettingsApisTest.php +++ b/test/Unit/Api/Ticket/TicketSettingsApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\SettingsData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class TicketApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\Ticket - * @covers \SupportPal\ApiClient\Api\Ticket\Settings - * @covers \SupportPal\ApiClient\Api\Api - */ class TicketSettingsApisTest extends ApiTest { /** @var TicketApi */ diff --git a/test/Unit/Api/User/UserApisTest.php b/test/Unit/Api/User/UserApisTest.php index 3cf78ac6..11c803a7 100644 --- a/test/Unit/Api/User/UserApisTest.php +++ b/test/Unit/Api/User/UserApisTest.php @@ -11,12 +11,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\User\UserData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class UserApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api - * @covers \SupportPal\ApiClient\Api\UserApi - * @covers \SupportPal\ApiClient\Api\Api - */ class UserApisTest extends ApiTest { /** @var UserApi */ diff --git a/test/Unit/Api/User/UserCustomFieldApisTest.php b/test/Unit/Api/User/UserCustomFieldApisTest.php index f455e54b..4eceb18a 100644 --- a/test/Unit/Api/User/UserCustomFieldApisTest.php +++ b/test/Unit/Api/User/UserCustomFieldApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\User\UserCustomFieldData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class UserCustomFieldApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\User - * @covers \SupportPal\ApiClient\Api\User\CustomFields - * @covers \SupportPal\ApiClient\Api\Api - */ class UserCustomFieldApisTest extends ApiTest { /** @var UserApi */ diff --git a/test/Unit/Api/User/UserGroupApisTest.php b/test/Unit/Api/User/UserGroupApisTest.php index 3ecc55c3..55d8afd2 100644 --- a/test/Unit/Api/User/UserGroupApisTest.php +++ b/test/Unit/Api/User/UserGroupApisTest.php @@ -8,12 +8,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\User\GroupData; use SupportPal\ApiClient\Tests\Unit\ApiTest; -/** - * Class UserGroupApisTest - * @package SupportPal\ApiClient\Tests\Unit\Api\User - * @covers \SupportPal\ApiClient\Api\User\UserGroups - * @covers \SupportPal\ApiClient\Api\Api - */ class UserGroupApisTest extends ApiTest { /** @var UserApi */ diff --git a/test/Unit/ApiClient/Core/CoreApisTest.php b/test/Unit/ApiClient/Core/CoreApisTest.php index 3f9d371b..503c0893 100644 --- a/test/Unit/ApiClient/Core/CoreApisTest.php +++ b/test/Unit/ApiClient/Core/CoreApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class CoreApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient - * @covers \SupportPal\ApiClient\Http\Core\SettingsApis - * @covers \SupportPal\ApiClient\Http\Client - */ class CoreApisTest extends ApiClientTest { /** @var CoreClient */ diff --git a/test/Unit/ApiClient/SelfService/ArticleApisTest.php b/test/Unit/ApiClient/SelfService/ArticleApisTest.php index dc430ebf..a0b4c05f 100644 --- a/test/Unit/ApiClient/SelfService/ArticleApisTest.php +++ b/test/Unit/ApiClient/SelfService/ArticleApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class ArticleApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\Http\SelfService\ArticleApis - * @covers \SupportPal\ApiClient\Http\Client - */ class ArticleApisTest extends ApiClientTest { /** @var SelfServiceClient */ diff --git a/test/Unit/ApiClient/SelfService/CategoryApisTest.php b/test/Unit/ApiClient/SelfService/CategoryApisTest.php index c095d265..198875f4 100644 --- a/test/Unit/ApiClient/SelfService/CategoryApisTest.php +++ b/test/Unit/ApiClient/SelfService/CategoryApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class CategoryApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\Http\SelfService\CategoryApis - * @covers \SupportPal\ApiClient\Http\Client - */ class CategoryApisTest extends ApiClientTest { /** @var SelfServiceClient */ diff --git a/test/Unit/ApiClient/SelfService/CommentApisTest.php b/test/Unit/ApiClient/SelfService/CommentApisTest.php index 5763729c..7b829a6f 100644 --- a/test/Unit/ApiClient/SelfService/CommentApisTest.php +++ b/test/Unit/ApiClient/SelfService/CommentApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class CommentApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\Http\SelfService\CommentApis - * @covers \SupportPal\ApiClient\Http\Client - */ class CommentApisTest extends ApiClientTest { /** @var SelfServiceClient */ diff --git a/test/Unit/ApiClient/SelfService/SettingsApisTest.php b/test/Unit/ApiClient/SelfService/SettingsApisTest.php index 92f9f29a..38f60f94 100644 --- a/test/Unit/ApiClient/SelfService/SettingsApisTest.php +++ b/test/Unit/ApiClient/SelfService/SettingsApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class SettingsApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\Http\SelfService\SettingsApis - * @covers \SupportPal\ApiClient\Http\Client - */ class SettingsApisTest extends ApiClientTest { /** @var SelfServiceClient */ diff --git a/test/Unit/ApiClient/SelfService/TagApisTest.php b/test/Unit/ApiClient/SelfService/TagApisTest.php index 0687bfff..8f064c72 100644 --- a/test/Unit/ApiClient/SelfService/TagApisTest.php +++ b/test/Unit/ApiClient/SelfService/TagApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class TagApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\Http\SelfService\TagApis - * @covers \SupportPal\ApiClient\Http\Client - */ class TagApisTest extends ApiClientTest { /** @var SelfServiceClient */ diff --git a/test/Unit/ApiClient/SelfService/TypeApisTest.php b/test/Unit/ApiClient/SelfService/TypeApisTest.php index cac21012..e695e6e6 100644 --- a/test/Unit/ApiClient/SelfService/TypeApisTest.php +++ b/test/Unit/ApiClient/SelfService/TypeApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class TypeApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\SelfService - * @covers \SupportPal\ApiClient\Http\SelfService\TypeApis - * @covers \SupportPal\ApiClient\Http\Client - */ class TypeApisTest extends ApiClientTest { /** @var SelfServiceClient */ diff --git a/test/Unit/ApiClient/Ticket/AttachmentApisTest.php b/test/Unit/ApiClient/Ticket/AttachmentApisTest.php index d5d2f374..e92736b8 100644 --- a/test/Unit/ApiClient/Ticket/AttachmentApisTest.php +++ b/test/Unit/ApiClient/Ticket/AttachmentApisTest.php @@ -13,12 +13,6 @@ use function json_encode; use function sprintf; -/** - * Class AttachmentApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\Http\Ticket\AttachmentApis - * @covers \SupportPal\ApiClient\Http\Client - */ class AttachmentApisTest extends ApiClientTest { /** @var TicketClient */ diff --git a/test/Unit/ApiClient/Ticket/ChannelSettingsApisTest.php b/test/Unit/ApiClient/Ticket/ChannelSettingsApisTest.php index 66a7af92..46ad13ed 100644 --- a/test/Unit/ApiClient/Ticket/ChannelSettingsApisTest.php +++ b/test/Unit/ApiClient/Ticket/ChannelSettingsApisTest.php @@ -11,12 +11,6 @@ use function json_encode; use function sprintf; -/** - * Class ChannelSettingsApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\Http\Ticket\ChannelSettingsApis - * @covers \SupportPal\ApiClient\Http\Client - */ class ChannelSettingsApisTest extends ApiClientTest { /** @var TicketClient */ diff --git a/test/Unit/ApiClient/Ticket/CustomFieldApisTest.php b/test/Unit/ApiClient/Ticket/CustomFieldApisTest.php index 46f476a9..ffc90cf3 100644 --- a/test/Unit/ApiClient/Ticket/CustomFieldApisTest.php +++ b/test/Unit/ApiClient/Ticket/CustomFieldApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class DepartmentApis - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\Http\Ticket\CustomFieldApis - * @covers \SupportPal\ApiClient\Http\Client - */ class CustomFieldApisTest extends ApiClientTest { /** @var TicketClient */ diff --git a/test/Unit/ApiClient/Ticket/DepartmentApisTest.php b/test/Unit/ApiClient/Ticket/DepartmentApisTest.php index d43f2301..458d33a2 100644 --- a/test/Unit/ApiClient/Ticket/DepartmentApisTest.php +++ b/test/Unit/ApiClient/Ticket/DepartmentApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class DepartmentApis - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\Http\Ticket\DepartmentApis - * @covers \SupportPal\ApiClient\Http\Client - */ class DepartmentApisTest extends ApiClientTest { /** @var TicketClient */ diff --git a/test/Unit/ApiClient/Ticket/MessageApisTest.php b/test/Unit/ApiClient/Ticket/MessageApisTest.php index c5a19444..6e7cca6c 100644 --- a/test/Unit/ApiClient/Ticket/MessageApisTest.php +++ b/test/Unit/ApiClient/Ticket/MessageApisTest.php @@ -11,12 +11,6 @@ use function json_encode; -/** - * Class MessageApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\Http\Ticket\MessageApis - * @covers \SupportPal\ApiClient\Http\Client - */ class MessageApisTest extends ApiClientTest { /** @var TicketClient */ diff --git a/test/Unit/ApiClient/Ticket/PriorityApisTest.php b/test/Unit/ApiClient/Ticket/PriorityApisTest.php index 42f6998c..4dc88f84 100644 --- a/test/Unit/ApiClient/Ticket/PriorityApisTest.php +++ b/test/Unit/ApiClient/Ticket/PriorityApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class PriorityApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\Http\Ticket\PriorityApis - * @covers \SupportPal\ApiClient\Http\Client - */ class PriorityApisTest extends ApiClientTest { /** @var TicketClient */ diff --git a/test/Unit/ApiClient/Ticket/StatusApisTest.php b/test/Unit/ApiClient/Ticket/StatusApisTest.php index 28e80f5f..62199c92 100644 --- a/test/Unit/ApiClient/Ticket/StatusApisTest.php +++ b/test/Unit/ApiClient/Ticket/StatusApisTest.php @@ -10,12 +10,6 @@ use function json_encode; -/** - * Class StatusApisTest - * @package SupportPal\ApiClient\Tests\Unit\ApiClient\Ticket - * @covers \SupportPal\ApiClient\Http\Ticket\StatusApis - * @covers \SupportPal\ApiClient\Http\Client - */ class StatusApisTest extends ApiClientTest { /** @var TicketClient */ diff --git a/test/Unit/Cache/CacheStrategyConfiguratorTest.php b/test/Unit/Cache/CacheStrategyConfiguratorTest.php index 264dfec4..b8e1ff89 100644 --- a/test/Unit/Cache/CacheStrategyConfiguratorTest.php +++ b/test/Unit/Cache/CacheStrategyConfiguratorTest.php @@ -10,11 +10,6 @@ use function sys_get_temp_dir; -/** - * Class CacheStrategyConfiguratorTest - * @package SupportPal\ApiClient\Tests\Unit\Cache - * @covers \SupportPal\ApiClient\Cache\CacheStrategyConfigurator - */ class CacheStrategyConfiguratorTest extends TestCase { /** @var ObjectProphecy|ApiCacheMap */ diff --git a/test/Unit/Cache/CacheableRequestMatcherTest.php b/test/Unit/Cache/CacheableRequestMatcherTest.php index 25534662..17a7de33 100644 --- a/test/Unit/Cache/CacheableRequestMatcherTest.php +++ b/test/Unit/Cache/CacheableRequestMatcherTest.php @@ -9,11 +9,6 @@ use SupportPal\ApiClient\Dictionary\ApiDictionary; use SupportPal\ApiClient\Tests\PhpUnit\PhpUnitCompatibilityTrait; -/** - * Class CacheableRequestMatcherTest - * @package SupportPal\ApiClient\Tests\Unit\Cache - * @covers \SupportPal\ApiClient\Cache\CacheableRequestMatcher - */ class CacheableRequestMatcherTest extends TestCase { use PhpUnitCompatibilityTrait; diff --git a/test/Unit/Model/BaseModelTestCase.php b/test/Unit/Model/BaseModelTestCase.php index d939a604..46e9829b 100644 --- a/test/Unit/Model/BaseModelTestCase.php +++ b/test/Unit/Model/BaseModelTestCase.php @@ -6,11 +6,6 @@ use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Tests\TestCase; -/** - * Class BaseModelTestCase - * @package SupportPal\ApiClient\Tests\Unit\Model - * @covers \SupportPal\ApiClient\Model\Model - */ abstract class BaseModelTestCase extends TestCase { use StringHelper; diff --git a/test/Unit/Model/Collection/CollectionTest.php b/test/Unit/Model/CollectionTest.php similarity index 91% rename from test/Unit/Model/Collection/CollectionTest.php rename to test/Unit/Model/CollectionTest.php index 2360cef8..1061b016 100644 --- a/test/Unit/Model/Collection/CollectionTest.php +++ b/test/Unit/Model/CollectionTest.php @@ -1,10 +1,10 @@ getModelsTestData(); yield [new Collection(0, []), true]; - yield [new Collection(15, []), true]; - yield [new Collection(0, $models), false]; - yield [new Collection(0, $models), false]; + yield [ new Collection(15, []), true]; + yield [ new Collection(0, $models), false]; + yield [ new Collection(0, $models), false]; } /** diff --git a/test/Unit/Model/Core/BrandTest.php b/test/Unit/Model/Core/BrandTest.php index b55775ef..18e7688e 100644 --- a/test/Unit/Model/Core/BrandTest.php +++ b/test/Unit/Model/Core/BrandTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Core\BrandData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class BrandTest - * @package SupportPal\ApiClient\Tests\Unit\Model\Core - * @covers \SupportPal\ApiClient\Model\Core\Brand - */ class BrandTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/Core/BrandTranslationTest.php b/test/Unit/Model/Core/BrandTranslationTest.php index 33237d04..ff28f0b8 100644 --- a/test/Unit/Model/Core/BrandTranslationTest.php +++ b/test/Unit/Model/Core/BrandTranslationTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Core\BrandTranslationData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class BrandTranslationTest - * @package SupportPal\ApiClient\Tests\Unit\Model\Core - * @covers \SupportPal\ApiClient\Model\Core\BrandTranslation - */ class BrandTranslationTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/Core/UploadTest.php b/test/Unit/Model/Core/UploadTest.php index d8f0c312..e5232eef 100644 --- a/test/Unit/Model/Core/UploadTest.php +++ b/test/Unit/Model/Core/UploadTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Core\UploadData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class UploadTest - * @package SupportPal\ApiClient\Tests\Unit\Model\Core - * @covers \SupportPal\ApiClient\Model\Core\Upload - */ class UploadTest extends BaseModelTestCase { protected function getModelData(): array diff --git a/test/Unit/Model/Department/OperatorTest.php b/test/Unit/Model/Department/OperatorTest.php deleted file mode 100644 index 88c932e6..00000000 --- a/test/Unit/Model/Department/OperatorTest.php +++ /dev/null @@ -1,32 +0,0 @@ -getDataWithObjects(); - } - - /** - * @inheritDoc - */ - protected function getModel(): Model - { - return new Operator; - } -} diff --git a/test/Unit/Model/SelfService/ArticleAttachmentTest.php b/test/Unit/Model/SelfService/ArticleAttachmentTest.php index 7af5df4e..3fcab150 100644 --- a/test/Unit/Model/SelfService/ArticleAttachmentTest.php +++ b/test/Unit/Model/SelfService/ArticleAttachmentTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\ArticleAttachmentData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class ArticleAttachmentTest - * @package SupportPal\ApiClient\Tests\Unit\Model\SelfService - * @covers \SupportPal\ApiClient\Model\SelfService\ArticleAttachment - */ class ArticleAttachmentTest extends BaseModelTestCase { protected function getModelData(): array diff --git a/test/Unit/Model/SelfService/ArticleTest.php b/test/Unit/Model/SelfService/ArticleTest.php index 39dfb4a9..aea12225 100644 --- a/test/Unit/Model/SelfService/ArticleTest.php +++ b/test/Unit/Model/SelfService/ArticleTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\ArticleData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class ArticleTest - * @package SupportPal\ApiClient\Tests\Unit\Model - * @covers \SupportPal\ApiClient\Model\SelfService\Article - */ class ArticleTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/SelfService/ArticleTranslationTest.php b/test/Unit/Model/SelfService/ArticleTranslationTest.php index 8d6f636d..79c33ca2 100644 --- a/test/Unit/Model/SelfService/ArticleTranslationTest.php +++ b/test/Unit/Model/SelfService/ArticleTranslationTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\ArticleTranslationData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class ArticleTranslationTest - * @package SupportPal\ApiClient\Tests\Unit\Model\SelfService - * @covers \SupportPal\ApiClient\Model\SelfService\ArticleTranslation - */ class ArticleTranslationTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/SelfService/CategoryTest.php b/test/Unit/Model/SelfService/CategoryTest.php index be6c413a..069d82b7 100644 --- a/test/Unit/Model/SelfService/CategoryTest.php +++ b/test/Unit/Model/SelfService/CategoryTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CategoryData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class CategoryTest - * @package SupportPal\ApiClient\Tests\Unit\Model\SelfService - * @covers \SupportPal\ApiClient\Model\SelfService\Category - */ class CategoryTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/SelfService/CategoryTranslationTest.php b/test/Unit/Model/SelfService/CategoryTranslationTest.php index 5215b862..57419b5d 100644 --- a/test/Unit/Model/SelfService/CategoryTranslationTest.php +++ b/test/Unit/Model/SelfService/CategoryTranslationTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CategoryTranslationData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class CategoryTranslationTest - * @package SupportPal\ApiClient\Tests\Unit\Model\SelfService - * @covers \SupportPal\ApiClient\Model\SelfService\CategoryTranslation - */ class CategoryTranslationTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/SelfService/CommentTest.php b/test/Unit/Model/SelfService/CommentTest.php index 51e3dddc..5e1075e1 100644 --- a/test/Unit/Model/SelfService/CommentTest.php +++ b/test/Unit/Model/SelfService/CommentTest.php @@ -7,12 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class CommentTest - * @package SupportPal\ApiClient\Tests\Unit\Model - * @covers \SupportPal\ApiClient\Model\SelfService\Comment - * @covers \SupportPal\ApiClient\Model\Model - */ class CommentTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/SelfService/Request/CreateCommentTest.php b/test/Unit/Model/SelfService/Request/CreateCommentTest.php index 41a4def5..9e9493c1 100644 --- a/test/Unit/Model/SelfService/Request/CreateCommentTest.php +++ b/test/Unit/Model/SelfService/Request/CreateCommentTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\Request\CreateCommentData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class CreateCommentTest - * @package SupportPal\ApiClient\Tests\Unit\Model\SelfService\Request - * @covers \SupportPal\ApiClient\Model\SelfService\Request\CreateComment - */ class CreateCommentTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/SelfService/TagTest.php b/test/Unit/Model/SelfService/TagTest.php index 0af5a4c3..daf5c1c6 100644 --- a/test/Unit/Model/SelfService/TagTest.php +++ b/test/Unit/Model/SelfService/TagTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TagData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class TagTest - * @package SupportPal\ApiClient\Tests\Unit\Model\SelfService - * @covers \SupportPal\ApiClient\Model\SelfService\Tag - */ class TagTest extends BaseModelTestCase { protected function getModelData(): array diff --git a/test/Unit/Model/SelfService/TypeTest.php b/test/Unit/Model/SelfService/TypeTest.php index ca51808b..0ff4bc7d 100644 --- a/test/Unit/Model/SelfService/TypeTest.php +++ b/test/Unit/Model/SelfService/TypeTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TypeData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class ArticleTypeTest - * @package SupportPal\ApiClient\Tests\Unit\Model - * @covers \SupportPal\ApiClient\Model\SelfService\Type - */ class TypeTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/SelfService/TypeTranslationTest.php b/test/Unit/Model/SelfService/TypeTranslationTest.php index 1af163ce..bc99d682 100644 --- a/test/Unit/Model/SelfService/TypeTranslationTest.php +++ b/test/Unit/Model/SelfService/TypeTranslationTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\SelfService\TypeTranslationData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class TypeTranslationTest - * @package SupportPal\ApiClient\Tests\Unit\Model\SelfService - * @covers \SupportPal\ApiClient\Model\SelfService\TypeTranslation - */ class TypeTranslationTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/Shared/OptionTest.php b/test/Unit/Model/Shared/OptionTest.php index 8f4565f4..d41f10b0 100644 --- a/test/Unit/Model/Shared/OptionTest.php +++ b/test/Unit/Model/Shared/OptionTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Shared\OptionData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class OptionTest - * @package SupportPal\ApiClient\Tests\Unit\Model\Shared - * @covers \SupportPal\ApiClient\Model\Shared\Option - */ class OptionTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/Shared/OptionTranslationTest.php b/test/Unit/Model/Shared/OptionTranslationTest.php index 3afe8578..10772335 100644 --- a/test/Unit/Model/Shared/OptionTranslationTest.php +++ b/test/Unit/Model/Shared/OptionTranslationTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Shared\OptionTranslationData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class OptionTranslationTest - * @package SupportPal\ApiClient\Tests\Unit\Model\Shared - * @covers \SupportPal\ApiClient\Model\Shared\OptionTranslation - */ class OptionTranslationTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/Ticket/AttachmentTest.php b/test/Unit/Model/Ticket/AttachmentTest.php index be6a0d75..7a75a6ea 100644 --- a/test/Unit/Model/Ticket/AttachmentTest.php +++ b/test/Unit/Model/Ticket/AttachmentTest.php @@ -7,12 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\AttachmentData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class AttachmentTest - * @package SupportPal\ApiClient\Tests\Unit\Model\Ticket - * @covers \SupportPal\ApiClient\Model\Ticket\Attachment - * - */ class AttachmentTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/Ticket/ChannelSettingsTest.php b/test/Unit/Model/Ticket/ChannelSettingsTest.php index 23bf40d1..ea606884 100644 --- a/test/Unit/Model/Ticket/ChannelSettingsTest.php +++ b/test/Unit/Model/Ticket/ChannelSettingsTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\ChannelSettingsData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class ChannelSettingsTest - * @package SupportPal\ApiClient\Tests\Unit\Model\Ticket - * @covers \SupportPal\ApiClient\Model\Ticket\ChannelSettings - */ class ChannelSettingsTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/Ticket/ChannelTest.php b/test/Unit/Model/Ticket/ChannelTest.php index da89c050..96534cae 100644 --- a/test/Unit/Model/Ticket/ChannelTest.php +++ b/test/Unit/Model/Ticket/ChannelTest.php @@ -7,11 +7,6 @@ use SupportPal\ApiClient\Tests\DataFixtures\Ticket\ChannelData; use SupportPal\ApiClient\Tests\Unit\Model\BaseModelTestCase; -/** - * Class ChannelTest - * @package SupportPal\ApiClient\Tests\Unit\Model\Ticket - * @covers \SupportPal\ApiClient\Model\Ticket\Channel - */ class ChannelTest extends BaseModelTestCase { /** diff --git a/test/Unit/Model/Department/EmailTemplatesTest.php b/test/Unit/Model/Ticket/DepartmentEmailTemplatesTest.php similarity index 55% rename from test/Unit/Model/Department/EmailTemplatesTest.php rename to test/Unit/Model/Ticket/DepartmentEmailTemplatesTest.php index 73dd241c..1fa901c9 100644 --- a/test/Unit/Model/Department/EmailTemplatesTest.php +++ b/test/Unit/Model/Ticket/DepartmentEmailTemplatesTest.php @@ -1,18 +1,13 @@ Date: Wed, 29 May 2024 12:39:37 +0100 Subject: [PATCH 11/20] fix phpstan --- src/Model/Ticket/Ticket.php | 4 +- src/SupportPal.php | 2 +- test/E2E/BaseTestCase.php | 108 ++------------------------ test/Functional/SupportPalTest.php | 8 +- test/Unit/Model/BaseModelTestCase.php | 3 - 5 files changed, 12 insertions(+), 113 deletions(-) diff --git a/src/Model/Ticket/Ticket.php b/src/Model/Ticket/Ticket.php index e510b312..d31622cc 100644 --- a/src/Model/Ticket/Ticket.php +++ b/src/Model/Ticket/Ticket.php @@ -55,8 +55,8 @@ class Ticket extends Model 'department' => Department::class, 'tags' => 'array:' . Tag::class, 'user' => User::class, - 'watching' => 'array:' . Operator::class, - 'assigned' => 'array:' . Operator::class, + 'watching' => 'array:' . User::class, + 'assigned' => 'array:' . User::class, 'brand' => Brand::class, 'last_reply' => Message::class, 'slaplan' => SlaPlan::class, diff --git a/src/SupportPal.php b/src/SupportPal.php index 66f8a95c..027709ea 100644 --- a/src/SupportPal.php +++ b/src/SupportPal.php @@ -122,7 +122,7 @@ public function getUserApi(): UserApi /** * @throws Exception */ - public function getRequestFactory(): Request + public function getRequest(): Request { /** @var Request $request */ $request = $this->containerBuilder->get(Request::class); diff --git a/test/E2E/BaseTestCase.php b/test/E2E/BaseTestCase.php index b605e308..ceefbabd 100644 --- a/test/E2E/BaseTestCase.php +++ b/test/E2E/BaseTestCase.php @@ -10,26 +10,17 @@ use SupportPal\ApiClient\Api\UserApi; use SupportPal\ApiClient\Config\ApiContext; use SupportPal\ApiClient\Exception\HttpResponseException; -use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\Shared\Settings; use SupportPal\ApiClient\SupportPal; use SupportPal\ApiClient\Tests\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use TypeError; -use function current; -use function get_class; -use function get_class_methods; use function getenv; -use function gettype; use function intval; -use function is_array; use function json_decode; -use function method_exists; use function sprintf; -use function substr; use function var_export; abstract class BaseTestCase extends TestCase @@ -38,11 +29,9 @@ abstract class BaseTestCase extends TestCase const DEFAULT_LIMIT = self::BATCH_SIZE * 2; - /** @var int */ - private $modelsTestLimit; + private int $modelsTestLimit; - /** @var SupportPal */ - private $supportPal; + private SupportPal $supportPal; public function setUp(): void { @@ -90,20 +79,14 @@ public function testGetAll(string $endpoint, string $apiCall): void $batch = $this->getApi()->{$apiCall}($parameters); $request = $this ->getSupportPal() - ->getRequestFactory() + ->getRequest() ->create('GET', $endpoint, [], [], $parameters); $response = $this->getSupportPal()->sendRequest($request); $modelsArray = json_decode((string) $response->getBody(), true)['data']; foreach ($batch->getModels() as $offset => $value) { - $missingMethods = []; - $this->getMissingFields($value, $modelsArray[$offset], $missingMethods); try { - self::assertEmpty($missingMethods, var_export($missingMethods, true)); - $callExceptions = []; - $this->callAllGetters($value, $callExceptions); - self::assertEmpty($callExceptions, var_export($callExceptions, true)); $this->assertArrayEqualsObjectFields($value, $modelsArray[$offset]); } catch (ExpectationFailedException $exception) { throw new ExpectationFailedException( @@ -123,7 +106,7 @@ protected function settingsTestCase(string $endpoint, string $apiCall): void $model = $this->getApi()->{$apiCall}(); $request = $this ->getSupportPal() - ->getRequestFactory() + ->getRequest() ->create('GET', $endpoint); $response = $this->getSupportPal()->sendRequest($request); $responseArray = json_decode((string) $response->getBody(), true)['data']; @@ -148,18 +131,12 @@ public function testGetOneById(string $endpoint, string $apiCall): void $model = $this->getApi()->{$apiCall}($iteration); $request = $this ->getSupportPal() - ->getRequestFactory() + ->getRequest() ->create('GET', $endpoint . '/' . $iteration); $response = $this->getSupportPal()->sendRequest($request); $responseArray = json_decode((string) $response->getBody(), true)['data']; - $missingMethods = []; - $this->getMissingFields($model, $responseArray, $missingMethods); - self::assertEmpty($missingMethods, var_export($missingMethods, true)); $this->assertArrayEqualsObjectFields($model, $responseArray); - $callExceptions = []; - $this->callAllGetters($model, $callExceptions); - self::assertEmpty($callExceptions, var_export($callExceptions, true)); ++$iteration; } catch (HttpResponseException $exception) { self::assertStringContainsString('given ID was not found', $exception->getMessage()); @@ -174,81 +151,6 @@ public function testGetOneById(string $endpoint, string $apiCall): void } } - /** - * @param Model $model - * @param array $array - * @param string[] $output - */ - private function getMissingFields(Model $model, array $array, array &$output): void - { - foreach ($array as $key => $value) { - $methodName = 'get' . $this->snakeCaseToPascalCase($key); - if (! method_exists($model, $methodName)) { - $className = get_class($model); - if (! isset($output[$className])) { - $output[$className] = []; - } - - if (! isset($output[$className][$methodName])) { - $output[$className][$methodName] = []; - } - - $output[$className][$methodName][] = gettype($value); - - continue; - } - - $methodValue = $model->{$methodName}(); - if (is_array($methodValue) && current($methodValue) instanceof Model) { - foreach ($methodValue as $offset => $subModel) { - $this->getMissingFields($subModel, $array[$key][$offset], $output); - } - - continue; - } - - if (! ($methodValue instanceof Model)) { - continue; - } - - $this->getMissingFields($methodValue, $array[$key], $output); - } - } - - /** - * @param Model $model - * @param string[] $exceptions - */ - private function callAllGetters(Model $model, array &$exceptions): void - { - foreach (get_class_methods(get_class($model)) as $method) { - if (substr($method, 0, 3) !== 'get') { - continue; - } - - try { - $value = $model->{$method}(); - } catch (TypeError $exception) { - $exceptions[] = $exception->getMessage(); - continue; - } - - if (is_array($value) && current($value) instanceof Model) { - foreach ($value as $subModel) { - $this->callAllGetters($subModel, $exceptions); - } - - continue; - } - - if (! ($value instanceof Model)) { - continue; - } - - $this->callAllGetters($value, $exceptions); - } - } - /** * @return iterable */ diff --git a/test/Functional/SupportPalTest.php b/test/Functional/SupportPalTest.php index 5c040080..651bd92d 100644 --- a/test/Functional/SupportPalTest.php +++ b/test/Functional/SupportPalTest.php @@ -19,7 +19,7 @@ class SupportPalTest extends ContainerAwareBaseTestCase { public function testGetRequestFactory(): void { - self::assertInstanceOf(Request::class, $this->getSupportPal()->getRequestFactory()); + self::assertInstanceOf(Request::class, $this->getSupportPal()->getRequest()); } public function testSendRequestSuccessful(): void @@ -30,7 +30,7 @@ public function testSendRequestSuccessful(): void (string) json_encode((new CommentData)->getResponse()) ); $this->appendRequestResponse($response); - $request = $this->getSupportPal()->getRequestFactory()->create('GET', 'test_endpoint'); + $request = $this->getSupportPal()->getRequest()->create('GET', 'test_endpoint'); self::assertSame($response, $this->getSupportPal()->sendRequest($request)); } @@ -43,7 +43,7 @@ public function testSendRequestUnSuccessful(): void (string) json_encode($this->genericErrorResponse) ); $this->appendRequestResponse($response); - $request = $this->getSupportPal()->getRequestFactory()->create('GET', 'test_endpoint'); + $request = $this->getSupportPal()->getRequest()->create('GET', 'test_endpoint'); $this->getSupportPal()->sendRequest($request); } @@ -54,7 +54,7 @@ public function testSendRequestUnSuccessful(): void */ public function testEscapePercentApiToken(string $apiToken): void { - $request = (new SupportPal(new ApiContext('localhost', $apiToken)))->getRequestFactory()->create('GET', 'test'); + $request = (new SupportPal(new ApiContext('localhost', $apiToken)))->getRequest()->create('GET', 'test'); self::assertSame('Basic ' . base64_encode($apiToken . ':X'), current($request->getHeader('Authorization'))); } diff --git a/test/Unit/Model/BaseModelTestCase.php b/test/Unit/Model/BaseModelTestCase.php index 46e9829b..11cff14f 100644 --- a/test/Unit/Model/BaseModelTestCase.php +++ b/test/Unit/Model/BaseModelTestCase.php @@ -2,14 +2,11 @@ namespace SupportPal\ApiClient\Tests\Unit\Model; -use SupportPal\ApiClient\Helper\StringHelper; use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Tests\TestCase; abstract class BaseModelTestCase extends TestCase { - use StringHelper; - public function testCreateModel():void { $model = $this->getModel(); From 38ab704d9cae3b39d65c93908d9ae1b7103f8cb6 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 12:48:20 +0100 Subject: [PATCH 12/20] fix phpcs --- src/Model/Ticket/Ticket.php | 1 - test/E2E/BaseTestCase.php | 1 - 2 files changed, 2 deletions(-) diff --git a/src/Model/Ticket/Ticket.php b/src/Model/Ticket/Ticket.php index d31622cc..687b28a8 100644 --- a/src/Model/Ticket/Ticket.php +++ b/src/Model/Ticket/Ticket.php @@ -3,7 +3,6 @@ namespace SupportPal\ApiClient\Model\Ticket; use SupportPal\ApiClient\Model\Core\Brand; -use SupportPal\ApiClient\Model\Department\Operator; use SupportPal\ApiClient\Model\Model; use SupportPal\ApiClient\Model\User\User; diff --git a/test/E2E/BaseTestCase.php b/test/E2E/BaseTestCase.php index ceefbabd..5374a060 100644 --- a/test/E2E/BaseTestCase.php +++ b/test/E2E/BaseTestCase.php @@ -21,7 +21,6 @@ use function intval; use function json_decode; use function sprintf; -use function var_export; abstract class BaseTestCase extends TestCase { From ea23dafcb17181548b311f55174268b9eb576551 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 12:52:17 +0100 Subject: [PATCH 13/20] fix --- src/Model/Ticket/Ticket.php | 4 +--- test/DataFixtures/Ticket/OperatorData.php | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/src/Model/Ticket/Ticket.php b/src/Model/Ticket/Ticket.php index 687b28a8..e6ebfb93 100644 --- a/src/Model/Ticket/Ticket.php +++ b/src/Model/Ticket/Ticket.php @@ -9,9 +9,7 @@ class Ticket extends Model { /** - * The attributes that should be cast to native types. - * - * @var array + * @var array */ protected $casts = [ 'id' => 'int', diff --git a/test/DataFixtures/Ticket/OperatorData.php b/test/DataFixtures/Ticket/OperatorData.php index 53d27091..80e636a9 100644 --- a/test/DataFixtures/Ticket/OperatorData.php +++ b/test/DataFixtures/Ticket/OperatorData.php @@ -3,7 +3,7 @@ namespace SupportPal\ApiClient\Tests\DataFixtures\Ticket; use SupportPal\ApiClient\Exception\InvalidArgumentException; -use SupportPal\ApiClient\Model\Department\Operator; +use SupportPal\ApiClient\Model\User\User; use SupportPal\ApiClient\Tests\DataFixtures\BaseModelData; use SupportPal\ApiClient\Tests\DataFixtures\User\BaseUserData; use SupportPal\ApiClient\Tests\DataFixtures\User\GroupData; @@ -11,7 +11,7 @@ class OperatorData extends BaseModelData { public const DATA = BaseUserData::DATA + [ - 'groups' => [GroupData::DATA,], + 'groups' => [GroupData::DATA], 'pivot' => [ 'department_id' => 1, 'user_id' => 1 @@ -35,6 +35,6 @@ public function getDataWithObjects(): array */ public function getModel(): string { - return Operator::class; + return User::class; } } From ecb784d8cd859d4c3942c95638f6226fc7cab8b7 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 12:54:17 +0100 Subject: [PATCH 14/20] fix --- src/Model/Ticket/Ticket.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Model/Ticket/Ticket.php b/src/Model/Ticket/Ticket.php index e6ebfb93..351c2ceb 100644 --- a/src/Model/Ticket/Ticket.php +++ b/src/Model/Ticket/Ticket.php @@ -8,9 +8,7 @@ class Ticket extends Model { - /** - * @var array - */ + /** @var array */ protected $casts = [ 'id' => 'int', 'number' => 'string', From 034616dbe8149a544c10abe5087c649e3f09d1ce Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 18:37:31 +0100 Subject: [PATCH 15/20] switch to supportpal/eloquent-models --- composer.json | 2 +- composer.lock | 109 +++++++++--------- src/Model/Core/Brand.php | 2 +- src/Model/Core/BrandTranslation.php | 2 +- src/Model/Core/Upload.php | 2 +- src/Model/Model.php | 2 +- src/Model/SelfService/Article.php | 2 +- src/Model/SelfService/ArticleAttachment.php | 2 +- src/Model/SelfService/ArticleTranslation.php | 2 +- src/Model/SelfService/Category.php | 2 +- src/Model/SelfService/CategoryTranslation.php | 2 +- src/Model/SelfService/Comment.php | 2 +- .../SelfService/Request/CreateComment.php | 2 +- src/Model/SelfService/Tag.php | 2 +- src/Model/SelfService/TagTranslation.php | 2 +- src/Model/SelfService/Type.php | 2 +- src/Model/SelfService/TypeTranslation.php | 2 +- src/Model/Shared/CustomField.php | 2 +- src/Model/Shared/Option.php | 2 +- src/Model/Shared/OptionTranslation.php | 2 +- src/Model/Ticket/Attachment.php | 2 +- src/Model/Ticket/Channel.php | 2 +- src/Model/Ticket/ChannelSettings.php | 2 +- src/Model/Ticket/Department.php | 2 +- src/Model/Ticket/DepartmentEmail.php | 2 +- src/Model/Ticket/DepartmentEmailTemplates.php | 2 +- src/Model/Ticket/DepartmentTranslation.php | 2 +- src/Model/Ticket/Extra.php | 2 +- src/Model/Ticket/Message.php | 2 +- src/Model/Ticket/Priority.php | 2 +- src/Model/Ticket/PriorityTranslation.php | 2 +- src/Model/Ticket/Request/CreateMessage.php | 2 +- src/Model/Ticket/Request/CreateTicket.php | 2 +- src/Model/Ticket/SlaPlan.php | 2 +- src/Model/Ticket/SlaPlanTranslation.php | 2 +- src/Model/Ticket/Status.php | 2 +- src/Model/Ticket/StatusTranslation.php | 2 +- src/Model/Ticket/Tag.php | 2 +- src/Model/Ticket/TagTranslation.php | 2 +- src/Model/Ticket/Ticket.php | 2 +- .../Ticket/TicketCustomFieldTranslation.php | 2 +- src/Model/User/Domain.php | 2 +- src/Model/User/Group.php | 2 +- src/Model/User/GroupTranslation.php | 2 +- src/Model/User/Organisation.php | 2 +- src/Model/User/Request/CreateUser.php | 2 +- src/Model/User/User.php | 2 +- src/Model/User/UserCustomFieldTranslation.php | 2 +- test/Unit/Api/Ticket/TicketApisTest.php | 3 + test/Unit/Api/User/UserApisTest.php | 3 + 50 files changed, 110 insertions(+), 99 deletions(-) diff --git a/composer.json b/composer.json index dceba6cc..6be99234 100644 --- a/composer.json +++ b/composer.json @@ -13,10 +13,10 @@ "php": "^8.1", "doctrine/cache": "^1.10", "guzzlehttp/guzzle": "^7.0", - "jenssegers/model": "^1.5", "kevinrob/guzzle-cache-middleware": "^5.0", "phpdocumentor/reflection-docblock": "^5.2", "psr/http-message": "^1.0", + "supportpal/eloquent-model": "^1.0", "symfony/config": "^6.2|^7.0", "symfony/dependency-injection": "^6.2|^7.0", "symfony/yaml": "^6.2|^7.0" diff --git a/composer.lock b/composer.lock index 4fec7d19..aded03ca 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "287eb9284e4a97779cf04d319af71322", + "content-hash": "ef6f56a74b5b5e004ee87c6fc4bd4127", "packages": [ { "name": "carbonphp/carbon-doctrine-types", @@ -906,57 +906,6 @@ }, "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", @@ -1726,6 +1675,62 @@ }, "time": "2019-03-08T08:55:37+00:00" }, + { + "name": "supportpal/eloquent-model", + "version": "v1.0.0", + "source": { + "type": "git", + "url": "https://github.com/supportpal/eloquent-model.git", + "reference": "3280ac3f4e83bdbfaabe867263242609278e0fc4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/supportpal/eloquent-model/zipball/3280ac3f4e83bdbfaabe867263242609278e0fc4", + "reference": "3280ac3f4e83bdbfaabe867263242609278e0fc4", + "shasum": "" + }, + "require": { + "illuminate/contracts": "^10.0|^11.0", + "illuminate/support": "^10.0|^11.0", + "php": "^8.1" + }, + "require-dev": { + "php-coveralls/php-coveralls": "^2.7.0", + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^10.0", + "slevomat/coding-standard": "^8.15", + "squizlabs/php_codesniffer": "^3.5", + "supportpal/coding-standard": "^0.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "Tests\\": "tests/", + "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/supportpal/eloquent-model", + "keywords": [ + "eloquent", + "laravel", + "model" + ], + "support": { + "source": "https://github.com/supportpal/eloquent-model/tree/v1.0.0" + }, + "time": "2024-05-29T17:16:56+00:00" + }, { "name": "symfony/clock", "version": "v7.0.7", diff --git a/src/Model/Core/Brand.php b/src/Model/Core/Brand.php index 11813391..05d36566 100644 --- a/src/Model/Core/Brand.php +++ b/src/Model/Core/Brand.php @@ -7,7 +7,7 @@ class Brand extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'enabled' => 'int', diff --git a/src/Model/Core/BrandTranslation.php b/src/Model/Core/BrandTranslation.php index 5169367d..6c7a84cd 100644 --- a/src/Model/Core/BrandTranslation.php +++ b/src/Model/Core/BrandTranslation.php @@ -7,7 +7,7 @@ class BrandTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'brand_id' => 'int', diff --git a/src/Model/Core/Upload.php b/src/Model/Core/Upload.php index 0205b976..ff8305a3 100644 --- a/src/Model/Core/Upload.php +++ b/src/Model/Core/Upload.php @@ -7,7 +7,7 @@ class Upload extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'hash' => 'string', 'filename' => 'string', 'folder' => 'string', diff --git a/src/Model/Model.php b/src/Model/Model.php index a15c6a1c..fc6b1bc5 100644 --- a/src/Model/Model.php +++ b/src/Model/Model.php @@ -5,5 +5,5 @@ abstract class Model extends \Jenssegers\Model\Model { /** @var string[] */ - protected $guarded = []; + protected array $guarded = []; } diff --git a/src/Model/SelfService/Article.php b/src/Model/SelfService/Article.php index 1600b092..58849f7a 100644 --- a/src/Model/SelfService/Article.php +++ b/src/Model/SelfService/Article.php @@ -7,7 +7,7 @@ class Article extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'author_id' => 'int', 'title' => 'string', diff --git a/src/Model/SelfService/ArticleAttachment.php b/src/Model/SelfService/ArticleAttachment.php index 85642d17..80b3f77d 100644 --- a/src/Model/SelfService/ArticleAttachment.php +++ b/src/Model/SelfService/ArticleAttachment.php @@ -8,7 +8,7 @@ class ArticleAttachment extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'upload_hash' => 'string', 'article_id' => 'int', 'locale' => 'string', diff --git a/src/Model/SelfService/ArticleTranslation.php b/src/Model/SelfService/ArticleTranslation.php index 5d233de1..55425775 100644 --- a/src/Model/SelfService/ArticleTranslation.php +++ b/src/Model/SelfService/ArticleTranslation.php @@ -7,7 +7,7 @@ class ArticleTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'article_id' => 'int', 'title' => 'string', 'slug' => 'string', diff --git a/src/Model/SelfService/Category.php b/src/Model/SelfService/Category.php index 27e8a522..da521448 100644 --- a/src/Model/SelfService/Category.php +++ b/src/Model/SelfService/Category.php @@ -7,7 +7,7 @@ class Category extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'type_id' => 'int', 'parent_id' => 'int', diff --git a/src/Model/SelfService/CategoryTranslation.php b/src/Model/SelfService/CategoryTranslation.php index efed7a0d..6b407009 100644 --- a/src/Model/SelfService/CategoryTranslation.php +++ b/src/Model/SelfService/CategoryTranslation.php @@ -7,7 +7,7 @@ class CategoryTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'category_id' => 'int', 'name' => 'string', 'slug' => 'string', diff --git a/src/Model/SelfService/Comment.php b/src/Model/SelfService/Comment.php index 946bfe09..6b3832e4 100644 --- a/src/Model/SelfService/Comment.php +++ b/src/Model/SelfService/Comment.php @@ -8,7 +8,7 @@ class Comment extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'article_id' => 'int', 'type_id' => 'int', diff --git a/src/Model/SelfService/Request/CreateComment.php b/src/Model/SelfService/Request/CreateComment.php index af454fc3..59035063 100644 --- a/src/Model/SelfService/Request/CreateComment.php +++ b/src/Model/SelfService/Request/CreateComment.php @@ -7,7 +7,7 @@ class CreateComment extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'article_id' => 'int', 'type_id' => 'int', 'parent_id' => 'int', diff --git a/src/Model/SelfService/Tag.php b/src/Model/SelfService/Tag.php index 1ca9c857..9d217fa3 100644 --- a/src/Model/SelfService/Tag.php +++ b/src/Model/SelfService/Tag.php @@ -7,7 +7,7 @@ class Tag extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'slug' => 'string', diff --git a/src/Model/SelfService/TagTranslation.php b/src/Model/SelfService/TagTranslation.php index d89767ec..001a8a74 100644 --- a/src/Model/SelfService/TagTranslation.php +++ b/src/Model/SelfService/TagTranslation.php @@ -7,7 +7,7 @@ class TagTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'tag_id' => 'int', 'name' => 'string', diff --git a/src/Model/SelfService/Type.php b/src/Model/SelfService/Type.php index 76f3ad9a..9f3e2e0c 100644 --- a/src/Model/SelfService/Type.php +++ b/src/Model/SelfService/Type.php @@ -8,7 +8,7 @@ class Type extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'brand_id' => 'int', 'name' => 'string', diff --git a/src/Model/SelfService/TypeTranslation.php b/src/Model/SelfService/TypeTranslation.php index a844121b..16f87e60 100644 --- a/src/Model/SelfService/TypeTranslation.php +++ b/src/Model/SelfService/TypeTranslation.php @@ -7,7 +7,7 @@ class TypeTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'type_id' => 'int', 'name' => 'string', diff --git a/src/Model/Shared/CustomField.php b/src/Model/Shared/CustomField.php index 6ae23e62..7d7e7ba6 100644 --- a/src/Model/Shared/CustomField.php +++ b/src/Model/Shared/CustomField.php @@ -30,7 +30,7 @@ abstract class CustomField extends Model public const TYPE_RATING = 10; /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'description' => 'string', diff --git a/src/Model/Shared/Option.php b/src/Model/Shared/Option.php index 54fa9783..8244ee15 100644 --- a/src/Model/Shared/Option.php +++ b/src/Model/Shared/Option.php @@ -7,7 +7,7 @@ class Option extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'field_id' => 'int', 'order' => 'int', diff --git a/src/Model/Shared/OptionTranslation.php b/src/Model/Shared/OptionTranslation.php index a49ac24a..e766d1f1 100644 --- a/src/Model/Shared/OptionTranslation.php +++ b/src/Model/Shared/OptionTranslation.php @@ -7,7 +7,7 @@ class OptionTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'value' => 'string', ]; diff --git a/src/Model/Ticket/Attachment.php b/src/Model/Ticket/Attachment.php index 0e7705b6..ef779744 100644 --- a/src/Model/Ticket/Attachment.php +++ b/src/Model/Ticket/Attachment.php @@ -8,7 +8,7 @@ class Attachment extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'upload_hash' => 'string', 'ticket_id' => 'int', diff --git a/src/Model/Ticket/Channel.php b/src/Model/Ticket/Channel.php index 2d1b81ed..83a6b331 100644 --- a/src/Model/Ticket/Channel.php +++ b/src/Model/Ticket/Channel.php @@ -7,7 +7,7 @@ class Channel extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'enabled' => 'int', diff --git a/src/Model/Ticket/ChannelSettings.php b/src/Model/Ticket/ChannelSettings.php index 42f0d103..55b4b60b 100644 --- a/src/Model/Ticket/ChannelSettings.php +++ b/src/Model/Ticket/ChannelSettings.php @@ -7,7 +7,7 @@ class ChannelSettings extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'unauthenticated_users' => 'string', 'show_captcha' => 'string', 'append_ip_address' => 'string', diff --git a/src/Model/Ticket/Department.php b/src/Model/Ticket/Department.php index 58ce2050..6fce6200 100644 --- a/src/Model/Ticket/Department.php +++ b/src/Model/Ticket/Department.php @@ -9,7 +9,7 @@ class Department extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'description' => 'string', diff --git a/src/Model/Ticket/DepartmentEmail.php b/src/Model/Ticket/DepartmentEmail.php index dc3cc71e..ecf18f24 100644 --- a/src/Model/Ticket/DepartmentEmail.php +++ b/src/Model/Ticket/DepartmentEmail.php @@ -7,7 +7,7 @@ class DepartmentEmail extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'department_id' => 'int', 'brand_id' => 'int', 'address' => 'string', diff --git a/src/Model/Ticket/DepartmentEmailTemplates.php b/src/Model/Ticket/DepartmentEmailTemplates.php index d82d6789..d4f5fb10 100644 --- a/src/Model/Ticket/DepartmentEmailTemplates.php +++ b/src/Model/Ticket/DepartmentEmailTemplates.php @@ -7,7 +7,7 @@ class DepartmentEmailTemplates extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'operator_department_changed' => 'int', 'operator_internal_opened' => 'int', 'user_ticket_locked' => 'int', diff --git a/src/Model/Ticket/DepartmentTranslation.php b/src/Model/Ticket/DepartmentTranslation.php index 8ce2aae5..6563db44 100644 --- a/src/Model/Ticket/DepartmentTranslation.php +++ b/src/Model/Ticket/DepartmentTranslation.php @@ -7,7 +7,7 @@ class DepartmentTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'description' => 'string', diff --git a/src/Model/Ticket/Extra.php b/src/Model/Ticket/Extra.php index 85632898..f2e33cc3 100644 --- a/src/Model/Ticket/Extra.php +++ b/src/Model/Ticket/Extra.php @@ -7,7 +7,7 @@ class Extra extends Model { /** @var array */ - protected $casts = [ + protected array $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 d812f058..0e8f7878 100644 --- a/src/Model/Ticket/Message.php +++ b/src/Model/Ticket/Message.php @@ -8,7 +8,7 @@ class Message extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'ticket_id' => 'int', 'channel_id' => 'int', diff --git a/src/Model/Ticket/Priority.php b/src/Model/Ticket/Priority.php index 5e32fb7d..6abb467b 100644 --- a/src/Model/Ticket/Priority.php +++ b/src/Model/Ticket/Priority.php @@ -7,7 +7,7 @@ class Priority extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'colour' => 'string', diff --git a/src/Model/Ticket/PriorityTranslation.php b/src/Model/Ticket/PriorityTranslation.php index ed340e4d..2a93df3e 100644 --- a/src/Model/Ticket/PriorityTranslation.php +++ b/src/Model/Ticket/PriorityTranslation.php @@ -7,7 +7,7 @@ class PriorityTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $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 ef01d591..bf8fab5f 100644 --- a/src/Model/Ticket/Request/CreateMessage.php +++ b/src/Model/Ticket/Request/CreateMessage.php @@ -7,7 +7,7 @@ class CreateMessage extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'ticket_id' => 'int', 'user_id' => 'int', 'user_ip_address' => 'string', diff --git a/src/Model/Ticket/Request/CreateTicket.php b/src/Model/Ticket/Request/CreateTicket.php index b7a610e4..8b7844ed 100644 --- a/src/Model/Ticket/Request/CreateTicket.php +++ b/src/Model/Ticket/Request/CreateTicket.php @@ -7,7 +7,7 @@ class CreateTicket extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'user' => 'int', 'on_behalf_of' => 'int', 'user_firstname' => 'string', diff --git a/src/Model/Ticket/SlaPlan.php b/src/Model/Ticket/SlaPlan.php index 0a0e68bd..5f82de75 100644 --- a/src/Model/Ticket/SlaPlan.php +++ b/src/Model/Ticket/SlaPlan.php @@ -7,7 +7,7 @@ class SlaPlan extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'description' => 'string', diff --git a/src/Model/Ticket/SlaPlanTranslation.php b/src/Model/Ticket/SlaPlanTranslation.php index ec77957f..4e150492 100644 --- a/src/Model/Ticket/SlaPlanTranslation.php +++ b/src/Model/Ticket/SlaPlanTranslation.php @@ -7,7 +7,7 @@ class SlaPlanTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'sla_plan_id' => 'int', 'name' => 'string', diff --git a/src/Model/Ticket/Status.php b/src/Model/Ticket/Status.php index d223f2c1..12fc6451 100644 --- a/src/Model/Ticket/Status.php +++ b/src/Model/Ticket/Status.php @@ -11,7 +11,7 @@ class Status extends Model * * @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'colour' => 'string', diff --git a/src/Model/Ticket/StatusTranslation.php b/src/Model/Ticket/StatusTranslation.php index 93bc03e1..0b5a8607 100644 --- a/src/Model/Ticket/StatusTranslation.php +++ b/src/Model/Ticket/StatusTranslation.php @@ -7,7 +7,7 @@ class StatusTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'status_id' => 'int', 'name' => 'string', diff --git a/src/Model/Ticket/Tag.php b/src/Model/Ticket/Tag.php index 546eb52a..9db5a841 100644 --- a/src/Model/Ticket/Tag.php +++ b/src/Model/Ticket/Tag.php @@ -7,7 +7,7 @@ class Tag extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'colour' => 'string', diff --git a/src/Model/Ticket/TagTranslation.php b/src/Model/Ticket/TagTranslation.php index 67ebc64a..634b80b7 100644 --- a/src/Model/Ticket/TagTranslation.php +++ b/src/Model/Ticket/TagTranslation.php @@ -7,7 +7,7 @@ class TagTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'tag_id' => 'int', 'name' => 'string', diff --git a/src/Model/Ticket/Ticket.php b/src/Model/Ticket/Ticket.php index 351c2ceb..b905aea6 100644 --- a/src/Model/Ticket/Ticket.php +++ b/src/Model/Ticket/Ticket.php @@ -9,7 +9,7 @@ class Ticket extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'number' => 'string', 'department_id' => 'int', diff --git a/src/Model/Ticket/TicketCustomFieldTranslation.php b/src/Model/Ticket/TicketCustomFieldTranslation.php index 1b0fc38b..eb0ab546 100644 --- a/src/Model/Ticket/TicketCustomFieldTranslation.php +++ b/src/Model/Ticket/TicketCustomFieldTranslation.php @@ -7,7 +7,7 @@ class TicketCustomFieldTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'ticket_custom_field_id' => 'int', 'name' => 'string', diff --git a/src/Model/User/Domain.php b/src/Model/User/Domain.php index 703a2bc6..d14b4cba 100644 --- a/src/Model/User/Domain.php +++ b/src/Model/User/Domain.php @@ -7,7 +7,7 @@ class Domain extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'organisation_id' => 'int', 'domain' => 'string', diff --git a/src/Model/User/Group.php b/src/Model/User/Group.php index 389cdf77..6066ef3e 100644 --- a/src/Model/User/Group.php +++ b/src/Model/User/Group.php @@ -7,7 +7,7 @@ class Group extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'name' => 'string', 'description' => 'string', diff --git a/src/Model/User/GroupTranslation.php b/src/Model/User/GroupTranslation.php index abfbe7a2..ae55defe 100644 --- a/src/Model/User/GroupTranslation.php +++ b/src/Model/User/GroupTranslation.php @@ -7,7 +7,7 @@ class GroupTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'user_group_id' => 'int', 'name' => 'string', diff --git a/src/Model/User/Organisation.php b/src/Model/User/Organisation.php index fb523532..e0745fbb 100644 --- a/src/Model/User/Organisation.php +++ b/src/Model/User/Organisation.php @@ -7,7 +7,7 @@ class Organisation extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'brand_id' => 'int', 'owner_id' => 'int', diff --git a/src/Model/User/Request/CreateUser.php b/src/Model/User/Request/CreateUser.php index 7a302daf..3740eddf 100644 --- a/src/Model/User/Request/CreateUser.php +++ b/src/Model/User/Request/CreateUser.php @@ -7,7 +7,7 @@ class CreateUser extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'brand_id' => 'int', 'firstname' => 'string', 'lastname' => 'string', diff --git a/src/Model/User/User.php b/src/Model/User/User.php index d7433580..b22076ed 100644 --- a/src/Model/User/User.php +++ b/src/Model/User/User.php @@ -7,7 +7,7 @@ class User extends Model { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'brand_id' => 'int', 'role' => 'int', diff --git a/src/Model/User/UserCustomFieldTranslation.php b/src/Model/User/UserCustomFieldTranslation.php index 03468257..45705ee6 100644 --- a/src/Model/User/UserCustomFieldTranslation.php +++ b/src/Model/User/UserCustomFieldTranslation.php @@ -7,7 +7,7 @@ class UserCustomFieldTranslation extends Translation { /** @var array */ - protected $casts = [ + protected array $casts = [ 'id' => 'int', 'user_custom_field_id' => 'int', 'name' => 'string', diff --git a/test/Unit/Api/Ticket/TicketApisTest.php b/test/Unit/Api/Ticket/TicketApisTest.php index 5aeb24f1..e371be9a 100644 --- a/test/Unit/Api/Ticket/TicketApisTest.php +++ b/test/Unit/Api/Ticket/TicketApisTest.php @@ -93,6 +93,9 @@ public function testPutTicketWithoutIdentifier(): void { $ticketData = new TicketData; $input = $this->prophesize(Ticket::class); + $input->getAttribute('relations')->willReturn(null); + $input->hasGetMutator('id')->willReturn(false); + $input->hasGetMutator('relations')->willReturn(false); 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 11c803a7..ac7a267d 100644 --- a/test/Unit/Api/User/UserApisTest.php +++ b/test/Unit/Api/User/UserApisTest.php @@ -92,6 +92,9 @@ public function testPutUserWithoutIdentifier(): void { $userData = new UserData; $input = $this->prophesize(User::class); + $input->getAttribute('relations')->willReturn(null); + $input->hasGetMutator('id')->willReturn(false); + $input->hasGetMutator('relations')->willReturn(false); self::expectException(MissingIdentifierException::class); /** @var User $user */ $user = $input->reveal(); From e6e676b0aa32297d86a7def015631a4aa05a6ecd Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 18:37:50 +0100 Subject: [PATCH 16/20] reduce code coverage requirement --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 176506b1..b3066960 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: run: ci/test.sh env: TESTSUITE: unit - MINCOVERAGE: ${{ matrix.php == '8.3' && '90' || '0' }} + MINCOVERAGE: ${{ matrix.php == '8.3' && '85' || '0' }} - name: Execute Functional tests run: ci/test.sh From f386c943923dfe03e3974e4e8ec17bb48a50d254 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Wed, 29 May 2024 18:48:25 +0100 Subject: [PATCH 17/20] increase code coverage requirement for functional and integration test suites --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b3066960..e910ff68 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -45,13 +45,13 @@ jobs: run: ci/test.sh env: TESTSUITE: functional - MINCOVERAGE: ${{ matrix.php == '8.3' && '70' || '0' }} + MINCOVERAGE: ${{ matrix.php == '8.3' && '80' || '0' }} - name: Execute Integration tests run: ci/test.sh env: TESTSUITE: integration - MINCOVERAGE: ${{ matrix.php == '8.3' && '70' || '0' }} + MINCOVERAGE: ${{ matrix.php == '8.3' && '80' || '0' }} - name: Execute Cache tests run: ./vendor/bin/phpunit --testsuite=cache --stop-on-fail From eedaaccc46e43e8e7bba431312d1d2dcd9182a6f Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Thu, 30 May 2024 11:40:29 +0100 Subject: [PATCH 18/20] fix e2e tests --- test/E2E/BaseTestCase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/E2E/BaseTestCase.php b/test/E2E/BaseTestCase.php index 5374a060..7c4d5995 100644 --- a/test/E2E/BaseTestCase.php +++ b/test/E2E/BaseTestCase.php @@ -110,7 +110,7 @@ protected function settingsTestCase(string $endpoint, string $apiCall): void $response = $this->getSupportPal()->sendRequest($request); $responseArray = json_decode((string) $response->getBody(), true)['data']; self::assertInstanceOf(Settings::class, $model); - self::assertSame($responseArray, $model); + $this->assertArrayEqualsObjectFields($model, $responseArray); } /** From 0cb87a64c4a22a723f8f32cfe11ccf5983e04859 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Thu, 30 May 2024 13:41:34 +0100 Subject: [PATCH 19/20] use illuminate/support collections --- src/Model/Collection.php | 117 +++++------------------------ test/TestCase.php | 4 +- test/Unit/Model/CollectionTest.php | 68 +++++------------ 3 files changed, 37 insertions(+), 152 deletions(-) diff --git a/src/Model/Collection.php b/src/Model/Collection.php index c8ba58ef..ac1d4c68 100644 --- a/src/Model/Collection.php +++ b/src/Model/Collection.php @@ -2,123 +2,40 @@ namespace SupportPal\ApiClient\Model; -use Closure; -use SupportPal\ApiClient\Exception\InvalidArgumentException; - -use function array_filter; -use function array_map; -use function array_merge; -use function count; -use function current; -use function get_class; -use function is_object; -use function reset; +use Illuminate\Support\Collection as IlluminateCollection; +/** + * @mixin IlluminateCollection + */ class Collection { - /** - * Total number of elements returned from API. - */ - private int $count; - - /** @var Model[] */ - private array $models; - - /** - * Total number of models in the collection. - */ - private int $modelsCount; + /** @var IlluminateCollection */ + private IlluminateCollection $collection; /** * @param Model[] $models - * @throws InvalidArgumentException - */ - public function __construct(int $count = 0, array $models = []) - { - self::assertSameTypeModelInstances($models); - $this->count = $count; - $this->models = $models; - $this->modelsCount = count($models); - } - - /** - * get total number of all models as returned from the API response in `count` field. - */ - public function getCount(): int - { - return $this->count; - } - - /** - * @return Model[] - */ - public function getModels(): array - { - return $this->models; - } - - /** - * Actual number of elements in the collection. */ - public function getModelsCount(): int + public function __construct(protected readonly int $totalCount = 0, array $models = []) { - return $this->modelsCount; + $this->collection = new IlluminateCollection($models); } /** - * @throws InvalidArgumentException + * Total count returned from API (but not necessarily what is included in the collection). */ - public function map(Closure $closure): Collection + public function totalCount(): int { - $value = array_map($closure, $this->getModels()); - - return new self($this->getCount(), $value); - } - - /** - * @throws InvalidArgumentException - */ - public function filter(Closure $closure): Collection - { - $value = array_filter($this->getModels(), $closure); - - return new self($this->getCount(), $value); - } - - public function first(): ?Model - { - $firstElement = reset($this->models); - - return $firstElement instanceof Model ? $firstElement : null; + return $this->totalCount; } - public function isEmpty(): bool + public function __call(string $name, mixed $arguments): mixed { - return $this->getModelsCount() === 0; - } - - /** - * Api return count is set to be the one from the merged endpoint - * @throws InvalidArgumentException - */ - public function merge(Collection $collection): Collection - { - return new self($collection->getCount(), array_merge($this->getModels(), $collection->getModels())); - } + $result = $this->collection->$name(...$arguments); - /** - * @param Model[] $models - * @throws InvalidArgumentException - */ - private function assertSameTypeModelInstances(array $models): void - { - $firstModelType = ! empty($models) && is_object(current($models)) ? get_class(current($models)) : null; - foreach ($models as $model) { - if (! $model instanceof Model || get_class($model) !== $firstModelType) { - throw new InvalidArgumentException( - 'Supplied models must implement' . Model::class . ' and belong to the same type' - ); - } + if ($result instanceof IlluminateCollection) { + return new self($this->totalCount, $result->all()); } + + return $result; } } diff --git a/test/TestCase.php b/test/TestCase.php index c1e638f9..1aa05904 100644 --- a/test/TestCase.php +++ b/test/TestCase.php @@ -81,8 +81,8 @@ protected function assertArrayEqualsObjectFields(object $obj, array $array): voi protected function assertApiDataMatchesModels(Model|Collection $models, array $data): void { if ($models instanceof Collection) { - self::assertSame($data['count'], $models->getCount()); - foreach ($models->getModels() as $offset => $object) { + self::assertSame($data['count'], $models->count()); + foreach ($models->all() as $offset => $object) { $this->assertArrayEqualsObjectFields($object, $data['data'][$offset]); } diff --git a/test/Unit/Model/CollectionTest.php b/test/Unit/Model/CollectionTest.php index 1061b016..82c1d6d0 100644 --- a/test/Unit/Model/CollectionTest.php +++ b/test/Unit/Model/CollectionTest.php @@ -2,18 +2,14 @@ namespace Model; -use stdClass; use SupportPal\ApiClient\Exception\InvalidArgumentException; use SupportPal\ApiClient\Model\Collection; use SupportPal\ApiClient\Model\Model; -use SupportPal\ApiClient\Model\SelfService\Article; use SupportPal\ApiClient\Model\SelfService\Comment; use SupportPal\ApiClient\Tests\DataFixtures\SelfService\CommentData; use SupportPal\ApiClient\Tests\TestCase; use function array_map; -use function array_merge; -use function array_pop; use function count; use function current; use function range; @@ -26,9 +22,9 @@ public function testCreateCollection(): void $count = count($models); $collection = new Collection($count, $models); - self::assertSame($models, $collection->getModels()); - self::assertSame($count, $collection->getCount()); - self::assertSame($count, $collection->getModelsCount()); + self::assertSame($models, $collection->all()); + self::assertSame($count, $collection->count()); + self::assertSame($count, $collection->totalCount()); } public function testTotalModelsNotMatchingModelsCount(): void @@ -37,9 +33,9 @@ public function testTotalModelsNotMatchingModelsCount(): void $count = count($models); $collection = new Collection($count + 10, $models); - self::assertSame($models, $collection->getModels()); - self::assertSame($count, $collection->getModelsCount()); - self::assertSame($count + 10, $collection->getCount()); + self::assertSame($models, $collection->all()); + self::assertSame($count, $collection->count()); + self::assertSame($count + 10, $collection->totalCount()); } public function testCollectionMap(): void @@ -51,17 +47,18 @@ public function testCollectionMap(): void /** @var Comment $firstModel */ $firstModel = current($models); $name = $firstModel->getAttribute('name') . 'test'; - $mappedCollection = $collection->map(function (Comment $comment) use ($name) { + /** @var Collection $mappedCollection */ + $mappedCollection = $collection->map(function (Model $comment) use ($name) { return $comment->setAttribute('name', $name); }); self::assertNotSame($collection, $mappedCollection); - self::assertSame($models, $mappedCollection->getModels()); - self::assertSame($count, $mappedCollection->getCount()); - self::assertSame($count, $mappedCollection->getModelsCount()); + self::assertSame($models, $mappedCollection->all()); + self::assertSame($count, $mappedCollection->count()); + self::assertSame($count, $mappedCollection->totalCount()); /** @var Comment $model */ - foreach ($mappedCollection->getModels() as $model) { + foreach ($mappedCollection->all() as $model) { self::assertSame($name, $model->getAttribute('name')); } } @@ -76,14 +73,15 @@ public function testCollectionFilter(): void $firstModel = current($models); $name = $firstModel->getAttribute('name') . 'test'; - $mappedCollection = $collection->filter(function (Comment $comment) use ($name) { + /** @var Collection $filteredCollection */ + $filteredCollection = $collection->filter(function (Model $comment) use ($name) { return $comment->getAttribute('name') === $name; }); - self::assertNotSame($collection, $mappedCollection); - self::assertNotSame($models, $mappedCollection->getModels()); - self::assertSame($count, $mappedCollection->getCount()); - self::assertSame(0, $mappedCollection->getModelsCount()); + self::assertNotEquals($collection, $filteredCollection); + self::assertNotEquals($models, $filteredCollection->all()); + self::assertSame(0, $filteredCollection->count()); + self::assertSame($count, $filteredCollection->totalCount()); } public function testCollectionFirst(): void @@ -108,36 +106,6 @@ public function testCollectionIsEmpty(Collection $collection, bool $actualIsEmpt self::assertSame($collection->isEmpty(), $actualIsEmpty); } - public function testCreateWithDifferentModels(): void - { - self::expectException(InvalidArgumentException::class); - new Collection(2, [ new Comment, new Article]); - } - - public function testCreateWithInvalidTypes(): void - { - self::expectException(InvalidArgumentException::class); - /** @var Model[] $models */ - $models = [new stdClass, new stdClass]; - new Collection(2, $models); - } - - public function testMerge(): void - { - $models1 = $this->getModelsTestData(); - $models2 = $this->getModelsTestData(); - array_pop($models2); - - $collection1 = new Collection(count($models1), $models1); - $collection2 = new Collection(count($models2), $models2); - - $merged = $collection1->merge($collection2); - $arraysMerge = array_merge($models1, $models2); - self::assertSame($arraysMerge, $merged->getModels()); - self::assertSame(count($models2), $merged->getCount()); - self::assertSame(count($arraysMerge), $merged->getModelsCount()); - } - /** * @return iterable * @throws InvalidArgumentException From fb7f0e7a05cfaaf1c24aaaf64e67851a84e33870 Mon Sep 17 00:00:00 2001 From: Jay Shah <602425+jshah4517@users.noreply.github.com> Date: Thu, 30 May 2024 13:42:24 +0100 Subject: [PATCH 20/20] update phpstan --- composer.json | 2 +- composer.lock | 16 ++++++---------- phpstan.neon | 1 - 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 6be99234..863d7920 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,7 @@ "larapack/dd": "^1.1", "phpmd/phpmd": "^2.9", "phpspec/prophecy-phpunit": "^2.0", - "phpstan/phpstan": "1.10.25", + "phpstan/phpstan": "1.11.2", "phpunit/phpunit": "^9.3", "rregeer/phpunit-coverage-check": "^0.3.1", "slevomat/coding-standard": "^8.15", diff --git a/composer.lock b/composer.lock index aded03ca..5756dafe 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ef6f56a74b5b5e004ee87c6fc4bd4127", + "content-hash": "508a9f83f8262a73df5f42db534cbf7f", "packages": [ { "name": "carbonphp/carbon-doctrine-types", @@ -4104,16 +4104,16 @@ }, { "name": "phpstan/phpstan", - "version": "1.10.25", + "version": "1.11.2", "source": { "type": "git", "url": "https://github.com/phpstan/phpstan.git", - "reference": "578f4e70d117f9a90699324c555922800ac38d8c" + "reference": "0d5d4294a70deb7547db655c47685d680e39cfec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpstan/zipball/578f4e70d117f9a90699324c555922800ac38d8c", - "reference": "578f4e70d117f9a90699324c555922800ac38d8c", + "url": "https://api.github.com/repos/phpstan/phpstan/zipball/0d5d4294a70deb7547db655c47685d680e39cfec", + "reference": "0d5d4294a70deb7547db655c47685d680e39cfec", "shasum": "" }, "require": { @@ -4156,13 +4156,9 @@ { "url": "https://github.com/phpstan", "type": "github" - }, - { - "url": "https://tidelift.com/funding/github/packagist/phpstan/phpstan", - "type": "tidelift" } ], - "time": "2023-07-06T12:11:37+00:00" + "time": "2024-05-24T13:23:04+00:00" }, { "name": "phpunit/php-code-coverage", diff --git a/phpstan.neon b/phpstan.neon index bb671777..4b4297c7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -6,7 +6,6 @@ parameters: paths: - src - test - inferPrivatePropertyTypeFromConstructor: true excludePaths: - test/DataFixtures - test/PhpUnit