Skip to content

Commit 6aa0476

Browse files
Adding support for recurring transactions endpoint.
1 parent 60a59c5 commit 6aa0476

File tree

3 files changed

+56
-11
lines changed

3 files changed

+56
-11
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,7 @@ Methods:
313313
* `list(string $access_token, DateTime $start_date, DateTime $end_date, array $options = []): object`
314314
* `refresh(string $access_token): object`
315315
* `sync(string $access_token, ?string $cursor = null, ?int $count = null, array $options = []): object`
316+
* `recurring(string $access_token, array $account_ids, array $options = []): object`
316317

317318
Example:
318319
```php

src/Resources/Transactions.php

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function sync(string $access_token, ?string $cursor = null, ?int $count =
7171
{
7272
$params = [
7373
"access_token" => $access_token,
74-
"options" => (object) $options,
74+
"options" => (object) $options
7575
];
7676

7777
if( $cursor ) {
@@ -88,4 +88,29 @@ public function sync(string $access_token, ?string $cursor = null, ?int $count =
8888
$this->paramsWithClientCredentials($params)
8989
);
9090
}
91+
92+
/**
93+
* Get all recurring transactions (deposit and debit.)
94+
*
95+
* @see https://plaid.com/docs/api/products/transactions/#transactionsrecurringget
96+
*
97+
* @param string $access_token
98+
* @param array<string> $account_ids
99+
* @param array<string,mixed> $options
100+
* @return object
101+
*/
102+
public function recurring(string $access_token, array $account_ids, array $options = []): object
103+
{
104+
$params = [
105+
"access_token" => $access_token,
106+
"account_ids" => $account_ids,
107+
"options" => (object) $options
108+
];
109+
110+
return $this->sendRequest(
111+
"post",
112+
"transactions/recurring/get",
113+
$this->paramsWithClientCredentials($params)
114+
);
115+
}
91116
}

tests/TransactionsTest.php

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ public function test_refresh_transactions(): void
4747
public function test_sync_transactions_minimal(): void
4848
{
4949
$response = $this->getPlaidClient()->transactions->sync(
50-
"access_token"
51-
);
50+
"access_token"
51+
);
5252

5353
$this->assertEquals("POST", $response->method);
5454
$this->assertEquals("2020-09-14", $response->version);
@@ -63,9 +63,9 @@ public function test_sync_transactions_minimal(): void
6363
public function test_sync_transactions_cursor_only(): void
6464
{
6565
$response = $this->getPlaidClient()->transactions->sync(
66-
"access_token",
67-
"last_cursor_123",
68-
);
66+
"access_token",
67+
"last_cursor_123",
68+
);
6969

7070
$this->assertEquals("POST", $response->method);
7171
$this->assertEquals("2020-09-14", $response->version);
@@ -81,11 +81,11 @@ public function test_sync_transactions_cursor_only(): void
8181
public function test_sync_transactions_all_params(): void
8282
{
8383
$response = $this->getPlaidClient()->transactions->sync(
84-
"access_token",
85-
"last_cursor_123",
86-
100,
87-
["include_personal_finance_category" => true],
88-
);
84+
"access_token",
85+
"last_cursor_123",
86+
100,
87+
["include_personal_finance_category" => true],
88+
);
8989

9090
$this->assertEquals("POST", $response->method);
9191
$this->assertEquals("2020-09-14", $response->version);
@@ -98,4 +98,23 @@ public function test_sync_transactions_all_params(): void
9898
$this->assertEquals(100, $response->params->count);
9999
$this->assertEquals((object) ["include_personal_finance_category" => true], $response->params->options);
100100
}
101+
102+
public function test_recurring_transactions(): void
103+
{
104+
$response = $this->getPlaidClient()->transactions->recurring(
105+
"access_token",
106+
["acct_123", "acct_456"],
107+
["option1" => "value1"],
108+
);
109+
110+
$this->assertEquals("POST", $response->method);
111+
$this->assertEquals("2020-09-14", $response->version);
112+
$this->assertEquals("application/json", $response->content);
113+
$this->assertEquals("/transactions/recurring/get", $response->path);
114+
$this->assertEquals("client_id", $response->params->client_id);
115+
$this->assertEquals("secret", $response->params->secret);
116+
$this->assertEquals("access_token", $response->params->access_token);
117+
$this->assertEquals(["acct_123", "acct_456"], $response->params->account_ids);
118+
$this->assertEquals((object) ["option1" => "value1"], $response->params->options);
119+
}
101120
}

0 commit comments

Comments
 (0)