From 85f473b38fcc0233b83954cb468bb109932df804 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linas=20Pa=C5=A1viestis?= Date: Thu, 10 Nov 2022 14:10:40 +0200 Subject: [PATCH] 4.2.0 update --- CHANGELOG.md | 14 + README.md | 117 +++ composer.json | 1 + composer.lock | 982 ++++++++++++++---- init.php | 7 + lib/BaseClient.php | 24 +- lib/Exception/Api/LedgerAccountNotFound.php | 12 + lib/Exception/Api/RefundIsNotValid.php | 12 + lib/Exception/Api/RefundNotFound.php | 12 + lib/Exception/Api/WithdrawalNotFound.php | 12 + lib/Services/LedgerService.php | 28 + lib/Services/RefundService.php | 46 + lib/Services/ServiceFactory.php | 5 +- lib/Services/WithdrawalService.php | 27 + tests/CoinGate/Services/LedgerServiceTest.php | 76 ++ tests/CoinGate/Services/OrderServiceTest.php | 112 +- tests/CoinGate/Services/RefundServiceTest.php | 129 +++ .../Services/WithdrawalServiceTest.php | 76 ++ tests/TestCase.php | 13 +- 19 files changed, 1451 insertions(+), 254 deletions(-) create mode 100644 lib/Exception/Api/LedgerAccountNotFound.php create mode 100644 lib/Exception/Api/RefundIsNotValid.php create mode 100644 lib/Exception/Api/RefundNotFound.php create mode 100644 lib/Exception/Api/WithdrawalNotFound.php create mode 100644 lib/Services/LedgerService.php create mode 100644 lib/Services/RefundService.php create mode 100644 lib/Services/WithdrawalService.php create mode 100644 tests/CoinGate/Services/LedgerServiceTest.php create mode 100644 tests/CoinGate/Services/RefundServiceTest.php create mode 100644 tests/CoinGate/Services/WithdrawalServiceTest.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 4878f7d..0d06073 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,20 @@ CoinGate PHP library release notes ============================ +v4.2.0 +--- +* Added support for Refund API calls. + - Added support for [Create Order Refund](https://developer.coingate.com/reference/create-refund) + - Added support for [Get Order Refund](https://developer.coingate.com/reference/get-order-refund) + - Added support for [Get Order Refunds](https://developer.coingate.com/reference/get-refund) + - Added support for [Get Refunds](https://developer.coingate.com/reference/get-refunds) +* Added support for Ledger API calls. + - Added support for [Get Account](https://developer.coingate.com/reference/get-account) + - Added support for [List Accounts](https://developer.coingate.com/reference/accounts) +* Added support for Withdrawal API calls. + - Added support for [Get Withdrawals](https://developer.coingate.com/reference/get-withdrawals) + - Added support for [Get Withdrawal](https://developer.coingate.com/reference/get-withdrawal) + v4.1.0 --- * ApiKey is no more mandatory when creating a Client. Useful when you want to perform Public API calls only. diff --git a/README.md b/README.md index bbd9b98..bfb9fad 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,123 @@ $orders = $client->order->list([ ]); ``` +## Refund API + +### Create Order Refund + +Creating a refund for an order. + +```php +$params = [ + 'amount' => 50, + 'address' => '2ExAmPl3dyFiqkMUUksTJ3Qey1s2Q3f4i59', + 'address_memo' => 'Blue house', // optional + 'currency_id' => 1, + 'platform_id' => 2, + 'reason' => 'Iphone refund', + 'email' => 'example.guy@xmpl.com', + 'ledger_account_id' => 'ID of the trader balance' +]; + +try { + $refund = $client->refund->create(7294, $params); +} catch (\CoinGate\Exception\ApiErrorException $e) { + // something went wrong... +} + +echo $refund->id; +``` + +### Get Order Refund + +Retrieves a specific refund for an order. + +```php +$refund = $client->refund->get(7294, 4927); +``` + +### Get Order Refunds + +Retrieves all refunds for an order. + +```php +// optional filters +$params = [ + 'page' => 2, + 'per_page' => 30 +] + +$orderRefunds = $client->refund->list(7294, $params); +``` + +### Get Refunds + +Retrieves all refunds. + +```php +$refunds = $client->refund->list(); +``` + +or + +```php +// optional filters +$params = [ + 'page' => 2, + 'per_page' => 30 +] + +$refunds = $client->refund->list(null, $params); +``` + +## Ledger API + +### Get Account + +Retrieves a specific ledger account. + +```php +$account = $client->ledger->get('01G0EM0RRVREB4WD5KDB6VJVPM'); +``` + +### Get Accounts + +Retrieves all ledger accounts. + +```php +// optional filters +$params = [ + 'page' => 2, + 'per_page' => 30 +] + +$accounts = $client->ledger->list($params); +``` + +## Withdrawal API + +### Get Withdrawal + +Retrieving specific withdrawal. + +```php +$withdrawal = $client->withdrawal->get(1234); +``` + +### Get Withdrawals + +Retrieving all withdrawals. + +```php +// optional filters +$params = [ + 'page' => 2, + 'per_page' => 30 +] + +$withdrawals = $client->withdrawal->list($params); +``` + ## Public API ### Get Exchange Rate diff --git a/composer.json b/composer.json index e3663c9..1d98ee7 100644 --- a/composer.json +++ b/composer.json @@ -30,6 +30,7 @@ }, "require-dev": { "phpunit/phpunit": "^5.7 || ^9.0", + "php-http/mock-client": "~1.5.0", "squizlabs/php_codesniffer": "~3.6.2", "phpstan/phpstan": "~1.4.10" }, diff --git a/composer.lock b/composer.lock index 299d1d9..910eb67 100644 --- a/composer.lock +++ b/composer.lock @@ -4,9 +4,75 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "a49e6732f9e48290e4473f3a0b9be65d", + "content-hash": "28e182fbb3d20d2410337727418ecaca", "packages": [], "packages-dev": [ + { + "name": "clue/stream-filter", + "version": "v1.6.0", + "source": { + "type": "git", + "url": "https://github.com/clue/stream-filter.git", + "reference": "d6169430c7731d8509da7aecd0af756a5747b78e" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/clue/stream-filter/zipball/d6169430c7731d8509da7aecd0af756a5747b78e", + "reference": "d6169430c7731d8509da7aecd0af756a5747b78e", + "shasum": "" + }, + "require": { + "php": ">=5.3" + }, + "require-dev": { + "phpunit/phpunit": "^9.3 || ^5.7 || ^4.8.36" + }, + "type": "library", + "autoload": { + "files": [ + "src/functions_include.php" + ], + "psr-4": { + "Clue\\StreamFilter\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Christian Lück", + "email": "christian@clue.engineering" + } + ], + "description": "A simple and modern approach to stream filtering in PHP", + "homepage": "https://github.com/clue/php-stream-filter", + "keywords": [ + "bucket brigade", + "callback", + "filter", + "php_user_filter", + "stream", + "stream_filter_append", + "stream_filter_register" + ], + "support": { + "issues": "https://github.com/clue/stream-filter/issues", + "source": "https://github.com/clue/stream-filter/tree/v1.6.0" + }, + "funding": [ + { + "url": "https://clue.engineering/support", + "type": "custom" + }, + { + "url": "https://github.com/clue", + "type": "github" + } + ], + "time": "2022-02-21T13:15:14+00:00" + }, { "name": "doctrine/instantiator", "version": "1.4.1", @@ -138,16 +204,16 @@ }, { "name": "nikic/php-parser", - "version": "v4.13.2", + "version": "v4.15.1", "source": { "type": "git", "url": "https://github.com/nikic/PHP-Parser.git", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077" + "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/210577fe3cf7badcc5814d99455df46564f3c077", - "reference": "210577fe3cf7badcc5814d99455df46564f3c077", + "url": "https://api.github.com/repos/nikic/PHP-Parser/zipball/0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", + "reference": "0ef6c55a3f47f89d7a374e6f835197a0b5fcf900", "shasum": "" }, "require": { @@ -188,9 +254,9 @@ ], "support": { "issues": "https://github.com/nikic/PHP-Parser/issues", - "source": "https://github.com/nikic/PHP-Parser/tree/v4.13.2" + "source": "https://github.com/nikic/PHP-Parser/tree/v4.15.1" }, - "time": "2021-11-30T19:35:32+00:00" + "time": "2022-09-04T07:30:47+00:00" }, { "name": "phar-io/manifest", @@ -304,31 +370,118 @@ "time": "2022-02-21T01:04:05+00:00" }, { - "name": "phpdocumentor/reflection-common", - "version": "2.2.0", + "name": "php-http/client-common", + "version": "2.6.0", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionCommon.git", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b" + "url": "https://github.com/php-http/client-common.git", + "reference": "45db684cd4e186dcdc2b9c06b22970fe123796c0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/1d01c49d4ed62f25aa84a747ad35d5a16924662b", - "reference": "1d01c49d4ed62f25aa84a747ad35d5a16924662b", + "url": "https://api.github.com/repos/php-http/client-common/zipball/45db684cd4e186dcdc2b9c06b22970fe123796c0", + "reference": "45db684cd4e186dcdc2b9c06b22970fe123796c0", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0" + "php": "^7.1 || ^8.0", + "php-http/httplug": "^2.0", + "php-http/message": "^1.6", + "php-http/message-factory": "^1.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "symfony/options-resolver": "~4.0.15 || ~4.1.9 || ^4.2.1 || ^5.0 || ^6.0", + "symfony/polyfill-php80": "^1.17" + }, + "require-dev": { + "doctrine/instantiator": "^1.1", + "guzzlehttp/psr7": "^1.4", + "nyholm/psr7": "^1.2", + "phpspec/phpspec": "^5.1 || ^6.3 || ^7.1", + "phpspec/prophecy": "^1.10.2", + "phpunit/phpunit": "^7.5.15 || ^8.5 || ^9.3" + }, + "suggest": { + "ext-json": "To detect JSON responses with the ContentTypePlugin", + "ext-libxml": "To detect XML responses with the ContentTypePlugin", + "php-http/cache-plugin": "PSR-6 Cache plugin", + "php-http/logger-plugin": "PSR-3 Logger plugin", + "php-http/stopwatch-plugin": "Symfony Stopwatch plugin" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Client\\Common\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Common HTTP Client implementations and tools for HTTPlug", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "common", + "http", + "httplug" + ], + "support": { + "issues": "https://github.com/php-http/client-common/issues", + "source": "https://github.com/php-http/client-common/tree/2.6.0" + }, + "time": "2022-09-29T09:59:43+00:00" + }, + { + "name": "php-http/discovery", + "version": "1.14.3", + "source": { + "type": "git", + "url": "https://github.com/php-http/discovery.git", + "reference": "31d8ee46d0215108df16a8527c7438e96a4d7735" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/discovery/zipball/31d8ee46d0215108df16a8527c7438e96a4d7735", + "reference": "31d8ee46d0215108df16a8527c7438e96a4d7735", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "conflict": { + "nyholm/psr7": "<1.0" + }, + "require-dev": { + "graham-campbell/phpspec-skip-example-extension": "^5.0", + "php-http/httplug": "^1.0 || ^2.0", + "php-http/message-factory": "^1.0", + "phpspec/phpspec": "^5.1 || ^6.1" + }, + "suggest": { + "php-http/message": "Allow to use Guzzle, Diactoros or Slim Framework factories" }, "type": "library", "extra": { "branch-alias": { - "dev-2.x": "2.x-dev" + "dev-master": "1.9-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": "src/" + "Http\\Discovery\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -337,59 +490,60 @@ ], "authors": [ { - "name": "Jaap van Otterdijk", - "email": "opensource@ijaap.nl" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], - "description": "Common reflection classes used by phpdocumentor to reflect the code structure", - "homepage": "http://www.phpdoc.org", + "description": "Finds installed HTTPlug implementations and PSR-7 message factories", + "homepage": "http://php-http.org", "keywords": [ - "FQSEN", - "phpDocumentor", - "phpdoc", - "reflection", - "static analysis" + "adapter", + "client", + "discovery", + "factory", + "http", + "message", + "psr7" ], "support": { - "issues": "https://github.com/phpDocumentor/ReflectionCommon/issues", - "source": "https://github.com/phpDocumentor/ReflectionCommon/tree/2.x" + "issues": "https://github.com/php-http/discovery/issues", + "source": "https://github.com/php-http/discovery/tree/1.14.3" }, - "time": "2020-06-27T09:03:43+00:00" + "time": "2022-07-11T14:04:40+00:00" }, { - "name": "phpdocumentor/reflection-docblock", - "version": "5.3.0", + "name": "php-http/httplug", + "version": "2.3.0", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170" + "url": "https://github.com/php-http/httplug.git", + "reference": "f640739f80dfa1152533976e3c112477f69274eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/622548b623e81ca6d78b721c5e029f4ce664f170", - "reference": "622548b623e81ca6d78b721c5e029f4ce664f170", + "url": "https://api.github.com/repos/php-http/httplug/zipball/f640739f80dfa1152533976e3c112477f69274eb", + "reference": "f640739f80dfa1152533976e3c112477f69274eb", "shasum": "" }, "require": { - "ext-filter": "*", - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.2", - "phpdocumentor/type-resolver": "^1.3", - "webmozart/assert": "^1.9.1" + "php": "^7.1 || ^8.0", + "php-http/promise": "^1.1", + "psr/http-client": "^1.0", + "psr/http-message": "^1.0" }, "require-dev": { - "mockery/mockery": "~1.3.2", - "psalm/phar": "^4.8" + "friends-of-phpspec/phpspec-code-coverage": "^4.1", + "phpspec/phpspec": "^5.1 || ^6.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "5.x-dev" + "dev-master": "2.x-dev" } }, "autoload": { "psr-4": { - "phpDocumentor\\Reflection\\": "src" + "Http\\Client\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -398,52 +552,76 @@ ], "authors": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" + "name": "Eric GELOEN", + "email": "geloen.eric@gmail.com" }, { - "name": "Jaap van Otterdijk", - "email": "account@ijaap.nl" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com", + "homepage": "https://sagikazarmark.hu" } ], - "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", + "description": "HTTPlug, the HTTP client abstraction for PHP", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http" + ], "support": { - "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.3.0" + "issues": "https://github.com/php-http/httplug/issues", + "source": "https://github.com/php-http/httplug/tree/2.3.0" }, - "time": "2021-10-19T17:43:47+00:00" + "time": "2022-02-21T09:52:22+00:00" }, { - "name": "phpdocumentor/type-resolver", - "version": "1.6.0", + "name": "php-http/message", + "version": "1.13.0", "source": { "type": "git", - "url": "https://github.com/phpDocumentor/TypeResolver.git", - "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706" + "url": "https://github.com/php-http/message.git", + "reference": "7886e647a30a966a1a8d1dad1845b71ca8678361" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/93ebd0014cab80c4ea9f5e297ea48672f1b87706", - "reference": "93ebd0014cab80c4ea9f5e297ea48672f1b87706", + "url": "https://api.github.com/repos/php-http/message/zipball/7886e647a30a966a1a8d1dad1845b71ca8678361", + "reference": "7886e647a30a966a1a8d1dad1845b71ca8678361", "shasum": "" }, "require": { - "php": "^7.2 || ^8.0", - "phpdocumentor/reflection-common": "^2.0" + "clue/stream-filter": "^1.5", + "php": "^7.1 || ^8.0", + "php-http/message-factory": "^1.0.2", + "psr/http-message": "^1.0" + }, + "provide": { + "php-http/message-factory-implementation": "1.0" }, "require-dev": { - "ext-tokenizer": "*", - "psalm/phar": "^4.8" + "ergebnis/composer-normalize": "^2.6", + "ext-zlib": "*", + "guzzlehttp/psr7": "^1.0", + "laminas/laminas-diactoros": "^2.0", + "phpspec/phpspec": "^5.1 || ^6.3 || ^7.1", + "slim/slim": "^3.0" + }, + "suggest": { + "ext-zlib": "Used with compressor/decompressor streams", + "guzzlehttp/psr7": "Used with Guzzle PSR-7 Factories", + "laminas/laminas-diactoros": "Used with Diactoros Factories", + "slim/slim": "Used with Slim Framework PSR-7 implementation" }, "type": "library", "extra": { "branch-alias": { - "dev-1.x": "1.x-dev" + "dev-master": "1.10-dev" } }, "autoload": { + "files": [ + "src/filters.php" + ], "psr-4": { - "phpDocumentor\\Reflection\\": "src" + "Http\\Message\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -452,41 +630,109 @@ ], "authors": [ { - "name": "Mike van Riel", - "email": "me@mikevanriel.com" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], - "description": "A PSR-5 based resolver of Class names, Types and Structural Element Names", + "description": "HTTP Message related tools", + "homepage": "http://php-http.org", + "keywords": [ + "http", + "message", + "psr-7" + ], "support": { - "issues": "https://github.com/phpDocumentor/TypeResolver/issues", - "source": "https://github.com/phpDocumentor/TypeResolver/tree/1.6.0" + "issues": "https://github.com/php-http/message/issues", + "source": "https://github.com/php-http/message/tree/1.13.0" }, - "time": "2022-01-04T19:58:01+00:00" + "time": "2022-02-11T13:41:14+00:00" }, { - "name": "phpspec/prophecy", - "version": "v1.15.0", + "name": "php-http/message-factory", + "version": "v1.0.2", "source": { "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13" + "url": "https://github.com/php-http/message-factory.git", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/bbcd7380b0ebf3961ee21409db7b38bc31d69a13", - "reference": "bbcd7380b0ebf3961ee21409db7b38bc31d69a13", + "url": "https://api.github.com/repos/php-http/message-factory/zipball/a478cb11f66a6ac48d8954216cfed9aa06a501a1", + "reference": "a478cb11f66a6ac48d8954216cfed9aa06a501a1", "shasum": "" }, "require": { - "doctrine/instantiator": "^1.2", - "php": "^7.2 || ~8.0, <8.2", - "phpdocumentor/reflection-docblock": "^5.2", - "sebastian/comparator": "^3.0 || ^4.0", - "sebastian/recursion-context": "^3.0 || ^4.0" + "php": ">=5.4", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" + } + ], + "description": "Factory interfaces for PSR-7 HTTP Message", + "homepage": "http://php-http.org", + "keywords": [ + "factory", + "http", + "message", + "stream", + "uri" + ], + "support": { + "issues": "https://github.com/php-http/message-factory/issues", + "source": "https://github.com/php-http/message-factory/tree/master" + }, + "time": "2015-12-19T14:08:53+00:00" + }, + { + "name": "php-http/mock-client", + "version": "1.5.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/mock-client.git", + "reference": "a797c2a9122cccafcce14773b8a24d2808a9ab44" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/mock-client/zipball/a797c2a9122cccafcce14773b8a24d2808a9ab44", + "reference": "a797c2a9122cccafcce14773b8a24d2808a9ab44", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0", + "php-http/client-common": "^2.0", + "php-http/discovery": "^1.0", + "php-http/httplug": "^2.0", + "php-http/message-factory": "^1.0", + "psr/http-client": "^1.0", + "psr/http-factory": "^1.0", + "psr/http-message": "^1.0", + "symfony/polyfill-php80": "^1.17" + }, + "provide": { + "php-http/async-client-implementation": "1.0", + "php-http/client-implementation": "1.0", + "psr/http-client-implementation": "1.0" }, "require-dev": { - "phpspec/phpspec": "^6.0 || ^7.0", - "phpunit/phpunit": "^8.0 || ^9.0" + "phpspec/phpspec": "^5.1 || ^6.0" }, "type": "library", "extra": { @@ -496,7 +742,7 @@ }, "autoload": { "psr-4": { - "Prophecy\\": "src/Prophecy" + "Http\\Mock\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -505,30 +751,80 @@ ], "authors": [ { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" + "name": "David de Boer", + "email": "david@ddeboer.nl" + } + ], + "description": "Mock HTTP client", + "homepage": "http://httplug.io", + "keywords": [ + "client", + "http", + "mock", + "psr7" + ], + "support": { + "issues": "https://github.com/php-http/mock-client/issues", + "source": "https://github.com/php-http/mock-client/tree/1.5.0" + }, + "time": "2021-08-25T07:01:14+00:00" + }, + { + "name": "php-http/promise", + "version": "1.1.0", + "source": { + "type": "git", + "url": "https://github.com/php-http/promise.git", + "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-http/promise/zipball/4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "reference": "4c4c1f9b7289a2ec57cde7f1e9762a5789506f88", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "friends-of-phpspec/phpspec-code-coverage": "^4.3.2", + "phpspec/phpspec": "^5.1.2 || ^6.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + } + }, + "autoload": { + "psr-4": { + "Http\\Promise\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Joel Wurtz", + "email": "joel.wurtz@gmail.com" }, { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" + "name": "Márk Sági-Kazár", + "email": "mark.sagikazar@gmail.com" } ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", + "description": "Promise used for asynchronous HTTP requests", + "homepage": "http://httplug.io", "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" + "promise" ], "support": { - "issues": "https://github.com/phpspec/prophecy/issues", - "source": "https://github.com/phpspec/prophecy/tree/v1.15.0" + "issues": "https://github.com/php-http/promise/issues", + "source": "https://github.com/php-http/promise/tree/1.1.0" }, - "time": "2021-12-08T12:19:24+00:00" + "time": "2020-07-07T09:29:14+00:00" }, { "name": "phpstan/phpstan", @@ -591,23 +887,23 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.15", + "version": "9.2.18", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f" + "reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/2e9da11878c4202f97915c1cb4bb1ca318a63f5f", - "reference": "2e9da11878c4202f97915c1cb4bb1ca318a63f5f", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/12fddc491826940cf9b7e88ad9664cf51f0f6d0a", + "reference": "12fddc491826940cf9b7e88ad9664cf51f0f6d0a", "shasum": "" }, "require": { "ext-dom": "*", "ext-libxml": "*", "ext-xmlwriter": "*", - "nikic/php-parser": "^4.13.0", + "nikic/php-parser": "^4.14", "php": ">=7.3", "phpunit/php-file-iterator": "^3.0.3", "phpunit/php-text-template": "^2.0.2", @@ -656,7 +952,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.15" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.18" }, "funding": [ { @@ -664,7 +960,7 @@ "type": "github" } ], - "time": "2022-03-07T09:28:20+00:00" + "time": "2022-10-27T13:35:33+00:00" }, { "name": "phpunit/php-file-iterator", @@ -909,16 +1205,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.5.19", + "version": "9.5.26", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807" + "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/35ea4b7f3acabb26f4bb640f8c30866c401da807", - "reference": "35ea4b7f3acabb26f4bb640f8c30866c401da807", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/851867efcbb6a1b992ec515c71cdcf20d895e9d2", + "reference": "851867efcbb6a1b992ec515c71cdcf20d895e9d2", "shasum": "" }, "require": { @@ -933,7 +1229,6 @@ "phar-io/manifest": "^2.0.3", "phar-io/version": "^3.0.2", "php": ">=7.3", - "phpspec/prophecy": "^1.12.1", "phpunit/php-code-coverage": "^9.2.13", "phpunit/php-file-iterator": "^3.0.5", "phpunit/php-invoker": "^3.1.1", @@ -941,20 +1236,16 @@ "phpunit/php-timer": "^5.0.2", "sebastian/cli-parser": "^1.0.1", "sebastian/code-unit": "^1.0.6", - "sebastian/comparator": "^4.0.5", + "sebastian/comparator": "^4.0.8", "sebastian/diff": "^4.0.3", "sebastian/environment": "^5.1.3", - "sebastian/exporter": "^4.0.3", + "sebastian/exporter": "^4.0.5", "sebastian/global-state": "^5.0.1", "sebastian/object-enumerator": "^4.0.3", "sebastian/resource-operations": "^3.0.3", - "sebastian/type": "^3.0", + "sebastian/type": "^3.2", "sebastian/version": "^3.0.2" }, - "require-dev": { - "ext-pdo": "*", - "phpspec/prophecy-phpunit": "^2.0.1" - }, "suggest": { "ext-soap": "*", "ext-xdebug": "*" @@ -996,7 +1287,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.19" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.5.26" }, "funding": [ { @@ -1006,9 +1297,173 @@ { "url": "https://github.com/sebastianbergmann", "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/phpunit/phpunit", + "type": "tidelift" + } + ], + "time": "2022-10-28T06:00:21+00:00" + }, + { + "name": "psr/http-client", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-client.git", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-client/zipball/2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "reference": "2dfb5f6c5eff0e91e20e913f8c5452ed95b86621", + "shasum": "" + }, + "require": { + "php": "^7.0 || ^8.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Client\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" } ], - "time": "2022-03-15T09:57:31+00:00" + "description": "Common interface for HTTP clients", + "homepage": "https://github.com/php-fig/http-client", + "keywords": [ + "http", + "http-client", + "psr", + "psr-18" + ], + "support": { + "source": "https://github.com/php-fig/http-client/tree/master" + }, + "time": "2020-06-29T06:28:15+00:00" + }, + { + "name": "psr/http-factory", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-factory.git", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-factory/zipball/12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "reference": "12ac7fcd07e5b077433f5f2bee95b3a771bf61be", + "shasum": "" + }, + "require": { + "php": ">=7.0.0", + "psr/http-message": "^1.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interfaces for PSR-7 HTTP message factories", + "keywords": [ + "factory", + "http", + "message", + "psr", + "psr-17", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-factory/tree/master" + }, + "time": "2019-04-30T12:38:16+00:00" + }, + { + "name": "psr/http-message", + "version": "1.0.1", + "source": { + "type": "git", + "url": "https://github.com/php-fig/http-message.git", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", + "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", + "shasum": "" + }, + "require": { + "php": ">=5.3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Http\\Message\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "http://www.php-fig.org/" + } + ], + "description": "Common interface for HTTP messages", + "homepage": "https://github.com/php-fig/http-message", + "keywords": [ + "http", + "http-message", + "psr", + "psr-7", + "request", + "response" + ], + "support": { + "source": "https://github.com/php-fig/http-message/tree/master" + }, + "time": "2016-08-06T14:39:51+00:00" }, { "name": "sebastian/cli-parser", @@ -1179,16 +1634,16 @@ }, { "name": "sebastian/comparator", - "version": "4.0.6", + "version": "4.0.8", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382" + "reference": "fa0f136dd2334583309d32b62544682ee972b51a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/55f4261989e546dc112258c7a75935a81a7ce382", - "reference": "55f4261989e546dc112258c7a75935a81a7ce382", + "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/fa0f136dd2334583309d32b62544682ee972b51a", + "reference": "fa0f136dd2334583309d32b62544682ee972b51a", "shasum": "" }, "require": { @@ -1241,7 +1696,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/comparator/issues", - "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.6" + "source": "https://github.com/sebastianbergmann/comparator/tree/4.0.8" }, "funding": [ { @@ -1249,7 +1704,7 @@ "type": "github" } ], - "time": "2020-10-26T15:49:45+00:00" + "time": "2022-09-14T12:41:17+00:00" }, { "name": "sebastian/complexity", @@ -1376,16 +1831,16 @@ }, { "name": "sebastian/environment", - "version": "5.1.3", + "version": "5.1.4", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac" + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/388b6ced16caa751030f6a69e588299fa09200ac", - "reference": "388b6ced16caa751030f6a69e588299fa09200ac", + "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/1b5dff7bb151a4db11d49d90e5408e4e938270f7", + "reference": "1b5dff7bb151a4db11d49d90e5408e4e938270f7", "shasum": "" }, "require": { @@ -1427,7 +1882,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/environment/issues", - "source": "https://github.com/sebastianbergmann/environment/tree/5.1.3" + "source": "https://github.com/sebastianbergmann/environment/tree/5.1.4" }, "funding": [ { @@ -1435,20 +1890,20 @@ "type": "github" } ], - "time": "2020-09-28T05:52:38+00:00" + "time": "2022-04-03T09:37:03+00:00" }, { "name": "sebastian/exporter", - "version": "4.0.4", + "version": "4.0.5", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9" + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/65e8b7db476c5dd267e65eea9cab77584d3cfff9", - "reference": "65e8b7db476c5dd267e65eea9cab77584d3cfff9", + "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", + "reference": "ac230ed27f0f98f597c8a2b6eb7ac563af5e5b9d", "shasum": "" }, "require": { @@ -1504,7 +1959,7 @@ ], "support": { "issues": "https://github.com/sebastianbergmann/exporter/issues", - "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.4" + "source": "https://github.com/sebastianbergmann/exporter/tree/4.0.5" }, "funding": [ { @@ -1512,7 +1967,7 @@ "type": "github" } ], - "time": "2021-11-11T14:18:36+00:00" + "time": "2022-09-14T06:03:37+00:00" }, { "name": "sebastian/global-state", @@ -1867,16 +2322,16 @@ }, { "name": "sebastian/type", - "version": "3.0.0", + "version": "3.2.0", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/type.git", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad" + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", - "reference": "b233b84bc4465aff7b57cf1c4bc75c86d00d6dad", + "url": "https://api.github.com/repos/sebastianbergmann/type/zipball/fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", + "reference": "fb3fe09c5f0bae6bc27ef3ce933a1e0ed9464b6e", "shasum": "" }, "require": { @@ -1888,7 +2343,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.0-dev" + "dev-master": "3.2-dev" } }, "autoload": { @@ -1911,7 +2366,7 @@ "homepage": "https://github.com/sebastianbergmann/type", "support": { "issues": "https://github.com/sebastianbergmann/type/issues", - "source": "https://github.com/sebastianbergmann/type/tree/3.0.0" + "source": "https://github.com/sebastianbergmann/type/tree/3.2.0" }, "funding": [ { @@ -1919,7 +2374,7 @@ "type": "github" } ], - "time": "2022-03-15T09:54:48+00:00" + "time": "2022-09-12T14:47:03+00:00" }, { "name": "sebastian/version", @@ -2031,32 +2486,160 @@ "time": "2021-12-12T21:44:58+00:00" }, { - "name": "symfony/polyfill-ctype", - "version": "v1.25.0", + "name": "symfony/deprecation-contracts", + "version": "v3.1.1", "source": { "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "30885182c981ab175d4d034db0f6f469898070ab" + "url": "https://github.com/symfony/deprecation-contracts.git", + "reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", - "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918", + "reference": "07f1b9cc2ffee6aaafcf4b710fbc38ff736bd918", "shasum": "" }, "require": { - "php": ">=7.1" + "php": ">=8.1" }, - "provide": { - "ext-ctype": "*" + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.1-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } }, - "suggest": { - "ext-ctype": "For best performance" + "autoload": { + "files": [ + "function.php" + ] + }, + "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": "A generic function and convention to trigger deprecation notices", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/deprecation-contracts/tree/v3.1.1" + }, + "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": "2022-02-25T11:15:52+00:00" + }, + { + "name": "symfony/options-resolver", + "version": "v6.1.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/options-resolver.git", + "reference": "a3016f5442e28386ded73c43a32a5b68586dd1c4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/options-resolver/zipball/a3016f5442e28386ded73c43a32a5b68586dd1c4", + "reference": "a3016f5442e28386ded73c43a32a5b68586dd1c4", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.1|^3" + }, + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\OptionsResolver\\": "" + }, + "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": "Provides an improved replacement for the array_replace PHP function", + "homepage": "https://symfony.com", + "keywords": [ + "config", + "configuration", + "options" + ], + "support": { + "source": "https://github.com/symfony/options-resolver/tree/v6.1.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": "2022-02-25T11:15:52+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.26.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "reference": "cfa0ae98841b9e461207c13ab093d76b0fa7bace", + "shasum": "" + }, + "require": { + "php": ">=7.1" }, "type": "library", "extra": { "branch-alias": { - "dev-main": "1.23-dev" + "dev-main": "1.26-dev" }, "thanks": { "name": "symfony/polyfill", @@ -2068,8 +2651,11 @@ "bootstrap.php" ], "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - } + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] }, "notification-url": "https://packagist.org/downloads/", "license": [ @@ -2077,24 +2663,28 @@ ], "authors": [ { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.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": "Symfony polyfill for ctype functions", + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", "homepage": "https://symfony.com", "keywords": [ "compatibility", - "ctype", "polyfill", - "portable" + "portable", + "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.26.0" }, "funding": [ { @@ -2110,7 +2700,7 @@ "type": "tidelift" } ], - "time": "2021-10-20T20:35:02+00:00" + "time": "2022-05-10T07:21:04+00:00" }, { "name": "theseer/tokenizer", @@ -2161,64 +2751,6 @@ } ], "time": "2021-07-28T10:34:58+00:00" - }, - { - "name": "webmozart/assert", - "version": "1.10.0", - "source": { - "type": "git", - "url": "https://github.com/webmozarts/assert.git", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/webmozarts/assert/zipball/6964c76c7804814a842473e0c8fd15bab0f18e25", - "reference": "6964c76c7804814a842473e0c8fd15bab0f18e25", - "shasum": "" - }, - "require": { - "php": "^7.2 || ^8.0", - "symfony/polyfill-ctype": "^1.8" - }, - "conflict": { - "phpstan/phpstan": "<0.12.20", - "vimeo/psalm": "<4.6.1 || 4.6.2" - }, - "require-dev": { - "phpunit/phpunit": "^8.5.13" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.10-dev" - } - }, - "autoload": { - "psr-4": { - "Webmozart\\Assert\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Bernhard Schussek", - "email": "bschussek@gmail.com" - } - ], - "description": "Assertions to validate method input/output with nice error messages.", - "keywords": [ - "assert", - "check", - "validate" - ], - "support": { - "issues": "https://github.com/webmozarts/assert/issues", - "source": "https://github.com/webmozarts/assert/tree/1.10.0" - }, - "time": "2021-03-09T10:59:23+00:00" } ], "aliases": [], @@ -2232,5 +2764,5 @@ "ext-json": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.3.0" } diff --git a/init.php b/init.php index c65edd4..d8f1cd6 100644 --- a/init.php +++ b/init.php @@ -15,6 +15,9 @@ require __DIR__ . '/lib/Services/ServiceFactory.php'; require __DIR__ . '/lib/Services/OrderService.php'; require __DIR__ . '/lib/Services/PublicService.php'; +require __DIR__ . '/lib/Services/RefundService.php'; +require __DIR__ . '/lib/Services/LedgerService.php'; +require __DIR__ . '/lib/Services/WithdrawalService.php'; // Exceptions require __DIR__ . '/lib/Exception/ApiConnectionException.php'; @@ -33,3 +36,7 @@ require __DIR__ . '/lib/Exception/Api/OrderNotFound.php'; require __DIR__ . '/lib/Exception/Api/Unauthorized.php'; require __DIR__ . '/lib/Exception/Api/UnprocessableEntity.php'; +require __DIR__ . '/lib/Exception/Api/RefundIsNotValid.php'; +require __DIR__ . '/lib/Exception/Api/RefundNotFound.php'; +require __DIR__ . '/lib/Exception/Api/LedgerAccountNotFound.php'; +require __DIR__ . '/lib/Exception/Api/WithdrawalNotFound.php'; diff --git a/lib/BaseClient.php b/lib/BaseClient.php index 1469cc0..a0ede9f 100644 --- a/lib/BaseClient.php +++ b/lib/BaseClient.php @@ -7,8 +7,12 @@ use CoinGate\Exception\Api\NotFound; use CoinGate\Exception\Api\OrderIsNotValid; use CoinGate\Exception\Api\OrderNotFound; +use CoinGate\Exception\Api\RefundIsNotValid; +use CoinGate\Exception\Api\RefundNotFound; +use CoinGate\Exception\Api\LedgerAccountNotFound; use CoinGate\Exception\Api\Unauthorized; use CoinGate\Exception\Api\UnprocessableEntity; +use CoinGate\Exception\Api\WithdrawalNotFound; use CoinGate\Exception\ApiErrorException; use CoinGate\Exception\InvalidArgumentException; use CoinGate\Exception\InternalServerError; @@ -18,12 +22,18 @@ use CoinGate\HttpClient\CurlClient; use CoinGate\Services\OrderService; use CoinGate\Services\PublicService; +use CoinGate\Services\RefundService; +use CoinGate\Services\LedgerService; +use CoinGate\Services\WithdrawalService; use Exception; /** * Client used to send requests to CoinGate's API * * @property OrderService $order + * @property RefundService $refund + * @property LedgerService $ledger + * @property WithdrawalService $withdrawal * @mixin PublicService */ class BaseClient implements ClientInterface @@ -31,7 +41,7 @@ class BaseClient implements ClientInterface /** * @var string */ - public const VERSION = '4.1.0'; + public const VERSION = '4.2.0'; /** * @var string default base URL for CoinBase's API @@ -293,14 +303,26 @@ public function handleErrorResponse($response, int $httpStatus) } } elseif ($httpStatus === 404) { switch ($reason) { + case 'RefundNotFound': + throw RefundNotFound::factory($response, $httpStatus); + + case 'LedgerAccountNotFound': + throw LedgerAccountNotFound::factory($response, $httpStatus); + case 'OrderNotFound': throw OrderNotFound::factory($response, $httpStatus); + case 'WithdrawalNotFound': + throw WithdrawalNotFound::factory($response, $httpStatus); + default: throw NotFound::factory($response, $httpStatus); } } elseif ($httpStatus === 422) { switch ($reason) { + case 'RefundIsNotValid': + throw RefundIsNotValid::factory($response, $httpStatus); + case 'OrderIsNotValid': throw OrderIsNotValid::factory($response, $httpStatus); diff --git a/lib/Exception/Api/LedgerAccountNotFound.php b/lib/Exception/Api/LedgerAccountNotFound.php new file mode 100644 index 0000000..149b0c8 --- /dev/null +++ b/lib/Exception/Api/LedgerAccountNotFound.php @@ -0,0 +1,12 @@ +request('get', $this->buildPath('/v2/ledger/accounts/%s', $id)); + } + + /** + * Retrieves all ledger accounts. + * + * @param string[] $params + * @return mixed + */ + public function list(array $params = []) + { + return $this->request('get', '/v2/ledger/accounts', $params); + } +} diff --git a/lib/Services/RefundService.php b/lib/Services/RefundService.php new file mode 100644 index 0000000..c70e81a --- /dev/null +++ b/lib/Services/RefundService.php @@ -0,0 +1,46 @@ +request('post', $this->buildPath('/v2/orders/%s/refunds', $orderId), $params); + } + + /** + * Retrieves a specific refund for an order. + * + * @param int $orderId + * @param int $id + * @return mixed + */ + public function get(int $orderId, int $id) + { + return $this->request('get', $this->buildPath('/v2/orders/%s/refunds/%s', $orderId, $id)); + } + + /** + * Retrieves all refunds (optionally could be filtered by an order). + * + * @param int|null $orderId + * @param string[] $params + * @return mixed + */ + public function list(int $orderId = null, array $params = []) + { + if ($orderId === null) { + return $this->request('get', '/v2/refunds', $params); + } + + return $this->request('get', $this->buildPath('/v2/orders/%s/refunds', $orderId), $params); + } +} diff --git a/lib/Services/ServiceFactory.php b/lib/Services/ServiceFactory.php index e6a5c5b..50070c8 100644 --- a/lib/Services/ServiceFactory.php +++ b/lib/Services/ServiceFactory.php @@ -14,7 +14,10 @@ class ServiceFactory extends AbstractServiceFactory * @var array */ private static $classMap = [ - 'order' => OrderService::class + 'order' => OrderService::class, + 'refund' => RefundService::class, + 'ledger' => LedgerService::class, + 'withdrawal' => WithdrawalService::class ]; /** diff --git a/lib/Services/WithdrawalService.php b/lib/Services/WithdrawalService.php new file mode 100644 index 0000000..84da39e --- /dev/null +++ b/lib/Services/WithdrawalService.php @@ -0,0 +1,27 @@ +request('get', $this->buildPath('/v2/withdrawals/%s', $id)); + } + + /** + * Retrieves all withdrawals + * + * @return mixed + */ + public function list() + { + return $this->request('get', '/v2/withdrawals'); + } +} diff --git a/tests/CoinGate/Services/LedgerServiceTest.php b/tests/CoinGate/Services/LedgerServiceTest.php new file mode 100644 index 0000000..710a66c --- /dev/null +++ b/tests/CoinGate/Services/LedgerServiceTest.php @@ -0,0 +1,76 @@ +mockHttpClient = $this->mockHttpClient(); + + $client = $this->createSandboxClient($this->mockHttpClient); + + $this->service = new LedgerService($client); + } + + public function testGetLedgerAccount() + { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'id' => '01G0EM0RRVREB4WD5KDB6VJVPM' + ]), + 200 + ]); + + $account = $this->service->get('01G0EM0RRVREB4WD5KDB6VJVPM'); + + $this->assertObjectHasAttribute('id', $account); + } + + public function testNotFoundGetLedgerAccount() + { + $this->mockHttpClient + ->method('request') + ->willThrowException( + \CoinGate\Exception\Api\LedgerAccountNotFound::factory('Ledger Account not found', 404) + ); + + $this->expectException(\CoinGate\Exception\Api\LedgerAccountNotFound::class); + + $this->service->get('01G0EM0RRVREB4WD5KDB6VJVPM'); + } + + public function testListLedgerAccounts() + { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'current_page' => 1, + 'per_page' => 20, + 'total_accounts' => 1, + 'total_pages' => 1, + 'accounts' => [ + [ 'id' => '01G0EM0RRVREB4WD5KDB6VJVPM' ] + ] + ]), + 200 + ]); + + $response = $this->service->list(); + + $this->assertNotEmpty($response); + } +} diff --git a/tests/CoinGate/Services/OrderServiceTest.php b/tests/CoinGate/Services/OrderServiceTest.php index 537a284..2d8c68f 100644 --- a/tests/CoinGate/Services/OrderServiceTest.php +++ b/tests/CoinGate/Services/OrderServiceTest.php @@ -6,7 +6,9 @@ class OrderServiceTest extends TestCase { - /** @var OrderService */ + private $mockHttpClient; + + /** @var \CoinGate\Services\OrderService */ private $service; /** @@ -14,26 +16,54 @@ class OrderServiceTest extends TestCase */ protected function setUpService() { - $client = $this->createSandboxClient(); + $this->mockHttpClient = $this->mockHttpClient(); + + $client = $this->createSandboxClient($this->mockHttpClient); $this->service = new OrderService($client); } public function testCreateOrder() { - $params = self::getGoodPostParams(); - - $order = $this->service->create($params); + $myCustomOrderId = 'YOUR-CUSTOM-ORDER-ID-115'; + + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'id' => 1, + 'order_id' => $myCustomOrderId + ]), + 200 + ]); + + $order = $this->service->create([ + 'order_id' => $myCustomOrderId, + 'price_amount' => 1050.99, + 'price_currency' => 'USD', + 'receive_currency' => 'EUR', + 'callback_url' => 'https://example.com/payments?token=6tCENGUYI62ojkuzDPX7Jg', + 'cancel_url' => 'https://example.com/cart', + 'success_url' => 'https://example.com/account/orders', + 'title' => 'Order #112', + 'description' => 'Apple Iphone 6' + ]); $this->assertObjectHasAttribute('id', $order); - $this->assertSame($order->order_id, $params['order_id']); + $this->assertSame($order->order_id, $myCustomOrderId); return $order; } public function testInvalidCreateOrder() { - $this->expectException('CoinGate\Exception\Api\OrderIsNotValid'); + $this->mockHttpClient + ->method('request') + ->willThrowException( + \CoinGate\Exception\Api\OrderIsNotValid::factory('Order is not valid', 422) + ); + + $this->expectException(\CoinGate\Exception\Api\OrderIsNotValid::class); $this->service->create([]); } @@ -43,6 +73,15 @@ public function testInvalidCreateOrder() */ public function testCheckout($order) { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'id' => $order->id + ]), + 200 + ]); + $response = $this->service->checkout($order->id, [ 'pay_currency' => 'BTC' ]); @@ -50,9 +89,15 @@ public function testCheckout($order) $this->assertSame($order->id, $response->id); } - public function testInvalidCheckout() + public function testNotFoundCheckout() { - $this->expectException('CoinGate\Exception\Api\OrderNotFound'); + $this->mockHttpClient + ->method('request') + ->willThrowException( + \CoinGate\Exception\Api\OrderNotFound::factory('Order not found', 404) + ); + + $this->expectException(\CoinGate\Exception\Api\OrderNotFound::class); $this->service->checkout(0, [ 'pay_currency' => 'BTC' @@ -64,20 +109,50 @@ public function testInvalidCheckout() */ public function testGetOrder($order) { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'id' => $order->id + ]), + 200 + ]); + $response = $this->service->get($order->id); $this->assertSame($order->id, $response->id); } - public function testInvalidGetOrder() + public function testNotFoundGetOrder() { - $this->expectException('CoinGate\Exception\Api\OrderNotFound'); + $this->mockHttpClient + ->method('request') + ->willThrowException( + \CoinGate\Exception\Api\OrderNotFound::factory('Order not found', 404) + ); + + $this->expectException(\CoinGate\Exception\Api\OrderNotFound::class); $this->service->get(0); } public function testListOrders() { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'current_page' => 1, + 'per_page' => 20, + 'total_orders' => 1, + 'total_pages' => 1, + 'orders' => [ + [ 'id' => 1 ] + ] + ]), + 200 + ]); + $response = $this->service->list([ 'created_at' => [ 'from' => '2022-01-25' @@ -86,19 +161,4 @@ public function testListOrders() $this->assertNotEmpty($response); } - - public static function getGoodPostParams(): array - { - return [ - 'order_id' => 'YOUR-CUSTOM-ORDER-ID-115', - 'price_amount' => 1050.99, - 'price_currency' => 'USD', - 'receive_currency' => 'EUR', - 'callback_url' => 'https://example.com/payments?token=6tCENGUYI62ojkuzDPX7Jg', - 'cancel_url' => 'https://example.com/cart', - 'success_url' => 'https://example.com/account/orders', - 'title' => 'Order #112', - 'description' => 'Apple Iphone 6' - ]; - } } diff --git a/tests/CoinGate/Services/RefundServiceTest.php b/tests/CoinGate/Services/RefundServiceTest.php new file mode 100644 index 0000000..d2c67f6 --- /dev/null +++ b/tests/CoinGate/Services/RefundServiceTest.php @@ -0,0 +1,129 @@ +mockHttpClient = $this->mockHttpClient(); + + $client = $this->createSandboxClient($this->mockHttpClient); + + $this->service = new RefundService($client); + } + + public function testCreateOrderRefund() + { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'id' => 1 + ]), + 200 + ]); + + $refund = $this->service->create($this->orderId, []); + + $this->assertObjectHasAttribute('id', $refund); + + return $refund; + } + + public function testInvalidCreateRefundOrder() + { + $this->mockHttpClient + ->method('request') + ->willThrowException( + \CoinGate\Exception\Api\RefundIsNotValid::factory('Refund is not valid', 422) + ); + + $this->expectException(\CoinGate\Exception\Api\RefundIsNotValid::class); + + $this->service->create($this->orderId, []); + } + + /** + * @depends testCreateOrderRefund + */ + public function testGetOrderRefund($refund) + { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'id' => $refund->id + ]), + 200 + ]); + + $response = $this->service->get($this->orderId, $refund->id); + + $this->assertSame($refund->id, $response->id); + } + + public function testNotFoundGetOrderRefund() + { + $this->mockHttpClient + ->method('request') + ->willThrowException( + \CoinGate\Exception\Api\RefundNotFound::factory('Refund not found', 404) + ); + + $this->expectException(\CoinGate\Exception\Api\RefundNotFound::class); + + $this->service->get($this->orderId, 0); + } + + public function testGetOrderRefundsOrRefunds() + { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'current_page' => 1, + 'per_page' => 20, + 'total_refunds' => 1, + 'total_pages' => 1, + 'refunds' => [ + [ 'id' => 1 ] + ] + ]), + 200 + ]); + + $response = $this->service->list($this->orderId); + + $this->assertNotEmpty($response); + + $response = $this->service->list(); + + $this->assertNotEmpty($response); + } + + public function testNotFoundGetOrderRefunds() + { + $this->mockHttpClient + ->method('request') + ->willThrowException( + \CoinGate\Exception\Api\RefundNotFound::factory('Refund not found', 404) + ); + + $this->expectException(\CoinGate\Exception\Api\RefundNotFound::class); + + $this->service->list(0); + } +} diff --git a/tests/CoinGate/Services/WithdrawalServiceTest.php b/tests/CoinGate/Services/WithdrawalServiceTest.php new file mode 100644 index 0000000..1006794 --- /dev/null +++ b/tests/CoinGate/Services/WithdrawalServiceTest.php @@ -0,0 +1,76 @@ +mockHttpClient = $this->mockHttpClient(); + + $client = $this->createSandboxClient($this->mockHttpClient); + + $this->service = new WithdrawalService($client); + } + + public function testGetWithdrawal() + { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'id' => '10' + ]), + 200 + ]); + + $withdrawal = $this->service->get(10); + + $this->assertObjectHasAttribute('id', $withdrawal); + } + + public function testNotFoundWithdrawal() + { + $this->mockHttpClient + ->method('request') + ->willThrowException( + \CoinGate\Exception\Api\WithdrawalNotFound::factory('Withdrawal does not exist', 404) + ); + + $this->expectException(\CoinGate\Exception\Api\WithdrawalNotFound::class); + + $this->service->get(10); + } + + public function testWithdrawals() + { + $this->mockHttpClient + ->method('request') + ->willReturn([ + json_encode([ + 'current_page' => 1, + 'per_page' => 20, + 'total_withdrawal' => 1, + 'total_pages' => 1, + 'withdrawals' => [ + [ 'id' => 1 ] + ] + ]), + 200 + ]); + + $response = $this->service->list(); + + $this->assertNotEmpty($response); + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index ebb7d15..5fd8c29 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,12 +2,23 @@ namespace CoinGate; +use CoinGate\HttpClient\CurlClient; + class TestCase extends \PHPUnit\Framework\TestCase { public const APIKEY = '-Lj8CYksfaJw_VwoCPMEPUKiLDnFFGKz7szNKXYp'; - protected function createSandboxClient(): Client + protected function mockHttpClient() { + return $this->createMock(CurlClient::class); + } + + protected function createSandboxClient($httpClient = null): Client + { + if ($httpClient !== null) { + Client::setHttpClient($httpClient); + } + return new Client(self::APIKEY, true); } }