From aa25afbf88779647f218d1cffc8e1325a9718c13 Mon Sep 17 00:00:00 2001 From: Alexandr Volga Date: Fri, 31 May 2024 16:49:24 +0300 Subject: [PATCH 1/8] Add files via upload --- src/Resources/Identity.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 src/Resources/Identity.php diff --git a/src/Resources/Identity.php b/src/Resources/Identity.php new file mode 100644 index 0000000..bd0ce74 --- /dev/null +++ b/src/Resources/Identity.php @@ -0,0 +1,30 @@ + $options + * @throws PlaidRequestException + * @return object + */ + public function get(string $access_token, array $options = []): object + { + $params = [ + "access_token" => $access_token, + "options" => (object) $options + ]; + + return $this->sendRequest( + "post", + "identity/get", + $this->paramsWithClientCredentials($params) + ); + } +} \ No newline at end of file From 72e9990ef65d7c2065f1b5cc59b57f63cc2991a9 Mon Sep 17 00:00:00 2001 From: Alexandr Volga Date: Fri, 31 May 2024 16:50:28 +0300 Subject: [PATCH 2/8] add identity resource --- src/Plaid.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plaid.php b/src/Plaid.php index 73d1fe8..33f1a7a 100644 --- a/src/Plaid.php +++ b/src/Plaid.php @@ -13,6 +13,7 @@ * @property \TomorrowIdeas\Plaid\Resources\Auth $auth * @property \TomorrowIdeas\Plaid\Resources\BankTransfers $bank_transfers * @property \TomorrowIdeas\Plaid\Resources\Categories $categories + * @property \TomorrowIdeas\Plaid\Resources\Identity $identity * @property \TomorrowIdeas\Plaid\Resources\Institutions $institutions * @property \TomorrowIdeas\Plaid\Resources\Investments $investments * @property \TomorrowIdeas\Plaid\Resources\Items $items From 3b1997817d2d444be45b7a0ef2799bc6e0a04e8c Mon Sep 17 00:00:00 2001 From: Alexandr Volga Date: Fri, 31 May 2024 17:05:05 +0300 Subject: [PATCH 3/8] Update Identity.php --- src/Resources/Identity.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Resources/Identity.php b/src/Resources/Identity.php index bd0ce74..48214f1 100644 --- a/src/Resources/Identity.php +++ b/src/Resources/Identity.php @@ -7,7 +7,7 @@ class Identity extends AbstractResource { /** - * Get Auth request. + * Get Identity request. * * @param string $access_token * @param array $options @@ -27,4 +27,4 @@ public function get(string $access_token, array $options = []): object $this->paramsWithClientCredentials($params) ); } -} \ No newline at end of file +} From 311138baa47e2b3d3db02e57f2530f5b8922ac3a Mon Sep 17 00:00:00 2001 From: Alexandr Volga Date: Fri, 11 Oct 2024 16:13:08 +0300 Subject: [PATCH 4/8] Update composer.json - Dropping support for PHP 7.x - bump nimbly/Shuttle --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index ee61ade..7b24cb0 100644 --- a/composer.json +++ b/composer.json @@ -8,10 +8,10 @@ ], "type": "library", "require": { - "php": ">=7.3|>=8.0", + "php": ">=8.0", "ext-json": "*", "ext-curl": "*", - "nimbly/shuttle": "^0.4" + "nimbly/shuttle": "^1.0" }, "autoload": { "psr-4": { From b85c67c05c3b52d236111fbf74d988f259b246cd Mon Sep 17 00:00:00 2001 From: Alexandr Volga Date: Tue, 5 Nov 2024 17:48:25 +0200 Subject: [PATCH 5/8] Fix Shuttle import --- src/Plaid.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plaid.php b/src/Plaid.php index 33f1a7a..2bfaccd 100644 --- a/src/Plaid.php +++ b/src/Plaid.php @@ -4,7 +4,7 @@ use Psr\Http\Client\ClientInterface; use ReflectionClass; -use Shuttle\Shuttle; +use Nimbly\Shuttle; use TomorrowIdeas\Plaid\Resources\AbstractResource; use UnexpectedValueException; From 6d6000139f176558a63edc86274376b2140f19ba Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 5 Nov 2024 18:02:42 +0200 Subject: [PATCH 6/8] Fix Shuttle namespace --- src/Plaid.php | 2 +- tests/AbstractResourceTest.php | 2 +- tests/PlaidClientTest.php | 2 +- tests/ReportsTest.php | 2 +- tests/TestCase.php | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Plaid.php b/src/Plaid.php index 2bfaccd..1bad4bb 100644 --- a/src/Plaid.php +++ b/src/Plaid.php @@ -2,9 +2,9 @@ namespace TomorrowIdeas\Plaid; +use Nimbly\Shuttle\Shuttle; use Psr\Http\Client\ClientInterface; use ReflectionClass; -use Nimbly\Shuttle; use TomorrowIdeas\Plaid\Resources\AbstractResource; use UnexpectedValueException; diff --git a/tests/AbstractResourceTest.php b/tests/AbstractResourceTest.php index ec9bfbb..db664df 100644 --- a/tests/AbstractResourceTest.php +++ b/tests/AbstractResourceTest.php @@ -6,7 +6,7 @@ use Capsule\Response; use Capsule\ResponseStatus; use Shuttle\Handler\MockHandler; -use Shuttle\Shuttle; +use Nimbly\Shuttle\Shuttle; use TomorrowIdeas\Plaid\Plaid; use TomorrowIdeas\Plaid\PlaidRequestException; use UnexpectedValueException; diff --git a/tests/PlaidClientTest.php b/tests/PlaidClientTest.php index 9890ada..2345642 100644 --- a/tests/PlaidClientTest.php +++ b/tests/PlaidClientTest.php @@ -3,7 +3,7 @@ namespace TomorrowIdeas\Plaid\Tests; use ReflectionClass; -use Shuttle\Shuttle; +use Nimbly\Shuttle\Shuttle; use TomorrowIdeas\Plaid\Plaid; use UnexpectedValueException; diff --git a/tests/ReportsTest.php b/tests/ReportsTest.php index 3bb79d6..0c304be 100644 --- a/tests/ReportsTest.php +++ b/tests/ReportsTest.php @@ -4,7 +4,7 @@ use Capsule\Response; use Shuttle\Handler\MockHandler; -use Shuttle\Shuttle; +use Nimbly\Shuttle\Shuttle; use TomorrowIdeas\Plaid\Plaid; use TomorrowIdeas\Plaid\PlaidRequestException; diff --git a/tests/TestCase.php b/tests/TestCase.php index 2003681..cb4aafe 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -6,7 +6,7 @@ use Capsule\Response; use PHPUnit\Framework\TestCase as PHPUnitTestCase; use Shuttle\Handler\MockHandler; -use Shuttle\Shuttle; +use Nimbly\Shuttle\Shuttle; use TomorrowIdeas\Plaid\Plaid; abstract class TestCase extends PHPUnitTestCase From ceae6dac59fc8b378990c55ab90a7113f4fc3b6c Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 6 Nov 2024 09:15:52 +0200 Subject: [PATCH 7/8] Fix Shuttle namespace --- .travis.yml | 3 +- composer.json | 3 +- src/Resources/AbstractResource.php | 2 +- tests/AbstractResourceTest.php | 76 +++++++++++++---------------- tests/PlaidRequestExceptionTest.php | 2 +- tests/ReportsTest.php | 16 +++--- tests/TestCase.php | 22 ++++----- 7 files changed, 55 insertions(+), 69 deletions(-) diff --git a/.travis.yml b/.travis.yml index cd49215..6e1e57b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,8 @@ language: php php: - - '7.3' - - '7.4' - '8.0' - '8.1' + - '8.2' install: - composer install diff --git a/composer.json b/composer.json index 7b24cb0..4512589 100644 --- a/composer.json +++ b/composer.json @@ -19,8 +19,7 @@ } }, "require-dev": { - "phpunit/phpunit": "^9.0", - "vimeo/psalm": "^4.0", + "phpunit/phpunit": "^10.0", "symfony/var-dumper": "^4.2", "php-coveralls/php-coveralls": "^2.1" }, diff --git a/src/Resources/AbstractResource.php b/src/Resources/AbstractResource.php index 07d5e3a..7446265 100644 --- a/src/Resources/AbstractResource.php +++ b/src/Resources/AbstractResource.php @@ -2,7 +2,7 @@ namespace TomorrowIdeas\Plaid\Resources; -use Capsule\Request; +use Nimbly\Capsule\Request; use Psr\Http\Client\ClientInterface; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; diff --git a/tests/AbstractResourceTest.php b/tests/AbstractResourceTest.php index db664df..9f74fa6 100644 --- a/tests/AbstractResourceTest.php +++ b/tests/AbstractResourceTest.php @@ -2,10 +2,10 @@ namespace TomorrowIdeas\Plaid\Tests; -use Capsule\Request; -use Capsule\Response; -use Capsule\ResponseStatus; -use Shuttle\Handler\MockHandler; +use Nimbly\Capsule\Request; +use Nimbly\Capsule\Response; +use Nimbly\Capsule\ResponseStatus; +use Nimbly\Shuttle\Handler\MockHandler; use Nimbly\Shuttle\Shuttle; use TomorrowIdeas\Plaid\Plaid; use TomorrowIdeas\Plaid\PlaidRequestException; @@ -16,7 +16,7 @@ * @covers TomorrowIdeas\Plaid\Resources\AbstractResource * @covers TomorrowIdeas\Plaid\Resources\Items * @covers TomorrowIdeas\Plaid\PlaidRequestException - * @uses TomorrowIdeas\Plaid\PlaidException + * @uses TomorrowIdeas\Plaid\PlaidException */ class AbstractResourceTest extends TestCase { @@ -26,40 +26,37 @@ public function test_build_request_with_no_params_sends_empty_object_in_body(): $reflectionClass = new \ReflectionClass($itemsResource); - $method = $reflectionClass->getMethod("buildRequest"); + $method = $reflectionClass->getMethod("buildRequest"); $method->setAccessible(true); $request = $method->invokeArgs($itemsResource, ["post", "/endpoint"]); $this->assertEquals( - (object) [], + (object)[], \json_decode($request->getBody()->getContents()) ); } public function test_request_exception_passes_through_plaid_display_message(): void { - $httpClient = new Shuttle([ - 'handler' => new MockHandler([ - function(Request $request) { - + $httpClient = new Shuttle( + new MockHandler([ + function (Request $request) { $requestParams = [ "display_message" => "DISPLAY MESSAGE", ]; return new Response(300, \json_encode($requestParams)); - - } + }, ]) - ]); + ); $plaid = new Plaid("client_id", "secret"); $plaid->setHttpClient($httpClient); try { $plaid->items->get("access_token"); - } - catch( PlaidRequestException $plaidRequestException ){ + } catch (PlaidRequestException $plaidRequestException) { $this->assertEquals("DISPLAY MESSAGE", $plaidRequestException->getMessage()); @@ -68,27 +65,24 @@ function(Request $request) { public function test_request_exception_passes_through_http_status_code(): void { - $httpClient = new Shuttle([ - 'handler' => new MockHandler([ - function(Request $request) { - + $httpClient = new Shuttle( + new MockHandler([ + function (Request $request) { $requestParams = [ "display_message" => "DISPLAY MESSAGE", ]; return new Response(300, \json_encode($requestParams)); - - } + }, ]) - ]); + ); $plaid = new Plaid("client_id", "secret"); $plaid->setHttpClient($httpClient); try { $plaid->items->get("access_token"); - } - catch( PlaidRequestException $plaidRequestException ){ + } catch (PlaidRequestException $plaidRequestException) { $this->assertEquals(300, $plaidRequestException->getCode()); @@ -97,10 +91,9 @@ function(Request $request) { public function test_1xx_responses_throw_exception(): void { - $httpClient = new Shuttle([ - 'handler' => new MockHandler([ - function(Request $request) { - + $httpClient = new Shuttle( + new MockHandler([ + function (Request $request) { $requestParams = [ "method" => $request->getMethod(), "version" => $request->getHeaderLine("Plaid-Version"), @@ -112,10 +105,9 @@ function(Request $request) { ]; return new Response(100, \json_encode($requestParams)); - - } + }, ]) - ]); + ); $plaid = new Plaid("client_id", "secret"); $plaid->setHttpClient($httpClient); @@ -126,19 +118,17 @@ function(Request $request) { public function test_3xx_responses_and_above_throw_exception(): void { - $httpClient = new Shuttle([ - 'handler' => new MockHandler([ - function(Request $request) { - + $httpClient = new Shuttle( + new MockHandler([ + function (Request $request) { $requestParams = [ "display_message" => "PLAID_ERROR", ]; return new Response(300, \json_encode($requestParams)); - - } + }, ]) - ]); + ); $plaid = new Plaid("client_id", "secret"); $plaid->setHttpClient($httpClient); @@ -149,11 +139,11 @@ function(Request $request) { public function test_invalid_json_when_parsing_response(): void { - $httpClient = new Shuttle([ - 'handler' => new MockHandler([ - new Response(ResponseStatus::OK, "invalid_json") + $httpClient = new Shuttle( + new MockHandler([ + new Response(ResponseStatus::OK, "invalid_json"), ]) - ]); + ); $plaid = new Plaid("client_id", "secret"); $plaid->setHttpClient($httpClient); diff --git a/tests/PlaidRequestExceptionTest.php b/tests/PlaidRequestExceptionTest.php index 79303a6..fb30d95 100644 --- a/tests/PlaidRequestExceptionTest.php +++ b/tests/PlaidRequestExceptionTest.php @@ -2,7 +2,7 @@ namespace TomorrowIdeas\Plaid\Tests; -use Capsule\Response; +use Nimbly\Capsule\Response; use TomorrowIdeas\Plaid\PlaidRequestException; /** diff --git a/tests/ReportsTest.php b/tests/ReportsTest.php index 0c304be..ae31df3 100644 --- a/tests/ReportsTest.php +++ b/tests/ReportsTest.php @@ -2,8 +2,8 @@ namespace TomorrowIdeas\Plaid\Tests; -use Capsule\Response; -use Shuttle\Handler\MockHandler; +use Nimbly\Capsule\Response; +use Nimbly\Shuttle\Handler\MockHandler; use Nimbly\Shuttle\Shuttle; use TomorrowIdeas\Plaid\Plaid; use TomorrowIdeas\Plaid\PlaidRequestException; @@ -28,7 +28,7 @@ public function test_create_asset_report(): void $this->assertEquals("secret", $response->params->secret); $this->assertEquals(["access_token1", "access_token2"], $response->params->access_tokens); $this->assertEquals(30, $response->params->days_requested); - $this->assertEquals((object) [], $response->params->options); + $this->assertEquals((object)[], $response->params->options); } public function test_refresh_asset_report(): void @@ -43,7 +43,7 @@ public function test_refresh_asset_report(): void $this->assertEquals("secret", $response->params->secret); $this->assertEquals("asset_report_token", $response->params->asset_report_token); $this->assertEquals(30, $response->params->days_requested); - $this->assertEquals((object) [], $response->params->options); + $this->assertEquals((object)[], $response->params->options); } public function test_filter_asset_report(): void @@ -90,11 +90,11 @@ public function test_get_asset_report_pdf(): void public function test_get_asset_report_pdf_throws_on_fail(): void { - $httpClient = new Shuttle([ - 'handler' => new MockHandler([ - new Response(400, "Bad Request") + $httpClient = new Shuttle( + new MockHandler([ + new Response(400, "Bad Request"), ]) - ]); + ); $plaid = new Plaid("client_id", "secret"); $plaid->setHttpClient($httpClient); diff --git a/tests/TestCase.php b/tests/TestCase.php index cb4aafe..5876028 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -2,21 +2,20 @@ namespace TomorrowIdeas\Plaid\Tests; -use Capsule\Request; -use Capsule\Response; -use PHPUnit\Framework\TestCase as PHPUnitTestCase; -use Shuttle\Handler\MockHandler; +use Nimbly\Capsule\Request; +use Nimbly\Capsule\Response; +use Nimbly\Shuttle\Handler\MockHandler; use Nimbly\Shuttle\Shuttle; +use PHPUnit\Framework\TestCase as PHPUnitTestCase; use TomorrowIdeas\Plaid\Plaid; abstract class TestCase extends PHPUnitTestCase { protected function getPlaidClient(string $environment = "production"): Plaid { - $httpClient = new Shuttle([ - 'handler' => new MockHandler([ - function(Request $request) { - + $httpClient = new Shuttle( + new MockHandler([ + function (Request $request) { $requestParams = [ "method" => $request->getMethod(), "version" => $request->getHeaderLine("Plaid-Version"), @@ -28,10 +27,9 @@ function(Request $request) { ]; return new Response(200, \json_encode($requestParams)); - - } - ]) - ]); + }, + ]), + ); $plaid = new Plaid("client_id", "secret", $environment); $plaid->setHttpClient($httpClient); From 5a776f5acef71fd2b3b52a7f5620d3c067c6d168 Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 6 Nov 2024 09:34:37 +0200 Subject: [PATCH 8/8] Fix phpunit version --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 4512589..dc1b697 100644 --- a/composer.json +++ b/composer.json @@ -19,7 +19,7 @@ } }, "require-dev": { - "phpunit/phpunit": "^10.0", + "phpunit/phpunit": "^9.0", "symfony/var-dumper": "^4.2", "php-coveralls/php-coveralls": "^2.1" },