Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ build/
vendor/
.vscode/
composer.lock
.phpunit.result.cache
.idea
.phpunit.result.cache
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
language: php
php:
- '7.3'
- '7.4'
- '8.0'
- '8.1'

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -439,4 +439,10 @@ $payment_schedule = new TomorrowIdeas\Plaid\Entities\PaymnentSchedule(

## Errors

All unsuccessfull (non 2xx) responses will throw a `PlaidRequestException`. The full response object is available via the `getResponse()` method.
All unsuccessfull (non 2xx) responses will throw a `PlaidRequestException`. The full response object is available via the `getResponse()` method.

## Contributing

### Testing

```./vendor/bin/phpunit tests```
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion src/Plaid.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace TomorrowIdeas\Plaid;

use Nimbly\Shuttle\Shuttle;
use Psr\Http\Client\ClientInterface;
use ReflectionClass;
use Shuttle\Shuttle;
use TomorrowIdeas\Plaid\Resources\AbstractResource;
use UnexpectedValueException;

Expand Down
2 changes: 1 addition & 1 deletion src/Resources/AbstractResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
52 changes: 23 additions & 29 deletions tests/AbstractResourceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@

namespace TomorrowIdeas\Plaid\Tests;

use Capsule\Request;
use Capsule\Response;
use Capsule\ResponseStatus;
use Shuttle\Handler\MockHandler;
use Shuttle\Shuttle;
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;
use UnexpectedValueException;
Expand Down Expand Up @@ -39,19 +39,17 @@ public function test_build_request_with_no_params_sends_empty_object_in_body():

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);
Expand All @@ -68,19 +66,17 @@ 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);
Expand All @@ -97,10 +93,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"),
Expand All @@ -112,10 +107,9 @@ function(Request $request) {
];

return new Response(100, \json_encode($requestParams));

}
])
]);
);

$plaid = new Plaid("client_id", "secret");
$plaid->setHttpClient($httpClient);
Expand All @@ -126,8 +120,8 @@ function(Request $request) {

public function test_3xx_responses_and_above_throw_exception(): void
{
$httpClient = new Shuttle([
'handler' => new MockHandler([
$httpClient = new Shuttle(
new MockHandler([
function(Request $request) {

$requestParams = [
Expand All @@ -138,7 +132,7 @@ function(Request $request) {

}
])
]);
);

$plaid = new Plaid("client_id", "secret");
$plaid->setHttpClient($httpClient);
Expand All @@ -149,11 +143,11 @@ function(Request $request) {

public function test_invalid_json_when_parsing_response(): void
{
$httpClient = new Shuttle([
'handler' => new MockHandler([
$httpClient = new Shuttle(
new MockHandler([
new Response(ResponseStatus::OK, "invalid_json")
])
]);
);

$plaid = new Plaid("client_id", "secret");
$plaid->setHttpClient($httpClient);
Expand Down
2 changes: 1 addition & 1 deletion tests/PlaidClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace TomorrowIdeas\Plaid\Tests;

use Nimbly\Shuttle\Shuttle;
use ReflectionClass;
use Shuttle\Shuttle;
use TomorrowIdeas\Plaid\Plaid;
use UnexpectedValueException;

Expand Down
2 changes: 1 addition & 1 deletion tests/PlaidRequestExceptionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace TomorrowIdeas\Plaid\Tests;

use Capsule\Response;
use Nimbly\Capsule\Response;
use TomorrowIdeas\Plaid\PlaidRequestException;

/**
Expand Down
12 changes: 6 additions & 6 deletions tests/ReportsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace TomorrowIdeas\Plaid\Tests;

use Capsule\Response;
use Shuttle\Handler\MockHandler;
use Shuttle\Shuttle;
use Nimbly\Capsule\Response;
use Nimbly\Shuttle\Handler\MockHandler;
use Nimbly\Shuttle\Shuttle;
use TomorrowIdeas\Plaid\Plaid;
use TomorrowIdeas\Plaid\PlaidRequestException;

Expand Down Expand Up @@ -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([
$httpClient = new Shuttle(
new MockHandler([
new Response(400, "Bad Request")
])
]);
);

$plaid = new Plaid("client_id", "secret");
$plaid->setHttpClient($httpClient);
Expand Down
18 changes: 8 additions & 10 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@

namespace TomorrowIdeas\Plaid\Tests;

use Capsule\Request;
use Capsule\Response;
use Nimbly\Capsule\Request;
use Nimbly\Capsule\Response;
use Nimbly\Shuttle\Handler\MockHandler;
use Nimbly\Shuttle\Shuttle;
use PHPUnit\Framework\TestCase as PHPUnitTestCase;
use Shuttle\Handler\MockHandler;
use Shuttle\Shuttle;
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"),
Expand All @@ -28,10 +27,9 @@ function(Request $request) {
];

return new Response(200, \json_encode($requestParams));

}
])
]);
);

$plaid = new Plaid("client_id", "secret", $environment);
$plaid->setHttpClient($httpClient);
Expand Down