Skip to content

Commit 329826b

Browse files
Merge branch 'DEV-v3' into backport-constructor-changes-to-v3
# Conflicts: # tests/Hyperwallet/Tests/Util/HyperwalletEncryptionTest.php
2 parents 0cb2f1a + 19eefe2 commit 329826b

18 files changed

+642
-149
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
ChangeLog
22
=========
33

4+
1.6.0
5+
-------------------
6+
- Added Transfer status transitions - get, list
7+
- Added filters
8+
- Fields added to Transfer Method
9+
410
1.5.1
511
-------------------
612
- Added fields processingTime to BankCards, expiresOn to Payments

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Hyperwallet REST SDK (Beta)
66
===========================
77

88
A library to manage users, transfer methods and payments through the Hyperwallet Rest V3 API
9+
For Rest V4 APIs, please use SDK v2.1.0
910

1011
Prerequisites
1112
------------

src/Hyperwallet/Hyperwallet.php

Lines changed: 155 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Hyperwallet\Exception\HyperwalletApiException;
66
use Hyperwallet\Exception\HyperwalletArgumentException;
7-
use Hyperwallet\Exception\HyperwalletException;
87
use Hyperwallet\Model\AuthenticationToken;
98
use Hyperwallet\Model\Balance;
109
use Hyperwallet\Model\BankAccount;
@@ -14,20 +13,21 @@
1413
use Hyperwallet\Model\IProgramAware;
1514
use Hyperwallet\Model\PaperCheck;
1615
use Hyperwallet\Model\PaperCheckStatusTransition;
17-
use Hyperwallet\Model\PayPalAccountStatusTransition;
18-
use Hyperwallet\Model\Transfer;
19-
use Hyperwallet\Model\TransferRefund;
20-
use Hyperwallet\Model\TransferStatusTransition;
2116
use Hyperwallet\Model\Payment;
2217
use Hyperwallet\Model\PaymentStatusTransition;
2318
use Hyperwallet\Model\PayPalAccount;
19+
use Hyperwallet\Model\PayPalAccountStatusTransition;
2420
use Hyperwallet\Model\PrepaidCard;
2521
use Hyperwallet\Model\PrepaidCardStatusTransition;
2622
use Hyperwallet\Model\Program;
2723
use Hyperwallet\Model\ProgramAccount;
2824
use Hyperwallet\Model\Receipt;
25+
use Hyperwallet\Model\StatusTransition;
26+
use Hyperwallet\Model\Transfer;
2927
use Hyperwallet\Model\TransferMethod;
3028
use Hyperwallet\Model\TransferMethodConfiguration;
29+
use Hyperwallet\Model\TransferRefund;
30+
use Hyperwallet\Model\TransferStatusTransition;
3131
use Hyperwallet\Model\User;
3232
use Hyperwallet\Model\UserStatusTransition;
3333
use Hyperwallet\Model\VenmoAccount;
@@ -138,6 +138,12 @@ public function updateUser(User $user) {
138138
* @throws HyperwalletApiException
139139
*/
140140
public function listUsers($options = array()) {
141+
if (!empty($options)) {
142+
$filteredArr = array_diff_key($options, array_flip(User::FILTERS_ARRAY()));
143+
if (!empty($filteredArr)) {
144+
throw new HyperwalletArgumentException('Invalid filter');
145+
}
146+
}
141147
$body = $this->client->doGet('/rest/v3/users', array(), $options);
142148
return new ListResponse($body, function ($entry) {
143149
return new User($entry);
@@ -183,6 +189,12 @@ public function listUserStatusTransitions($userToken, array $options = array())
183189
if (empty($userToken)) {
184190
throw new HyperwalletArgumentException('userToken is required!');
185191
}
192+
if (!empty($options)) {
193+
$filteredArr = array_diff_key( $options, array_flip(StatusTransition::FILTERS_ARRAY()) );
194+
if (!empty($filteredArr)) {
195+
throw new HyperwalletArgumentException('Invalid filter');
196+
}
197+
}
186198

187199
$body = $this->client->doGet('/rest/v3/users/{user-token}/status-transitions', array(
188200
'user-token' => $userToken
@@ -290,6 +302,12 @@ public function listPaperChecks($userToken, $options = array()) {
290302
if (empty($userToken)) {
291303
throw new HyperwalletArgumentException('userToken is required!');
292304
}
305+
if (!empty($options)) {
306+
$filteredArr = array_diff_key($options, array_flip(PaperCheck::FILTERS_ARRAY()));
307+
if (!empty($filteredArr)) {
308+
throw new HyperwalletArgumentException('Invalid filter');
309+
}
310+
}
293311
$body = $this->client->doGet('/rest/v3/users/{user-token}/paper-checks', array('user-token' => $userToken), $options);
294312
return new ListResponse($body, function ($entry) {
295313
return new PaperCheck($entry);
@@ -387,6 +405,12 @@ public function listPaperCheckStatusTransitions($userToken, $paperCheckToken, ar
387405
if (empty($paperCheckToken)) {
388406
throw new HyperwalletArgumentException('paperCheckToken is required!');
389407
}
408+
if (!empty($options)) {
409+
$filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
410+
if (!empty($filteredArr)) {
411+
throw new HyperwalletArgumentException('Invalid filter');
412+
}
413+
}
390414

391415
$body = $this->client->doGet('/rest/v3/users/{user-token}/paper-checks/{paper-check-token}/status-transitions', array(
392416
'user-token' => $userToken,
@@ -480,6 +504,12 @@ public function getTransferRefund($transferToken, $refundToken) {
480504
* @throws HyperwalletApiException
481505
*/
482506
public function listTransfers($options = array()) {
507+
if (!empty($options)) {
508+
$filteredArr = array_diff_key($options, array_flip(Transfer::FILTERS_ARRAY()));
509+
if (!empty($filteredArr)) {
510+
throw new HyperwalletArgumentException('Invalid filter');
511+
}
512+
}
483513
$body = $this->client->doGet('/rest/v3/transfers', array(), $options);
484514
return new ListResponse($body, function ($entry) {
485515
return new Transfer($entry);
@@ -525,6 +555,54 @@ public function createTransferStatusTransition($transferToken, TransferStatusTra
525555
return new TransferStatusTransition($body);
526556
}
527557

558+
/**
559+
* Get a transfer status transition
560+
*
561+
* @param string $transferToken The transfer token
562+
* @param string $statusTransitionToken The status transition token
563+
* @return TransferStatusTransition
564+
*
565+
* @throws HyperwalletArgumentException
566+
* @throws HyperwalletApiException
567+
*/
568+
public function getTransferStatusTransition($transferToken, $statusTransitionToken) {
569+
if (empty($transferToken)) {
570+
throw new HyperwalletArgumentException('transferToken is required!');
571+
}
572+
if (empty($statusTransitionToken)) {
573+
throw new HyperwalletArgumentException('statusTransitionToken is required!');
574+
}
575+
576+
$body = $this->client->doGet('/rest/v3/transfers/{transfer-token}/status-transitions/{status-transition-token}', array(
577+
'transfer-token' => $transferToken,
578+
'status-transition-token' => $statusTransitionToken
579+
), array());
580+
return new TransferStatusTransition($body);
581+
}
582+
583+
/**
584+
* List all transfer status transitions
585+
*
586+
* @param string $transferToken The transfer token
587+
* @param array $options The query parameters
588+
* @return ListResponse
589+
*
590+
* @throws HyperwalletArgumentException
591+
* @throws HyperwalletApiException
592+
*/
593+
public function listTransferStatusTransitions($transferToken, array $options = array()) {
594+
if (empty($transferToken)) {
595+
throw new HyperwalletArgumentException('transfer token is required!');
596+
}
597+
598+
$body = $this->client->doGet('/rest/v3/transfers/{transfer-token}/status-transitions', array(
599+
'transfer-token' => $transferToken
600+
), $options);
601+
return new ListResponse($body, function ($entry) {
602+
return new TransferStatusTransition($entry);
603+
});
604+
}
605+
528606
//--------------------------------------
529607
// PayPal Accounts
530608
//--------------------------------------
@@ -608,6 +686,12 @@ public function listPayPalAccounts($userToken, $options = array()) {
608686
if (empty($userToken)) {
609687
throw new HyperwalletArgumentException('userToken is required!');
610688
}
689+
if (!empty($options)) {
690+
$filteredArr = array_diff_key($options, array_flip(PayPalAccount::FILTERS_ARRAY()));
691+
if (!empty($filteredArr)) {
692+
throw new HyperwalletArgumentException('Invalid filter');
693+
}
694+
}
611695
$body = $this->client->doGet('/rest/v3/users/{user-token}/paypal-accounts', array('user-token' => $userToken), $options);
612696
return new ListResponse($body, function ($entry) {
613697
return new PayPalAccount($entry);
@@ -705,6 +789,12 @@ public function listPayPalAccountStatusTransitions($userToken, $payPalAccountTok
705789
if (empty($payPalAccountToken)) {
706790
throw new HyperwalletArgumentException('payPalAccountToken is required!');
707791
}
792+
if (!empty($options)) {
793+
$filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
794+
if (!empty($filteredArr)) {
795+
throw new HyperwalletArgumentException('Invalid filter');
796+
}
797+
}
708798

709799
$body = $this->client->doGet('/rest/v3/users/{user-token}/paypal-accounts/{payPal-account-token}/status-transitions', array(
710800
'user-token' => $userToken,
@@ -790,6 +880,12 @@ public function listPrepaidCards($userToken, $options = array()) {
790880
if (empty($userToken)) {
791881
throw new HyperwalletArgumentException('userToken is required!');
792882
}
883+
if (!empty($options)) {
884+
$filteredArr = array_diff_key($options, array_flip(PrepaidCard::FILTERS_ARRAY()));
885+
if (!empty($filteredArr)) {
886+
throw new HyperwalletArgumentException('Invalid filter');
887+
}
888+
}
793889
$body = $this->client->doGet('/rest/v3/users/{user-token}/prepaid-cards', array('user-token' => $userToken), $options);
794890
return new ListResponse($body, function ($entry) {
795891
return new PrepaidCard($entry);
@@ -972,6 +1068,12 @@ public function listPrepaidCardStatusTransitions($userToken, $prepaidCardToken,
9721068
if (empty($prepaidCardToken)) {
9731069
throw new HyperwalletArgumentException('prepaidCardToken is required!');
9741070
}
1071+
if (!empty($options)) {
1072+
$filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
1073+
if (!empty($filteredArr)) {
1074+
throw new HyperwalletArgumentException('Invalid filter');
1075+
}
1076+
}
9751077

9761078
$body = $this->client->doGet('/rest/v3/users/{user-token}/prepaid-cards/{prepaid-card-token}/status-transitions', array(
9771079
'user-token' => $userToken,
@@ -1057,6 +1159,12 @@ public function listBankAccounts($userToken, $options = array()) {
10571159
if (empty($userToken)) {
10581160
throw new HyperwalletArgumentException('userToken is required!');
10591161
}
1162+
if (!empty($options)) {
1163+
$filteredArr = array_diff_key($options, array_flip(BankAccount::FILTERS_ARRAY()));
1164+
if (!empty($filteredArr)) {
1165+
throw new HyperwalletArgumentException('Invalid filter');
1166+
}
1167+
}
10601168
$body = $this->client->doGet('/rest/v3/users/{user-token}/bank-accounts', array('user-token' => $userToken), $options);
10611169
return new ListResponse($body, function ($entry) {
10621170
return new BankAccount($entry);
@@ -1154,6 +1262,12 @@ public function listBankAccountStatusTransitions($userToken, $bankAccountToken,
11541262
if (empty($bankAccountToken)) {
11551263
throw new HyperwalletArgumentException('bankAccountToken is required!');
11561264
}
1265+
if (!empty($options)) {
1266+
$filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
1267+
if (!empty($filteredArr)) {
1268+
throw new HyperwalletArgumentException('Invalid filter');
1269+
}
1270+
}
11571271

11581272
$body = $this->client->doGet('/rest/v3/users/{user-token}/bank-accounts/{bank-account-token}/status-transitions', array(
11591273
'user-token' => $userToken,
@@ -1240,6 +1354,12 @@ public function listBankCards($userToken, $options = array()) {
12401354
if (empty($userToken)) {
12411355
throw new HyperwalletArgumentException('userToken is required!');
12421356
}
1357+
if (!empty($options)) {
1358+
$filteredArr = array_diff_key($options, array_flip(BankCard::FILTERS_ARRAY()));
1359+
if (!empty($filteredArr)) {
1360+
throw new HyperwalletArgumentException('Invalid filter');
1361+
}
1362+
}
12431363
$body = $this->client->doGet('/rest/v3/users/{user-token}/bank-cards', array('user-token' => $userToken), $options);
12441364
return new ListResponse($body, function ($entry) {
12451365
return new BankCard($entry);
@@ -1335,6 +1455,12 @@ public function listBankCardStatusTransitions($userToken, $bankCardToken, array
13351455
if (empty($bankCardToken)) {
13361456
throw new HyperwalletArgumentException('bankCardToken is required!');
13371457
}
1458+
if (!empty($options)) {
1459+
$filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
1460+
if (!empty($filteredArr)) {
1461+
throw new HyperwalletArgumentException('Invalid filter');
1462+
}
1463+
}
13381464

13391465
$body = $this->client->doGet('/rest/v3/users/{user-token}/bank-cards/{bank-card-token}/status-transitions', array(
13401466
'user-token' => $userToken,
@@ -1393,6 +1519,12 @@ public function listBalancesForUser($userToken, $options = array()) {
13931519
if (empty($userToken)) {
13941520
throw new HyperwalletArgumentException('userToken is required!');
13951521
}
1522+
if (!empty($options)) {
1523+
$filteredArr = array_diff_key($options, array_flip(Balance::FILTERS_ARRAY()));
1524+
if (!empty($filteredArr)) {
1525+
throw new HyperwalletArgumentException('Invalid filter');
1526+
}
1527+
}
13961528

13971529
$body = $this->client->doGet('/rest/v3/users/{user-token}/balances', array('user-token' => $userToken), $options);
13981530
return new ListResponse($body, function ($entry) {
@@ -1498,6 +1630,12 @@ public function getPayment($paymentToken) {
14981630
* @throws HyperwalletApiException
14991631
*/
15001632
public function listPayments($options = array()) {
1633+
if (!empty($options)) {
1634+
$filteredArr = array_diff_key($options, array_flip(Payment::FILTERS_ARRAY()));
1635+
if (!empty($filteredArr)) {
1636+
throw new HyperwalletArgumentException('Invalid filter');
1637+
}
1638+
}
15011639
$body = $this->client->doGet('/rest/v3/payments', array(), $options);
15021640
return new ListResponse($body, function ($entry) {
15031641
return new Payment($entry);
@@ -1564,6 +1702,12 @@ public function listPaymentStatusTransitions($paymentToken, array $options = arr
15641702
if (empty($paymentToken)) {
15651703
throw new HyperwalletArgumentException('paymentToken is required!');
15661704
}
1705+
if (!empty($options)) {
1706+
$filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
1707+
if (!empty($filteredArr)) {
1708+
throw new HyperwalletArgumentException('Invalid filter');
1709+
}
1710+
}
15671711

15681712
$body = $this->client->doGet('/rest/v3/payments/{payment-token}/status-transitions', array(
15691713
'payment-token' => $paymentToken
@@ -1802,6 +1946,12 @@ public function getWebhookNotification($webhookNotificationToken) {
18021946
* @throws HyperwalletApiException
18031947
*/
18041948
public function listWebhookNotifications($options = array()) {
1949+
if (!empty($options)) {
1950+
$filteredArr = array_diff_key($options, array_flip(WebhookNotification::FILTERS_ARRAY()));
1951+
if (!empty($filteredArr)) {
1952+
throw new HyperwalletArgumentException('Invalid filter');
1953+
}
1954+
}
18051955
$body = $this->client->doGet('/rest/v3/webhook-notifications', array(), $options);
18061956
return new ListResponse($body, function ($entry) {
18071957
return new WebhookNotification($entry);

src/Hyperwallet/Model/Balance.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ class Balance extends BaseModel {
1313

1414
/**
1515
* @internal
16-
*
16+
*
1717
* Read only fields
1818
*
1919
* @var string[]
2020
*/
2121
private static $READ_ONLY_FIELDS = array('currency', 'amount');
2222

23+
public static function FILTERS_ARRAY() {
24+
return array('currency');
25+
}
26+
2327
/**
2428
* Creates a instance of Balance
2529
*

src/Hyperwallet/Model/BankAccount.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ class BankAccount extends BaseModel {
8787
const PROFILE_TYPE_INDIVIDUAL = 'INDIVIDUAL';
8888
const PROFILE_TYPE_BUSINESS = 'BUSINESS';
8989

90+
public static function FILTERS_ARRAY() {
91+
return array('type','status');
92+
}
93+
9094
/**
9195
* Creates a instance of BankAccount
9296
*

src/Hyperwallet/Model/BankCard.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ class BankCard extends BaseModel {
4646
const CARD_BRAND_VISA = 'VISA';
4747
const CARD_BRAND_MASTERCARD = 'MASTERCARD';
4848

49+
public static function FILTERS_ARRAY() {
50+
return array('status');
51+
}
52+
4953
/**
5054
* Creates a instance of BankCard
5155
*

0 commit comments

Comments
 (0)