1: <?php
2:
3: namespace Hyperwallet;
4:
5: use Hyperwallet\Exception\HyperwalletApiException;
6: use Hyperwallet\Exception\HyperwalletArgumentException;
7: use Hyperwallet\Model\AuthenticationToken;
8: use Hyperwallet\Model\Balance;
9: use Hyperwallet\Model\BankAccount;
10: use Hyperwallet\Model\BankAccountStatusTransition;
11: use Hyperwallet\Model\BankCard;
12: use Hyperwallet\Model\BankCardStatusTransition;
13: use Hyperwallet\Model\BusinessStakeholder;
14: use Hyperwallet\Model\BusinessStakeholderStatusTransition;
15: use Hyperwallet\Model\HyperwalletVerificationDocument;
16: use Hyperwallet\Model\HyperwalletVerificationDocumentReason;
17: use Hyperwallet\Model\HyperwalletVerificationDocumentCollection;
18: use Hyperwallet\Model\HyperwalletVerificationDocumentReasonCollection;
19: use Hyperwallet\Model\IProgramAware;
20: use Hyperwallet\Model\PaperCheck;
21: use Hyperwallet\Model\PaperCheckStatusTransition;
22: use Hyperwallet\Model\Payment;
23: use Hyperwallet\Model\PaymentStatusTransition;
24: use Hyperwallet\Model\PayPalAccount;
25: use Hyperwallet\Model\PayPalAccountStatusTransition;
26: use Hyperwallet\Model\PrepaidCard;
27: use Hyperwallet\Model\PrepaidCardStatusTransition;
28: use Hyperwallet\Model\Program;
29: use Hyperwallet\Model\ProgramAccount;
30: use Hyperwallet\Model\Receipt;
31: use Hyperwallet\Model\StatusTransition;
32: use Hyperwallet\Model\Transfer;
33: use Hyperwallet\Model\TransferMethod;
34: use Hyperwallet\Model\TransferMethodConfiguration;
35: use Hyperwallet\Model\TransferRefund;
36: use Hyperwallet\Model\TransferStatusTransition;
37: use Hyperwallet\Model\User;
38: use Hyperwallet\Model\UserStatusTransition;
39: use Hyperwallet\Model\VenmoAccount;
40: use Hyperwallet\Model\VenmoAccountStatusTransition;
41: use Hyperwallet\Model\WebhookNotification;
42: use Hyperwallet\Response\ListResponse;
43: use Hyperwallet\Util\ApiClient;
44:
45: /**
46: * The Hyperwallet SDK Client
47: *
48: * @package Hyperwallet
49: */
50: class Hyperwallet {
51:
52: /**
53: * The program token
54: *
55: * @var string
56: */
57: private $programToken;
58:
59: /**
60: * The internal API client
61: *
62: * @var ApiClient
63: */
64: private $client;
65:
66: /**
67: * Creates a instance of the SDK Client
68: *
69: * @param string $username The API username
70: * @param string $password The API password
71: * @param string|null $programToken The program token that is used for some API calls
72: * @param string $server The API server to connect to
73: * @param array $encryptionData Encryption data to initialize ApiClient with encryption enabled
74: * @param array $clientOptions Guzzle Client Options
75: *
76: * @throws HyperwalletArgumentException
77: */
78: public function __construct($username, $password, $programToken = null, $server = 'https://api.sandbox.hyperwallet.com', $encryptionData = array(), $clientOptions = array()) {
79: if (empty($username) || empty($password)) {
80: throw new HyperwalletArgumentException('You need to specify your API username and password!');
81: }
82:
83: $this->programToken = $programToken;
84: $this->client = new ApiClient($username, $password, $server, $clientOptions, $encryptionData);
85: }
86:
87: //--------------------------------------
88: // Helpers
89: //--------------------------------------
90:
91: /**
92: * Modify body for nested formatting
93: *
94: * @param array $bodyResponse Body Response from request
95: * @return array
96: */
97: private function setDocumentAndReasonFromResponseHelper($bodyResponse) {
98: if (array_key_exists("documents", $bodyResponse)) {
99: $documents = $bodyResponse["documents"];
100: foreach ($documents as &$dVal) {
101: if (array_key_exists("reasons", $dVal)) {
102: $reasons = $dVal["reasons"];
103: foreach ($reasons as &$rVal) {
104: $rVal = new HyperwalletVerificationDocumentReason($rVal);
105: }
106: $dVal["reasons"] = new HyperwalletVerificationDocumentReasonCollection(...$reasons);
107: }
108: $dVal = new HyperwalletVerificationDocument($dVal);
109: }
110: $bodyResponse["documents"] = new HyperwalletVerificationDocumentCollection(...$documents);
111: }
112: return $bodyResponse;
113: }
114:
115:
116: //--------------------------------------
117: // Users
118: //--------------------------------------
119:
120: /**
121: * Create a user
122: *
123: * @param User $user The user data
124: * @return User
125: *
126: * @throws HyperwalletApiException
127: */
128: public function createUser(User $user) {
129: $this->addProgramToken($user);
130: $body = $this->client->doPost('/rest/v4/users', array(), $user, array());
131: return new User($body);
132: }
133:
134: /**
135: * Get a user
136: *
137: * @param string $userToken The user token
138: * @return User
139: *
140: * @throws HyperwalletArgumentException
141: * @throws HyperwalletApiException
142: */
143: public function getUser($userToken) {
144: if (empty($userToken)) {
145: throw new HyperwalletArgumentException('userToken is required!');
146: }
147: $body = $this->client->doGet('/rest/v4/users/{user-token}', array('user-token' => $userToken), array());
148: return new User($body);
149: }
150:
151: /**
152: * Update a user
153: *
154: * @param User $user The user
155: * @return User
156: *
157: * @throws HyperwalletArgumentException
158: * @throws HyperwalletApiException
159: */
160: public function updateUser(User $user) {
161: if (!$user->getToken()) {
162: throw new HyperwalletArgumentException('token is required!');
163: }
164: $body = $this->client->doPut('/rest/v4/users/{user-token}', array('user-token' => $user->getToken()), $user, array());
165: return new User($body);
166: }
167:
168: /**
169: * List all users
170: *
171: * @param array $options
172: * @return ListResponse
173: *
174: * @throws HyperwalletApiException
175: */
176: public function listUsers($options = array()) {
177: if (!empty($options)) {
178: $filteredArr = array_diff_key($options, array_flip(User::FILTERS_ARRAY()));
179: if (!empty($filteredArr)) {
180: throw new HyperwalletArgumentException('Invalid filter');
181: }
182: }
183:
184: $body = $this->client->doGet('/rest/v4/users', array(),$options) ;
185: return new ListResponse($body, function ($entry) {
186: return new User($entry);
187: });
188: }
189:
190: /**
191: * Get a user status transition
192: *
193: * @param string $userToken The user token
194: * @param string $statusTransitionToken The status transition token
195: * @return UserStatusTransition
196: *
197: * @throws HyperwalletArgumentException
198: * @throws HyperwalletApiException
199: */
200: public function getUserStatusTransition($userToken, $statusTransitionToken) {
201: if (empty($userToken)) {
202: throw new HyperwalletArgumentException('userToken is required!');
203: }
204: if (empty($statusTransitionToken)) {
205: throw new HyperwalletArgumentException('statusTransitionToken is required!');
206: }
207:
208: $body = $this->client->doGet('/rest/v4/users/{user-token}/status-transitions/{status-transition-token}', array(
209: 'user-token' => $userToken,
210: 'status-transition-token' => $statusTransitionToken
211: ), array());
212: return new UserStatusTransition($body);
213: }
214:
215: /**
216: * List all user status transitions
217: *
218: * @param string $userToken The user token
219: * @param array $options The query parameters
220: * @return ListResponse
221: *
222: * @throws HyperwalletArgumentException
223: * @throws HyperwalletApiException
224: */
225: public function listUserStatusTransitions($userToken, array $options = array()) {
226: if (empty($userToken)) {
227: throw new HyperwalletArgumentException('userToken is required!');
228: }
229: if (!empty($options)) {
230: $filteredArr = array_diff_key( $options, array_flip(StatusTransition::FILTERS_ARRAY()) );
231: if (!empty($filteredArr)) {
232: throw new HyperwalletArgumentException('Invalid filter');
233: }
234: }
235:
236: $body = $this->client->doGet('/rest/v4/users/{user-token}/status-transitions', array(
237: 'user-token' => $userToken
238: ), $options);
239: return new ListResponse($body, function ($entry) {
240: return new UserStatusTransition($entry);
241: });
242: }
243:
244: //--------------------------------------
245: // Authentication Token
246: //--------------------------------------
247:
248: /**
249: * Get authentication token
250: *
251: * @param string $userToken The user token
252: * @return AuthenticationToken
253: *
254: * @throws HyperwalletApiException
255: */
256: public function getAuthenticationToken($userToken) {
257: if (empty($userToken)) {
258: throw new HyperwalletArgumentException('userToken is required!');
259: }
260: $body = $this->client->doPost('/rest/v4/users/{user-token}/authentication-token', array(
261: 'user-token' => $userToken,
262: ), null, array());
263: return new AuthenticationToken($body);
264: }
265:
266: //--------------------------------------
267: // Paper Checks
268: //--------------------------------------
269:
270: /**
271: * Create a paper check
272: *
273: * @param string $userToken The user token
274: * @param PaperCheck $paperCheck The paper check data
275: * @return PaperCheck
276: *
277: * @throws HyperwalletArgumentException
278: * @throws HyperwalletApiException
279: */
280: public function createPaperCheck($userToken, PaperCheck $paperCheck) {
281: if (empty($userToken)) {
282: throw new HyperwalletArgumentException('userToken is required!');
283: }
284: $body = $this->client->doPost('/rest/v4/users/{user-token}/paper-checks',
285: array('user-token' => $userToken), $paperCheck, array());
286: return new PaperCheck($body);
287: }
288:
289: /**
290: * Get a paper check
291: *
292: * @param string $userToken The user token
293: * @param string $paperCheckToken The paper check token
294: * @return PaperCheck
295: *
296: * @throws HyperwalletArgumentException
297: * @throws HyperwalletApiException
298: */
299: public function getPaperCheck($userToken, $paperCheckToken) {
300: if (empty($userToken)) {
301: throw new HyperwalletArgumentException('userToken is required!');
302: }
303: if (empty($paperCheckToken)) {
304: throw new HyperwalletArgumentException('paperCheckToken is required!');
305: }
306: $body = $this->client->doGet('/rest/v4/users/{user-token}/paper-checks/{paper-check-token}', array(
307: 'user-token' => $userToken,
308: 'paper-check-token' => $paperCheckToken
309: ), array());
310: return new PaperCheck($body);
311: }
312:
313: /**
314: * Update a paper check
315: *
316: * @param string $userToken The user token
317: * @param PaperCheck $paperCheck The paper check data
318: * @return PaperCheck
319: *
320: * @throws HyperwalletArgumentException
321: * @throws HyperwalletApiException
322: */
323: public function updatePaperCheck($userToken, PaperCheck $paperCheck) {
324: $body = $this->updateTransferMethod($userToken, $paperCheck, 'paper-checks');
325: return new PaperCheck($body);
326: }
327:
328: /**
329: * List all paper checks
330: *
331: * @param string $userToken The user token
332: * @param array $options The query parameters to send
333: * @return ListResponse
334: *
335: * @throws HyperwalletArgumentException
336: * @throws HyperwalletApiException
337: */
338: public function listPaperChecks($userToken, $options = array()) {
339: if (empty($userToken)) {
340: throw new HyperwalletArgumentException('userToken is required!');
341: }
342: if (!empty($options)) {
343: $filteredArr = array_diff_key($options, array_flip(PaperCheck::FILTERS_ARRAY()));
344: if (!empty($filteredArr)) {
345: throw new HyperwalletArgumentException('Invalid filter');
346: }
347: }
348:
349: $body = $this->client->doGet('/rest/v4/users/{user-token}/paper-checks', array('user-token' => $userToken), $options);
350: return new ListResponse($body, function ($entry) {
351: return new PaperCheck($entry);
352: });
353: }
354:
355: /**
356: * Deactivate a paper check
357: *
358: * @param string $userToken The user token
359: * @param string $paperCheckToken The paper check token
360: * @return PaperCheckStatusTransition
361: *
362: * @throws HyperwalletArgumentException
363: * @throws HyperwalletApiException
364: */
365: public function deactivatePaperCheck($userToken, $paperCheckToken) {
366: $transition = new PaperCheckStatusTransition();
367: $transition->setTransition(PaperCheckStatusTransition::TRANSITION_DE_ACTIVATED);
368:
369: return $this->createPaperCheckStatusTransition($userToken, $paperCheckToken, $transition);
370: }
371:
372: /**
373: * Create a paper check status transition
374: *
375: * @param string $userToken The user token
376: * @param string $paperCheckToken The paper check token
377: * @param PaperCheckStatusTransition $transition The status transition
378: * @return PaperCheckStatusTransition
379: *
380: * @throws HyperwalletArgumentException
381: * @throws HyperwalletApiException
382: */
383: public function createPaperCheckStatusTransition($userToken, $paperCheckToken, PaperCheckStatusTransition $transition) {
384: if (empty($userToken)) {
385: throw new HyperwalletArgumentException('userToken is required!');
386: }
387: if (empty($paperCheckToken)) {
388: throw new HyperwalletArgumentException('paperCheckToken is required!');
389: }
390:
391: $body = $this->client->doPost('/rest/v4/users/{user-token}/paper-checks/{paper-check-token}/status-transitions', array(
392: 'user-token' => $userToken,
393: 'paper-check-token' => $paperCheckToken
394: ), $transition, array());
395: return new PaperCheckStatusTransition($body);
396: }
397:
398: /**
399: * Get a paper check status transition
400: *
401: * @param string $userToken The user token
402: * @param string $paperCheckToken The paper check token
403: * @param string $statusTransitionToken The status transition token
404: * @return PaperCheckStatusTransition
405: *
406: * @throws HyperwalletArgumentException
407: * @throws HyperwalletApiException
408: */
409: public function getPaperCheckStatusTransition($userToken, $paperCheckToken, $statusTransitionToken) {
410: if (empty($userToken)) {
411: throw new HyperwalletArgumentException('userToken is required!');
412: }
413: if (empty($paperCheckToken)) {
414: throw new HyperwalletArgumentException('paperCheckToken is required!');
415: }
416: if (empty($statusTransitionToken)) {
417: throw new HyperwalletArgumentException('statusTransitionToken is required!');
418: }
419:
420: $body = $this->client->doGet('/rest/v4/users/{user-token}/paper-checks/{paper-check-token}/status-transitions/{status-transition-token}', array(
421: 'user-token' => $userToken,
422: 'paper-check-token' => $paperCheckToken,
423: 'status-transition-token' => $statusTransitionToken
424: ), array());
425: return new PaperCheckStatusTransition($body);
426: }
427:
428: /**
429: * List all paper check status transitions
430: *
431: * @param string $userToken The user token
432: * @param string $paperCheckToken The paper check token
433: * @param array $options The query parameters
434: * @return ListResponse
435: *
436: * @throws HyperwalletArgumentException
437: * @throws HyperwalletApiException
438: */
439: public function listPaperCheckStatusTransitions($userToken, $paperCheckToken, array $options = array()) {
440: if (empty($userToken)) {
441: throw new HyperwalletArgumentException('userToken is required!');
442: }
443: if (empty($paperCheckToken)) {
444: throw new HyperwalletArgumentException('paperCheckToken is required!');
445: }
446: if (!empty($options)) {
447: $filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
448: if (!empty($filteredArr)) {
449: throw new HyperwalletArgumentException('Invalid filter');
450: }
451: }
452:
453: $body = $this->client->doGet('/rest/v4/users/{user-token}/paper-checks/{paper-check-token}/status-transitions', array(
454: 'user-token' => $userToken,
455: 'paper-check-token' => $paperCheckToken
456: ), $options);
457: return new ListResponse($body, function ($entry) {
458: return new PaperCheckStatusTransition($entry);
459: });
460: }
461:
462: //--------------------------------------
463: // Transfers
464: //--------------------------------------
465:
466: /**
467: * Create a transfer
468: *
469: * @param Transfer $transfer The transfer data
470: * @return Transfer
471: *
472: * @throws HyperwalletArgumentException
473: * @throws HyperwalletApiException
474: */
475: public function createTransfer(Transfer $transfer) {
476: if (empty($transfer->getSourceToken())) {
477: throw new HyperwalletArgumentException('sourceToken is required!');
478: }
479: if (empty($transfer->getDestinationToken())) {
480: throw new HyperwalletArgumentException('destinationToken is required!');
481: }
482: if (empty($transfer->getClientTransferId())) {
483: throw new HyperwalletArgumentException('clientTransferId is required!');
484: }
485: $body = $this->client->doPost('/rest/v4/transfers', array(), $transfer, array());
486: return new Transfer($body);
487: }
488:
489: public function createTransferRefund($transferToken, $transferRefund) {
490: if (empty($transferRefund)) {
491: throw new HyperwalletArgumentException('transferRefund is required!');
492: }
493: if (empty($transferToken)) {
494: throw new HyperwalletArgumentException('transferToken is required!');
495: }
496: if (empty($transferRefund->getClientRefundId())) {
497: throw new HyperwalletArgumentException('clientRefundId is required!');
498: }
499: $body = $this->client->doPost('/rest/v4/transfers/{transfer-token}/refunds',
500: array('transfer-token' => $transferToken), $transferRefund, array());
501: return new TransferRefund($body);
502: }
503:
504: /**
505: * Get a transfer
506: *
507: * @param string $transferToken The transfer token
508: * @return Transfer
509: *
510: * @throws HyperwalletArgumentException
511: * @throws HyperwalletApiException
512: */
513: public function getTransfer($transferToken) {
514: if (empty($transferToken)) {
515: throw new HyperwalletArgumentException('transferToken is required!');
516: }
517: $body = $this->client->doGet('/rest/v4/transfers/{transfer-token}', array('transfer-token' => $transferToken),
518: array());
519: return new Transfer($body);
520: }
521:
522: public function getTransferRefund($transferToken, $refundToken) {
523: if (empty($transferToken)) {
524: throw new HyperwalletArgumentException('transferToken is required!');
525: }
526: if (empty($refundToken)) {
527: throw new HyperwalletArgumentException('refundToken is required!');
528: }
529: $body = $this->client->doGet('/rest/v4/transfers/{transfer-token}/refunds/{refund-token}', array(
530: 'transfer-token' => $transferToken,
531: 'refund-token' => $refundToken),
532: array());
533: return new TransferRefund($body);
534: }
535:
536: /**
537: * List all transfers
538: *
539: * @param array $options The query parameters to send
540: * @return ListResponse
541: *
542: * @throws HyperwalletApiException
543: */
544: public function listTransfers($options = array()) {
545: if (!empty($options)) {
546: $filteredArr = array_diff_key($options, array_flip(Transfer::FILTERS_ARRAY()));
547: if (!empty($filteredArr)) {
548: throw new HyperwalletArgumentException('Invalid filter');
549: }
550: }
551:
552: $body = $this->client->doGet('/rest/v4/transfers', array(), $options);
553: return new ListResponse($body, function ($entry) {
554: return new Transfer($entry);
555: });
556: }
557:
558: /**
559: * List all transfers
560: *
561: * @param array $options The query parameters to send
562: * @return ListResponse
563: * @throws HyperwalletArgumentException
564: * @throws HyperwalletApiException
565: */
566: public function listTransferRefunds($transferToken, array $options = array()) {
567: if (empty($transferToken)) {
568: throw new HyperwalletArgumentException('transferToken is required!');
569: }
570: $body = $this->client->doGet('/rest/v4/transfers/{transfer-token}/refunds', array('transfer-token' => $transferToken), $options);
571: return new ListResponse($body, function ($entry) {
572: return new TransferRefund($entry);
573: });
574: }
575:
576: /**
577: * Create a transfer status transition
578: *
579: * @param string $transferToken The transfer token
580: * @param TransferStatusTransition $transition The status transition
581: * @return TransferStatusTransition
582: *
583: * @throws HyperwalletArgumentException
584: * @throws HyperwalletApiException
585: */
586: public function createTransferStatusTransition($transferToken, TransferStatusTransition $transition) {
587: if (empty($transferToken)) {
588: throw new HyperwalletArgumentException('transferToken is required!');
589: }
590:
591: $body = $this->client->doPost('/rest/v4/transfers/{transfer-token}/status-transitions', array(
592: 'transfer-token' => $transferToken
593: ), $transition, array());
594: return new TransferStatusTransition($body);
595: }
596:
597: /**
598: * Get a transfer status transition
599: *
600: * @param string $transferToken The transfer token
601: * @param string $statusTransitionToken The status transition token
602: * @return TransferStatusTransition
603: *
604: * @throws HyperwalletArgumentException
605: * @throws HyperwalletApiException
606: */
607: public function getTransferStatusTransition($transferToken, $statusTransitionToken) {
608: if (empty($transferToken)) {
609: throw new HyperwalletArgumentException('transferToken is required!');
610: }
611: if (empty($statusTransitionToken)) {
612: throw new HyperwalletArgumentException('statusTransitionToken is required!');
613: }
614:
615: $body = $this->client->doGet('/rest/v4/transfers/{transfer-token}/status-transitions/{status-transition-token}', array(
616: 'transfer-token' => $transferToken,
617: 'status-transition-token' => $statusTransitionToken
618: ), array());
619: return new TransferStatusTransition($body);
620: }
621:
622: /**
623: * List all transfer status transitions
624: *
625: * @param string $transferToken The transfer token
626: * @param array $options The query parameters
627: * @return ListResponse
628: *
629: * @throws HyperwalletArgumentException
630: * @throws HyperwalletApiException
631: */
632: public function listTransferStatusTransitions($transferToken, array $options = array()) {
633: if (empty($transferToken)) {
634: throw new HyperwalletArgumentException('transfer token is required!');
635: }
636:
637: $body = $this->client->doGet('/rest/v4/transfers/{transfer-token}/status-transitions', array(
638: 'transfer-token' => $transferToken
639: ), $options);
640: return new ListResponse($body, function ($entry) {
641: return new TransferStatusTransition($entry);
642: });
643: }
644:
645: //--------------------------------------
646: // PayPal Accounts
647: //--------------------------------------
648:
649: /**
650: * Create a PayPal account
651: *
652: * @param string $userToken The user token
653: * @param PayPalAccount $payPalAccount The PayPal account data
654: * @return PayPalAccount
655: *
656: * @throws HyperwalletArgumentException
657: * @throws HyperwalletApiException
658: */
659: public function createPayPalAccount($userToken, PayPalAccount $payPalAccount) {
660: if (empty($userToken)) {
661: throw new HyperwalletArgumentException('userToken is required!');
662: }
663: if (empty($payPalAccount->getTransferMethodCountry())) {
664: throw new HyperwalletArgumentException('transferMethodCountry is required!');
665: }
666: if (empty($payPalAccount->getTransferMethodCurrency())) {
667: throw new HyperwalletArgumentException('transferMethodCurrency is required!');
668: }
669: if (empty($payPalAccount->getEmail()) and empty($payPalAccount->getAccountId()) ) {
670: throw new HyperwalletArgumentException('email or accountId is required!');
671: }
672: $body = $this->client->doPost('/rest/v4/users/{user-token}/paypal-accounts', array('user-token' => $userToken), $payPalAccount, array());
673: return new PayPalAccount($body);
674: }
675:
676: /**
677: * Get a PayPal account
678: *
679: * @param string $userToken The user token
680: * @param string $payPalAccountToken The PayPal account token
681: * @return PayPalAccount
682: *
683: * @throws HyperwalletArgumentException
684: * @throws HyperwalletApiException
685: */
686: public function getPayPalAccount($userToken, $payPalAccountToken) {
687: if (empty($userToken)) {
688: throw new HyperwalletArgumentException('userToken is required!');
689: }
690: if (empty($payPalAccountToken)) {
691: throw new HyperwalletArgumentException('payPalAccountToken is required!');
692: }
693: $body = $this->client->doGet('/rest/v4/users/{user-token}/paypal-accounts/{paypal-account-token}', array(
694: 'user-token' => $userToken,
695: 'paypal-account-token' => $payPalAccountToken
696: ), array());
697: return new PayPalAccount($body);
698: }
699:
700: /**
701: * Update PayPal account
702: *
703: * @param string $userToken The user token
704: * @param PayPalAccount $payPalAccount Paypal account data
705: * @return PayPalAccount
706: *
707: * @throws HyperwalletArgumentException
708: * @throws HyperwalletApiException
709: */
710: public function updatePayPalAccount($userToken, PayPalAccount $payPalAccount) {
711: $body = $this->updateTransferMethod($userToken, $payPalAccount, 'paypal-accounts');
712: return new PayPalAccount($body);
713: }
714:
715: /**
716: * List all PayPal accounts
717: *
718: * @param string $userToken The user token
719: * @param array $options The query parameters to send
720: * @return ListResponse
721: *
722: * @throws HyperwalletApiException
723: */
724: public function listPayPalAccounts($userToken, $options = array()) {
725: if (empty($userToken)) {
726: throw new HyperwalletArgumentException('userToken is required!');
727: }
728: if (!empty($options)) {
729: $filteredArr = array_diff_key($options, array_flip(PayPalAccount::FILTERS_ARRAY()));
730: if (!empty($filteredArr)) {
731: throw new HyperwalletArgumentException('Invalid filter');
732: }
733: }
734:
735: $body = $this->client->doGet('/rest/v4/users/{user-token}/paypal-accounts', array('user-token' => $userToken), $options);
736: return new ListResponse($body, function ($entry) {
737: return new PayPalAccount($entry);
738: });
739: }
740:
741: /**
742: * Deactivate a PayPal account
743: *
744: * @param string $userToken The user token
745: * @param string $payPalAccountToken The PayPal account token
746: * @return PayPalAccountStatusTransition
747: *
748: * @throws HyperwalletArgumentException
749: * @throws HyperwalletApiException
750: */
751: public function deactivatePayPalAccount($userToken, $payPalAccountToken) {
752: $transition = new PayPalAccountStatusTransition();
753: $transition->setTransition(PayPalAccountStatusTransition::TRANSITION_DE_ACTIVATED);
754:
755: return $this->createPayPalAccountStatusTransition($userToken, $payPalAccountToken, $transition);
756: }
757:
758: /**
759: * Create a PayPal account status transition
760: *
761: * @param string $userToken The user token
762: * @param string $payPalAccountToken The PayPal account token
763: * @param PayPalAccountStatusTransition $transition The status transition
764: * @return PayPalAccountStatusTransition
765: *
766: * @throws HyperwalletArgumentException
767: * @throws HyperwalletApiException
768: */
769: public function createPayPalAccountStatusTransition($userToken, $payPalAccountToken, PayPalAccountStatusTransition $transition) {
770: if (empty($userToken)) {
771: throw new HyperwalletArgumentException('userToken is required!');
772: }
773: if (empty($payPalAccountToken)) {
774: throw new HyperwalletArgumentException('payPalAccountToken is required!');
775: }
776:
777: $body = $this->client->doPost('/rest/v4/users/{user-token}/paypal-accounts/{payPal-account-token}/status-transitions', array(
778: 'user-token' => $userToken,
779: 'payPal-account-token' => $payPalAccountToken
780: ), $transition, array());
781: return new PayPalAccountStatusTransition($body);
782: }
783:
784: /**
785: * Get a PayPal account status transition
786: *
787: * @param string $userToken The user token
788: * @param string $payPalAccountToken The PayPal account token
789: * @param string $statusTransitionToken The status transition token
790: * @return PayPalAccountStatusTransition
791: *
792: * @throws HyperwalletArgumentException
793: * @throws HyperwalletApiException
794: */
795: public function getPayPalAccountStatusTransition($userToken, $payPalAccountToken, $statusTransitionToken) {
796: if (empty($userToken)) {
797: throw new HyperwalletArgumentException('userToken is required!');
798: }
799: if (empty($payPalAccountToken)) {
800: throw new HyperwalletArgumentException('payPalAccountToken is required!');
801: }
802: if (empty($statusTransitionToken)) {
803: throw new HyperwalletArgumentException('statusTransitionToken is required!');
804: }
805:
806: $body = $this->client->doGet('/rest/v4/users/{user-token}/paypal-accounts/{payPal-account-token}/status-transitions/{status-transition-token}', array(
807: 'user-token' => $userToken,
808: 'payPal-account-token' => $payPalAccountToken,
809: 'status-transition-token' => $statusTransitionToken
810: ), array());
811: return new PayPalAccountStatusTransition($body);
812: }
813:
814: /**
815: * List all PayPal account status transitions
816: *
817: * @param string $userToken The user token
818: * @param string $payPalAccountToken The payPal account token
819: * @param array $options The query parameters
820: * @return ListResponse
821: *
822: * @throws HyperwalletArgumentException
823: * @throws HyperwalletApiException
824: */
825: public function listPayPalAccountStatusTransitions($userToken, $payPalAccountToken, array $options = array()) {
826: if (empty($userToken)) {
827: throw new HyperwalletArgumentException('userToken is required!');
828: }
829: if (empty($payPalAccountToken)) {
830: throw new HyperwalletArgumentException('payPalAccountToken is required!');
831: }
832: if (!empty($options)) {
833: $filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
834: if (!empty($filteredArr)) {
835: throw new HyperwalletArgumentException('Invalid filter');
836: }
837: }
838:
839: $body = $this->client->doGet('/rest/v4/users/{user-token}/paypal-accounts/{payPal-account-token}/status-transitions', array(
840: 'user-token' => $userToken,
841: 'payPal-account-token' => $payPalAccountToken
842: ), $options);
843: return new ListResponse($body, function ($entry) {
844: return new PayPalAccountStatusTransition($entry);
845: });
846: }
847:
848: //--------------------------------------
849: // Prepaid Cards
850: //--------------------------------------
851:
852: /**
853: * Create a prepaid card
854: *
855: * @param string $userToken The user token
856: * @param PrepaidCard $prepaidCard The prepaid card data
857: * @return PrepaidCard
858: *
859: * @throws HyperwalletArgumentException
860: * @throws HyperwalletApiException
861: */
862: public function createPrepaidCard($userToken, PrepaidCard $prepaidCard) {
863: if (empty($userToken)) {
864: throw new HyperwalletArgumentException('userToken is required!');
865: }
866: $body = $this->client->doPost('/rest/v4/users/{user-token}/prepaid-cards', array('user-token' => $userToken), $prepaidCard, array());
867: return new PrepaidCard($body);
868: }
869:
870: /**
871: * Replace a prepaid card
872: *
873: * @param string $userToken The user token
874: * @param PrepaidCard $prepaidCard The prepaid card data
875: * @return PrepaidCard
876: */
877: public function replacePrepaidCard($userToken, PrepaidCard $prepaidCard) {
878: if (empty($prepaidCard->getReplacementReason())) {
879: throw new HyperwalletArgumentException('replacementReason is required!');
880: }
881: return $this->createPrepaidCard($userToken, $prepaidCard);
882: }
883:
884: /**
885: * Get a prepaid card
886: *
887: * @param string $userToken The user token
888: * @param string $prepaidCardToken The prepaid card token
889: * @return PrepaidCard
890: *
891: * @throws HyperwalletArgumentException
892: * @throws HyperwalletApiException
893: */
894: public function getPrepaidCard($userToken, $prepaidCardToken) {
895: if (empty($userToken)) {
896: throw new HyperwalletArgumentException('userToken is required!');
897: }
898: if (empty($prepaidCardToken)) {
899: throw new HyperwalletArgumentException('prepaidCardToken is required!');
900: }
901: $body = $this->client->doGet('/rest/v4/users/{user-token}/prepaid-cards/{prepaid-card-token}', array(
902: 'user-token' => $userToken,
903: 'prepaid-card-token' => $prepaidCardToken
904: ), array());
905: return new PrepaidCard($body);
906: }
907:
908: /**
909: * Update a prepaid card
910: *
911: * @param string $userToken The user token
912: * @param PrepaidCard $prepaidCard The prepaid card data
913: * @return PrepaidCard
914: *
915: * @throws HyperwalletArgumentException
916: * @throws HyperwalletApiException
917: */
918: public function updatePrepaidCard($userToken, PrepaidCard $prepaidCard) {
919: $body = $this->updateTransferMethod($userToken, $prepaidCard, 'prepaid-cards');
920: return new PrepaidCard($body);
921: }
922:
923: /**
924: * List all prepaid cards
925: *
926: * @param string $userToken The user token
927: * @param array $options The query parameters to send
928: * @return ListResponse
929: *
930: * @throws HyperwalletArgumentException
931: * @throws HyperwalletApiException
932: */
933: public function listPrepaidCards($userToken, $options = array()) {
934: if (empty($userToken)) {
935: throw new HyperwalletArgumentException('userToken is required!');
936: }
937: if (!empty($options)) {
938: $filteredArr = array_diff_key($options, array_flip(PrepaidCard::FILTERS_ARRAY()));
939: if (!empty($filteredArr)) {
940: throw new HyperwalletArgumentException('Invalid filter');
941: }
942: }
943:
944: $body = $this->client->doGet('/rest/v4/users/{user-token}/prepaid-cards', array('user-token' => $userToken), $options);
945: return new ListResponse($body, function ($entry) {
946: return new PrepaidCard($entry);
947: });
948: }
949:
950: /**
951: * Suspend a prepaid card
952: *
953: * @param string $userToken The user token
954: * @param string $prepaidCardToken The prepaid card token
955: * @return PrepaidCardStatusTransition
956: *
957: * @throws HyperwalletArgumentException
958: * @throws HyperwalletApiException
959: */
960: public function suspendPrepaidCard($userToken, $prepaidCardToken) {
961: $transition = new PrepaidCardStatusTransition();
962: $transition->setTransition(PrepaidCardStatusTransition::TRANSITION_SUSPENDED);
963:
964: return $this->createPrepaidCardStatusTransition($userToken, $prepaidCardToken, $transition);
965: }
966:
967: /**
968: * Unsuspend a prepaid card
969: *
970: * @param string $userToken The user token
971: * @param string $prepaidCardToken The prepaid card token
972: * @return PrepaidCardStatusTransition
973: *
974: * @throws HyperwalletArgumentException
975: * @throws HyperwalletApiException
976: */
977: public function unsuspendPrepaidCard($userToken, $prepaidCardToken) {
978: $transition = new PrepaidCardStatusTransition();
979: $transition->setTransition(PrepaidCardStatusTransition::TRANSITION_UNSUSPENDED);
980:
981: return $this->createPrepaidCardStatusTransition($userToken, $prepaidCardToken, $transition);
982: }
983:
984: /**
985: * Mark a prepaid card as lost or stolen
986: *
987: * @param string $userToken The user token
988: * @param string $prepaidCardToken The prepaid card token
989: * @return PrepaidCardStatusTransition
990: *
991: * @throws HyperwalletArgumentException
992: * @throws HyperwalletApiException
993: */
994: public function lostOrStolenPrepaidCard($userToken, $prepaidCardToken) {
995: $transition = new PrepaidCardStatusTransition();
996: $transition->setTransition(PrepaidCardStatusTransition::TRANSITION_LOST_OR_STOLEN);
997:
998: return $this->createPrepaidCardStatusTransition($userToken, $prepaidCardToken, $transition);
999: }
1000:
1001: /**
1002: * Deactivate a prepaid card
1003: *
1004: * @param string $userToken The user token
1005: * @param string $prepaidCardToken The prepaid card token
1006: * @return PrepaidCardStatusTransition
1007: *
1008: * @throws HyperwalletArgumentException
1009: * @throws HyperwalletApiException
1010: */
1011: public function deactivatePrepaidCard($userToken, $prepaidCardToken) {
1012: $transition = new PrepaidCardStatusTransition();
1013: $transition->setTransition(PrepaidCardStatusTransition::TRANSITION_DE_ACTIVATED);
1014:
1015: return $this->createPrepaidCardStatusTransition($userToken, $prepaidCardToken, $transition);
1016: }
1017:
1018: /**
1019: * Lock a prepaid card
1020: *
1021: * @param string $userToken The user token
1022: * @param string $prepaidCardToken The prepaid card token
1023: * @return PrepaidCardStatusTransition
1024: *
1025: * @throws HyperwalletArgumentException
1026: * @throws HyperwalletApiException
1027: */
1028: public function lockPrepaidCard($userToken, $prepaidCardToken) {
1029: $transition = new PrepaidCardStatusTransition();
1030: $transition->setTransition(PrepaidCardStatusTransition::TRANSITION_LOCKED);
1031:
1032: return $this->createPrepaidCardStatusTransition($userToken, $prepaidCardToken, $transition);
1033: }
1034:
1035: /**
1036: * Unlock a prepaid card
1037: *
1038: * @param string $userToken The user token
1039: * @param string $prepaidCardToken The prepaid card token
1040: * @return PrepaidCardStatusTransition
1041: *
1042: * @throws HyperwalletArgumentException
1043: * @throws HyperwalletApiException
1044: */
1045: public function unlockPrepaidCard($userToken, $prepaidCardToken) {
1046: $transition = new PrepaidCardStatusTransition();
1047: $transition->setTransition(PrepaidCardStatusTransition::TRANSITION_UNLOCKED);
1048:
1049: return $this->createPrepaidCardStatusTransition($userToken, $prepaidCardToken, $transition);
1050: }
1051:
1052: /**
1053: * Create a prepaid card status transition
1054: *
1055: * @param string $userToken The user token
1056: * @param string $prepaidCardToken The prepaid card token
1057: * @param PrepaidCardStatusTransition $transition The status transition
1058: * @return PrepaidCardStatusTransition
1059: *
1060: * @throws HyperwalletArgumentException
1061: * @throws HyperwalletApiException
1062: */
1063: public function createPrepaidCardStatusTransition($userToken, $prepaidCardToken, PrepaidCardStatusTransition $transition) {
1064: if (empty($userToken)) {
1065: throw new HyperwalletArgumentException('userToken is required!');
1066: }
1067: if (empty($prepaidCardToken)) {
1068: throw new HyperwalletArgumentException('prepaidCardToken is required!');
1069: }
1070:
1071: $body = $this->client->doPost('/rest/v4/users/{user-token}/prepaid-cards/{prepaid-card-token}/status-transitions', array(
1072: 'user-token' => $userToken,
1073: 'prepaid-card-token' => $prepaidCardToken
1074: ), $transition, array());
1075: return new PrepaidCardStatusTransition($body);
1076: }
1077:
1078: /**
1079: * Get a prepaid card status transition
1080: *
1081: * @param string $userToken The user token
1082: * @param string $prepaidCardToken The prepaid card token
1083: * @param string $statusTransitionToken The status transition token
1084: * @return PrepaidCardStatusTransition
1085: *
1086: * @throws HyperwalletArgumentException
1087: * @throws HyperwalletApiException
1088: */
1089: public function getPrepaidCardStatusTransition($userToken, $prepaidCardToken, $statusTransitionToken) {
1090: if (empty($userToken)) {
1091: throw new HyperwalletArgumentException('userToken is required!');
1092: }
1093: if (empty($prepaidCardToken)) {
1094: throw new HyperwalletArgumentException('prepaidCardToken is required!');
1095: }
1096: if (empty($statusTransitionToken)) {
1097: throw new HyperwalletArgumentException('statusTransitionToken is required!');
1098: }
1099:
1100: $body = $this->client->doGet('/rest/v4/users/{user-token}/prepaid-cards/{prepaid-card-token}/status-transitions/{status-transition-token}', array(
1101: 'user-token' => $userToken,
1102: 'prepaid-card-token' => $prepaidCardToken,
1103: 'status-transition-token' => $statusTransitionToken
1104: ), array());
1105: return new PrepaidCardStatusTransition($body);
1106: }
1107:
1108: /**
1109: * List all prepaid card status transitions
1110: *
1111: * @param string $userToken The user token
1112: * @param string $prepaidCardToken The prepaid card token
1113: * @param array $options The query parameters
1114: * @return ListResponse
1115: *
1116: * @throws HyperwalletArgumentException
1117: * @throws HyperwalletApiException
1118: */
1119: public function listPrepaidCardStatusTransitions($userToken, $prepaidCardToken, array $options = array()) {
1120: if (empty($userToken)) {
1121: throw new HyperwalletArgumentException('userToken is required!');
1122: }
1123: if (empty($prepaidCardToken)) {
1124: throw new HyperwalletArgumentException('prepaidCardToken is required!');
1125: }
1126: if (!empty($options)) {
1127: $filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
1128: if (!empty($filteredArr)) {
1129: throw new HyperwalletArgumentException('Invalid filter');
1130: }
1131: }
1132:
1133: $body = $this->client->doGet('/rest/v4/users/{user-token}/prepaid-cards/{prepaid-card-token}/status-transitions', array(
1134: 'user-token' => $userToken,
1135: 'prepaid-card-token' => $prepaidCardToken
1136: ), $options);
1137: return new ListResponse($body, function ($entry) {
1138: return new PrepaidCardStatusTransition($entry);
1139: });
1140: }
1141:
1142: //--------------------------------------
1143: // Bank Accounts
1144: //--------------------------------------
1145:
1146: /**
1147: * Create a bank account
1148: *
1149: * @param string $userToken The user token
1150: * @param BankAccount $bankAccount The bank account data
1151: * @return BankAccount
1152: *
1153: * @throws HyperwalletArgumentException
1154: * @throws HyperwalletApiException
1155: */
1156: public function createBankAccount($userToken, BankAccount $bankAccount) {
1157: if (empty($userToken)) {
1158: throw new HyperwalletArgumentException('userToken is required!');
1159: }
1160: $body = $this->client->doPost('/rest/v4/users/{user-token}/bank-accounts', array('user-token' => $userToken), $bankAccount, array());
1161: return new BankAccount($body);
1162: }
1163:
1164: /**
1165: * Get a bank account
1166: *
1167: * @param string $userToken The user token
1168: * @param string $bankAccountToken The bank account token
1169: * @return BankAccount
1170: *
1171: * @throws HyperwalletArgumentException
1172: * @throws HyperwalletApiException
1173: */
1174: public function getBankAccount($userToken, $bankAccountToken) {
1175: if (empty($userToken)) {
1176: throw new HyperwalletArgumentException('userToken is required!');
1177: }
1178: if (empty($bankAccountToken)) {
1179: throw new HyperwalletArgumentException('bankAccountToken is required!');
1180: }
1181: $body = $this->client->doGet('/rest/v4/users/{user-token}/bank-accounts/{bank-account-token}', array(
1182: 'user-token' => $userToken,
1183: 'bank-account-token' => $bankAccountToken
1184: ), array());
1185: return new BankAccount($body);
1186: }
1187:
1188: /**
1189: * Update a bank account
1190: *
1191: * @param string $userToken The user token
1192: * @param BankAccount $bankAccount The bank account data
1193: * @return BankAccount
1194: *
1195: * @throws HyperwalletArgumentException
1196: * @throws HyperwalletApiException
1197: */
1198: public function updateBankAccount($userToken, BankAccount $bankAccount) {
1199: $body = $this->updateTransferMethod($userToken, $bankAccount, 'bank-accounts');
1200: return new BankAccount($body);
1201: }
1202:
1203: /**
1204: * List all bank accounts
1205: *
1206: * @param string $userToken The user token
1207: * @param array $options The query parameters to send
1208: * @return ListResponse
1209: *
1210: * @throws HyperwalletArgumentException
1211: * @throws HyperwalletApiException
1212: */
1213: public function listBankAccounts($userToken, $options = array()) {
1214: if (empty($userToken)) {
1215: throw new HyperwalletArgumentException('userToken is required!');
1216: }
1217: if (!empty($options)) {
1218: $filteredArr = array_diff_key($options, array_flip(BankAccount::FILTERS_ARRAY()));
1219: if (!empty($filteredArr)) {
1220: throw new HyperwalletArgumentException('Invalid filter');
1221: }
1222: }
1223:
1224: $body = $this->client->doGet('/rest/v4/users/{user-token}/bank-accounts', array('user-token' => $userToken), $options);
1225: return new ListResponse($body, function ($entry) {
1226: return new BankAccount($entry);
1227: });
1228: }
1229:
1230: /**
1231: * Deactivate a bank account
1232: *
1233: * @param string $userToken The user token
1234: * @param string $bankAccountToken The bank account token
1235: * @return BankAccountStatusTransition
1236: *
1237: * @throws HyperwalletArgumentException
1238: * @throws HyperwalletApiException
1239: */
1240: public function deactivateBankAccount($userToken, $bankAccountToken) {
1241: $transition = new BankAccountStatusTransition();
1242: $transition->setTransition(BankAccountStatusTransition::TRANSITION_DE_ACTIVATED);
1243:
1244: return $this->createBankAccountStatusTransition($userToken, $bankAccountToken, $transition);
1245: }
1246:
1247: /**
1248: * Create a bank account status transition
1249: *
1250: * @param string $userToken The user token
1251: * @param string $bankAccountToken The bank account token
1252: * @param BankAccountStatusTransition $transition The status transition
1253: * @return BankAccountStatusTransition
1254: *
1255: * @throws HyperwalletArgumentException
1256: * @throws HyperwalletApiException
1257: */
1258: public function createBankAccountStatusTransition($userToken, $bankAccountToken, BankAccountStatusTransition $transition) {
1259: if (empty($userToken)) {
1260: throw new HyperwalletArgumentException('userToken is required!');
1261: }
1262: if (empty($bankAccountToken)) {
1263: throw new HyperwalletArgumentException('bankAccountToken is required!');
1264: }
1265:
1266: $body = $this->client->doPost('/rest/v4/users/{user-token}/bank-accounts/{bank-account-token}/status-transitions', array(
1267: 'user-token' => $userToken,
1268: 'bank-account-token' => $bankAccountToken
1269: ), $transition, array());
1270: return new BankAccountStatusTransition($body);
1271: }
1272:
1273: /**
1274: * Get a bank account status transition
1275: *
1276: * @param string $userToken The user token
1277: * @param string $bankAccountToken The bank account token
1278: * @param string $statusTransitionToken The status transition token
1279: * @return BankAccountStatusTransition
1280: *
1281: * @throws HyperwalletArgumentException
1282: * @throws HyperwalletApiException
1283: */
1284: public function getBankAccountStatusTransition($userToken, $bankAccountToken, $statusTransitionToken) {
1285: if (empty($userToken)) {
1286: throw new HyperwalletArgumentException('userToken is required!');
1287: }
1288: if (empty($bankAccountToken)) {
1289: throw new HyperwalletArgumentException('bankAccountToken is required!');
1290: }
1291: if (empty($statusTransitionToken)) {
1292: throw new HyperwalletArgumentException('statusTransitionToken is required!');
1293: }
1294:
1295: $body = $this->client->doGet('/rest/v4/users/{user-token}/bank-accounts/{bank-account-token}/status-transitions/{status-transition-token}', array(
1296: 'user-token' => $userToken,
1297: 'bank-account-token' => $bankAccountToken,
1298: 'status-transition-token' => $statusTransitionToken
1299: ), array());
1300: return new BankAccountStatusTransition($body);
1301: }
1302:
1303: /**
1304: * List all bank account status transitions
1305: *
1306: * @param string $userToken The user token
1307: * @param string $bankAccountToken The bank account token
1308: * @param array $options The query parameters
1309: * @return ListResponse
1310: *
1311: * @throws HyperwalletArgumentException
1312: * @throws HyperwalletApiException
1313: */
1314: public function listBankAccountStatusTransitions($userToken, $bankAccountToken, array $options = array()) {
1315: if (empty($userToken)) {
1316: throw new HyperwalletArgumentException('userToken is required!');
1317: }
1318: if (empty($bankAccountToken)) {
1319: throw new HyperwalletArgumentException('bankAccountToken is required!');
1320: }
1321: if (!empty($options)) {
1322: $filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
1323: if (!empty($filteredArr)) {
1324: throw new HyperwalletArgumentException('Invalid filter');
1325: }
1326: }
1327:
1328: $body = $this->client->doGet('/rest/v4/users/{user-token}/bank-accounts/{bank-account-token}/status-transitions', array(
1329: 'user-token' => $userToken,
1330: 'bank-account-token' => $bankAccountToken
1331: ), $options);
1332: return new ListResponse($body, function ($entry) {
1333: return new BankAccountStatusTransition($entry);
1334: });
1335: }
1336:
1337: //--------------------------------------
1338: // Bank Cards
1339: //--------------------------------------
1340:
1341: /**
1342: * Create Bank Card
1343: *
1344: * @param string $userToken The user token
1345: * @param BankCard $bankCard The bank card data
1346: * @return BankCard
1347: *
1348: * @throws HyperwalletArgumentException
1349: * @throws HyperwalletApiException
1350: */
1351: public function createBankCard($userToken, BankCard $bankCard) {
1352: if (empty($userToken)) {
1353: throw new HyperwalletArgumentException('userToken is required!');
1354: }
1355: $body = $this->client->doPost('/rest/v4/users/{user-token}/bank-cards', array('user-token' => $userToken), $bankCard, array());
1356: return new BankCard($body);
1357: }
1358:
1359: /**
1360: * Get a bank card
1361: *
1362: * @param string $userToken The user token
1363: * @param string $bankCardToken The bank card token
1364: * @return BankCard
1365: *
1366: * @throws HyperwalletArgumentException
1367: * @throws HyperwalletApiException
1368: */
1369: public function getBankCard($userToken, $bankCardToken) {
1370: if (empty($userToken)) {
1371: throw new HyperwalletArgumentException('userToken is required!');
1372: }
1373: if (empty($bankCardToken)) {
1374: throw new HyperwalletArgumentException('bankCardToken is required!');
1375: }
1376: $body = $this->client->doGet('/rest/v4/users/{user-token}/bank-cards/{bank-card-token}', array(
1377: 'user-token' => $userToken,
1378: 'bank-card-token' => $bankCardToken
1379: ), array());
1380: return new BankCard($body);
1381: }
1382:
1383:
1384: /**
1385: * Update a bank card
1386: *
1387: * @param string $userToken The user token
1388: * @param BankCard $bankCard The bank card data
1389: * @return BankCard
1390: *
1391: * @throws HyperwalletArgumentException
1392: * @throws HyperwalletApiException
1393: */
1394: public function updateBankCard($userToken, BankCard $bankCard) {
1395: $body = $this->updateTransferMethod($userToken, $bankCard, 'bank-cards');
1396: return new BankCard($body);
1397: }
1398:
1399: /**
1400: * List all bank cards
1401: *
1402: * @param string $userToken The user token
1403: * @param array $options The query parameters to send
1404: * @return ListResponse
1405: *
1406: * @throws HyperwalletArgumentException
1407: * @throws HyperwalletApiException
1408: */
1409: public function listBankCards($userToken, $options = array()) {
1410: if (empty($userToken)) {
1411: throw new HyperwalletArgumentException('userToken is required!');
1412: }
1413: if (!empty($options)) {
1414: $filteredArr = array_diff_key($options, array_flip(BankCard::FILTERS_ARRAY()));
1415: if (!empty($filteredArr)) {
1416: throw new HyperwalletArgumentException('Invalid filter');
1417: }
1418: }
1419:
1420: $body = $this->client->doGet('/rest/v4/users/{user-token}/bank-cards', array('user-token' => $userToken), $options);
1421: return new ListResponse($body, function ($entry) {
1422: return new BankCard($entry);
1423: });
1424: }
1425:
1426: /**
1427: * @param string $userToken The user token
1428: * @param string $bankCardToken The bank card token
1429: * @return BankCardStatusTransition
1430: *
1431: * @throws HyperwalletApiException
1432: * @throws HyperwalletArgumentException
1433: */
1434: public function deactivateBankCard($userToken, $bankCardToken) {
1435: $transition = new BankCardStatusTransition();
1436: $transition->setTransition(BankCardStatusTransition::TRANSITION_DE_ACTIVATED);
1437:
1438: return $this->createBankCardStatusTransition($userToken, $bankCardToken, $transition);
1439: }
1440:
1441: /**
1442: * Create a bank card status transition
1443: *
1444: * @param string $userToken The user token
1445: * @param string $bankCardToken The bank card token
1446: * @param BankCardStatusTransition $transition The status transition
1447: * @return BankCardStatusTransition
1448: *
1449: * @throws HyperwalletArgumentException
1450: * @throws HyperwalletApiException
1451: */
1452: public function createBankCardStatusTransition($userToken, $bankCardToken, BankCardStatusTransition $transition) {
1453: if (empty($userToken)) {
1454: throw new HyperwalletArgumentException('userToken is required!');
1455: }
1456: if (empty($bankCardToken)) {
1457: throw new HyperwalletArgumentException('bankCardToken is required!');
1458: }
1459:
1460: $body = $this->client->doPost('/rest/v4/users/{user-token}/bank-cards/{bank-card-token}/status-transitions', array(
1461: 'user-token' => $userToken,
1462: 'bank-card-token' => $bankCardToken
1463: ), $transition, array());
1464: return new BankCardStatusTransition($body);
1465: }
1466:
1467: /**
1468: * Get a bank card status transition
1469: *
1470: * @param string $userToken The user token
1471: * @param string $bankCardToken The bank card token
1472: * @param string $statusTransitionToken The status transition token
1473: * @return BankCardStatusTransition
1474: *
1475: * @throws HyperwalletApiException
1476: * @throws HyperwalletArgumentException
1477: */
1478: public function getBankCardStatusTransition($userToken, $bankCardToken, $statusTransitionToken) {
1479: if (empty($userToken)) {
1480: throw new HyperwalletArgumentException('userToken is required!');
1481: }
1482: if (empty($bankCardToken)) {
1483: throw new HyperwalletArgumentException('bankCardToken is required!');
1484: }
1485: if (empty($statusTransitionToken)) {
1486: throw new HyperwalletArgumentException('statusTransitionToken is required!');
1487: }
1488:
1489: $body = $this->client->doGet('/rest/v4/users/{user-token}/bank-cards/{bank-card-token}/status-transitions/{status-transition-token}', array(
1490: 'user-token' => $userToken,
1491: 'bank-card-token' => $bankCardToken,
1492: 'status-transition-token' => $statusTransitionToken
1493: ), array());
1494: return new BankCardStatusTransition($body);
1495: }
1496:
1497: /**
1498: * List all bank card status transitions
1499: *
1500: * @param string $userToken The user token
1501: * @param string $bankCardToken The bank card token
1502: * @param array $options The query parameters
1503: * @return ListResponse
1504: *
1505: * @throws HyperwalletArgumentException
1506: * @throws HyperwalletApiException
1507: */
1508: public function listBankCardStatusTransitions($userToken, $bankCardToken, array $options = array()) {
1509: if (empty($userToken)) {
1510: throw new HyperwalletArgumentException('userToken is required!');
1511: }
1512: if (empty($bankCardToken)) {
1513: throw new HyperwalletArgumentException('bankCardToken is required!');
1514: }
1515: if (!empty($options)) {
1516: $filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
1517: if (!empty($filteredArr)) {
1518: throw new HyperwalletArgumentException('Invalid filter');
1519: }
1520: }
1521:
1522: $body = $this->client->doGet('/rest/v4/users/{user-token}/bank-cards/{bank-card-token}/status-transitions', array(
1523: 'user-token' => $userToken,
1524: 'bank-card-token' => $bankCardToken
1525: ), $options);
1526: return new ListResponse($body, function ($entry) {
1527: return new BankCardStatusTransition($entry);
1528: });
1529: }
1530:
1531: //--------------------------------------
1532: // Transfer Methods
1533: //--------------------------------------
1534:
1535: /**
1536: * Create a transfer method
1537: *
1538: * @param string $userToken The user token
1539: * @param string $jsonCacheToken The json cache token supplied by the widget
1540: * @param TransferMethod $transferMethod The transfer method data (to override certain fields)
1541: * @return BankAccount|PrepaidCard
1542: *
1543: * @throws HyperwalletArgumentException
1544: * @throws HyperwalletApiException
1545: */
1546: public function createTransferMethod($userToken, $jsonCacheToken, TransferMethod $transferMethod = null) {
1547: if (empty($userToken)) {
1548: throw new HyperwalletArgumentException('userToken is required!');
1549: }
1550: if (empty($jsonCacheToken)) {
1551: throw new HyperwalletArgumentException('jsonCacheToken is required!');
1552: }
1553: $body = $this->client->doPost('/rest/v4/users/{user-token}/transfer-methods', array('user-token' => $userToken), $transferMethod, array(), array(
1554: 'Json-Cache-Token' => $jsonCacheToken
1555: ));
1556: if ($body['type'] === PrepaidCard::TYPE_PREPAID_CARD) {
1557: return new PrepaidCard($body);
1558: }
1559: return new BankAccount($body);
1560: }
1561:
1562: //--------------------------------------
1563: // Balances
1564: //--------------------------------------
1565:
1566: /**
1567: * List balances for a user
1568: *
1569: * @param string $userToken The user token
1570: * @param array $options The query parameters
1571: * @return ListResponse
1572: *
1573: * @throws HyperwalletArgumentException
1574: */
1575: public function listBalancesForUser($userToken, $options = array()) {
1576: if (empty($userToken)) {
1577: throw new HyperwalletArgumentException('userToken is required!');
1578: }
1579: if (!empty($options)) {
1580: $filteredArr = array_diff_key($options, array_flip(Balance::FILTERS_ARRAY_USER()));
1581: if (!empty($filteredArr)) {
1582: throw new HyperwalletArgumentException('Invalid filter');
1583: }
1584: }
1585:
1586: $body = $this->client->doGet('/rest/v4/users/{user-token}/balances', array('user-token' => $userToken), $options);
1587: $listResponse = new ListResponse($body, function ($entry) {
1588: return new Balance($entry);
1589: });
1590: call_user_func(array($listResponse, 'unsetLinksAttribute'));
1591: return $listResponse;
1592: }
1593:
1594: /**
1595: * List balances for a prepaid card
1596: *
1597: * @param string $userToken The user token
1598: * @param string $prepaidCardToken The prepaid card token
1599: * @param array $options The query parameters
1600: * @return ListResponse
1601: *
1602: * @throws HyperwalletArgumentException
1603: */
1604: public function listBalancesForPrepaidCard($userToken, $prepaidCardToken, $options = array()) {
1605: if (empty($userToken)) {
1606: throw new HyperwalletArgumentException('userToken is required!');
1607: }
1608: if (empty($prepaidCardToken)) {
1609: throw new HyperwalletArgumentException('prepaidCardToken is required!');
1610: }
1611: if (!empty($options)) {
1612: $filteredArr = array_diff_key($options, array_flip(Balance::FILTERS_ARRAY_PREPAID_CARD()));
1613: if (!empty($filteredArr)) {
1614: throw new HyperwalletArgumentException('Invalid filter');
1615: }
1616: }
1617:
1618: $body = $this->client->doGet('/rest/v4/users/{user-token}/prepaid-cards/{prepaid-card-token}/balances', array(
1619: 'user-token' => $userToken,
1620: 'prepaid-card-token' => $prepaidCardToken
1621: ), $options);
1622: $listResponse = new ListResponse($body, function ($entry) {
1623: return new Balance($entry);
1624: });
1625: call_user_func(array($listResponse, 'unsetLinksAttribute'));
1626: return $listResponse;
1627: }
1628:
1629: /**
1630: * List balances for a program account
1631: *
1632: * @param string $programToken The program token
1633: * @param string $accountToken The account token
1634: * @param array $options The query parameters
1635: * @return ListResponse
1636: *
1637: * @throws HyperwalletArgumentException
1638: */
1639: public function listBalancesForAccount($programToken, $accountToken, $options = array()) {
1640: if (empty($programToken)) {
1641: throw new HyperwalletArgumentException('programToken is required!');
1642: }
1643: if (empty($accountToken)) {
1644: throw new HyperwalletArgumentException('accountToken is required!');
1645: }
1646: if (!empty($options)) {
1647: $filteredArr = array_diff_key($options, array_flip(Balance::FILTERS_ARRAY_ACCOUNT()));
1648: if (!empty($filteredArr)) {
1649: throw new HyperwalletArgumentException('Invalid filter');
1650: }
1651: }
1652:
1653: $body = $this->client->doGet('/rest/v4/programs/{program-token}/accounts/{account-token}/balances', array(
1654: 'program-token' => $programToken,
1655: 'account-token' => $accountToken
1656: ), $options);
1657: $listResponse = new ListResponse($body, function ($entry) {
1658: return new Balance($entry);
1659: });
1660: call_user_func(array($listResponse, 'unsetLinksAttribute'));
1661: return $listResponse;
1662: }
1663:
1664: //--------------------------------------
1665: // Payments
1666: //--------------------------------------
1667:
1668: /**
1669: * Create a payment
1670: *
1671: * @param Payment $payment The payment
1672: * @return Payment
1673: *
1674: * @throws HyperwalletApiException
1675: */
1676: public function createPayment(Payment $payment) {
1677: $this->addProgramToken($payment);
1678: $body = $this->client->doPost('/rest/v4/payments', array(), $payment, array());
1679: return new Payment($body);
1680: }
1681:
1682: /**
1683: * Get a payment
1684: *
1685: * @param string $paymentToken The payment token
1686: * @return Payment
1687: *
1688: * @throws HyperwalletArgumentException
1689: * @throws HyperwalletApiException
1690: */
1691: public function getPayment($paymentToken) {
1692: if (empty($paymentToken)) {
1693: throw new HyperwalletArgumentException('paymentToken is required!');
1694: }
1695: $body = $this->client->doGet('/rest/v4/payments/{payment-token}', array('payment-token' => $paymentToken), array());
1696: return new Payment($body);
1697: }
1698:
1699: /**
1700: * List all payments
1701: *
1702: * @param array $options The query parameters
1703: * @return ListResponse
1704: *
1705: * @throws HyperwalletApiException
1706: */
1707: public function listPayments($options = array()) {
1708: if (!empty($options)) {
1709: $filteredArr = array_diff_key($options, array_flip(Payment::FILTERS_ARRAY()));
1710: if (!empty($filteredArr)) {
1711: throw new HyperwalletArgumentException('Invalid filter');
1712: }
1713: }
1714:
1715: $body = $this->client->doGet('/rest/v4/payments', array(), $options);
1716: return new ListResponse($body, function ($entry) {
1717: return new Payment($entry);
1718: });
1719: }
1720:
1721: /**
1722: * Create a payment status transition
1723: *
1724: * @param string $paymentToken The payment token
1725: * @param PaymentStatusTransition $transition The status transition
1726: * @return PaymentStatusTransition
1727: *
1728: * @throws HyperwalletArgumentException
1729: * @throws HyperwalletApiException
1730: */
1731: public function createPaymentStatusTransition($paymentToken, PaymentStatusTransition $transition) {
1732: if (empty($paymentToken)) {
1733: throw new HyperwalletArgumentException('paymentToken is required!');
1734: }
1735:
1736: $body = $this->client->doPost('/rest/v4/payments/{payment-token}/status-transitions', array(
1737: 'payment-token' => $paymentToken
1738: ), $transition, array());
1739: return new PaymentStatusTransition($body);
1740: }
1741:
1742: /**
1743: * Get a payment status transition
1744: *
1745: * @param string $paymentToken The payment token
1746: * @param string $statusTransitionToken The status transition token
1747: * @return PaymentStatusTransition
1748: *
1749: * @throws HyperwalletArgumentException
1750: * @throws HyperwalletApiException
1751: */
1752: public function getPaymentStatusTransition($paymentToken, $statusTransitionToken) {
1753: if (empty($paymentToken)) {
1754: throw new HyperwalletArgumentException('paymentToken is required!');
1755: }
1756: if (empty($statusTransitionToken)) {
1757: throw new HyperwalletArgumentException('statusTransitionToken is required!');
1758: }
1759:
1760: $body = $this->client->doGet('/rest/v4/payments/{payment-token}/status-transitions/{status-transition-token}', array(
1761: 'payment-token' => $paymentToken,
1762: 'status-transition-token' => $statusTransitionToken
1763: ), array());
1764: return new PaymentStatusTransition($body);
1765: }
1766:
1767: /**
1768: * List all payment status transitions
1769: *
1770: * @param string $paymentToken The payment token
1771: * @param array $options The query parameters
1772: * @return ListResponse
1773: *
1774: * @throws HyperwalletArgumentException
1775: * @throws HyperwalletApiException
1776: */
1777: public function listPaymentStatusTransitions($paymentToken, array $options = array()) {
1778: if (empty($paymentToken)) {
1779: throw new HyperwalletArgumentException('paymentToken is required!');
1780: }
1781: if (!empty($options)) {
1782: $filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
1783: if (!empty($filteredArr)) {
1784: throw new HyperwalletArgumentException('Invalid filter');
1785: }
1786: }
1787:
1788: $body = $this->client->doGet('/rest/v4/payments/{payment-token}/status-transitions', array(
1789: 'payment-token' => $paymentToken
1790: ), $options);
1791: return new ListResponse($body, function ($entry) {
1792: return new PaymentStatusTransition($entry);
1793: });
1794: }
1795:
1796: //--------------------------------------
1797: // Programs
1798: //--------------------------------------
1799:
1800: /**
1801: * Get a program
1802: *
1803: * @param string $programToken The program token
1804: * @return Program
1805: *
1806: * @throws HyperwalletArgumentException
1807: * @throws HyperwalletApiException
1808: */
1809: public function getProgram($programToken) {
1810: if (empty($programToken)) {
1811: throw new HyperwalletArgumentException('programToken is required!');
1812: }
1813: $body = $this->client->doGet('/rest/v4/programs/{program-token}', array('program-token' => $programToken), array());
1814: return new Program($body);
1815: }
1816:
1817: //--------------------------------------
1818: // Program Accounts
1819: //--------------------------------------
1820:
1821: /**
1822: * Get a program account
1823: *
1824: * @param string $programToken The program token
1825: * @param string $accountToken The account token
1826: * @return ProgramAccount
1827: *
1828: * @throws HyperwalletArgumentException
1829: * @throws HyperwalletApiException
1830: */
1831: public function getProgramAccount($programToken, $accountToken) {
1832: if (empty($programToken)) {
1833: throw new HyperwalletArgumentException('programToken is required!');
1834: }
1835: if (empty($accountToken)) {
1836: throw new HyperwalletArgumentException('accountToken is required!');
1837: }
1838: $body = $this->client->doGet('/rest/v4/programs/{program-token}/accounts/{account-token}', array(
1839: 'program-token' => $programToken,
1840: 'account-token' => $accountToken
1841: ), array());
1842: return new ProgramAccount($body);
1843: }
1844:
1845: //--------------------------------------
1846: // Transfer Method Configurations
1847: //--------------------------------------
1848:
1849: /**
1850: * Get a transfer method configuration
1851: *
1852: * @param string $userToken The user token
1853: * @param string $country The transfer method country
1854: * @param string $currency The transfer method currency
1855: * @param string $type The transfer method type
1856: * @param string $profileType The profile type
1857: * @return TransferMethodConfiguration
1858: *
1859: * @throws HyperwalletArgumentException
1860: * @throws HyperwalletApiException
1861: */
1862: public function getTransferMethodConfiguration($userToken, $country, $currency, $type, $profileType) {
1863: if (empty($userToken)) {
1864: throw new HyperwalletArgumentException('userToken is required!');
1865: }
1866: if (empty($country)) {
1867: throw new HyperwalletArgumentException('country is required!');
1868: }
1869: if (empty($currency)) {
1870: throw new HyperwalletArgumentException('currency is required!');
1871: }
1872: if (empty($type)) {
1873: throw new HyperwalletArgumentException('type is required!');
1874: }
1875: if (empty($profileType)) {
1876: throw new HyperwalletArgumentException('profileType is required!');
1877: }
1878:
1879: $body = $this->client->doGet('/rest/v4/transfer-method-configurations', array(), array(
1880: 'userToken' => $userToken,
1881: 'country' => $country,
1882: 'currency' => $currency,
1883: 'type' => $type,
1884: 'profileType' => $profileType
1885: ));
1886: return new TransferMethodConfiguration($body);
1887: }
1888:
1889: /**
1890: * List all transfer method configurations
1891: *
1892: * @param string $userToken The user token
1893: * @param array $options The query parameters
1894: * @return ListResponse
1895: *
1896: * @throws HyperwalletArgumentException
1897: * @throws HyperwalletApiException
1898: */
1899: public function listTransferMethodConfigurations($userToken, $options = array()) {
1900: if (empty($userToken)) {
1901: throw new HyperwalletArgumentException('userToken is required!');
1902: }
1903: if (!empty($options)) {
1904: $filteredArr = array_diff_key($options, array_flip(TransferMethodConfiguration::FILTERS_ARRAY()));
1905: if (!empty($filteredArr)) {
1906: throw new HyperwalletArgumentException('Invalid filter');
1907: }
1908: }
1909:
1910: $body = $this->client->doGet('/rest/v4/transfer-method-configurations', array(), array_merge(array(
1911: 'userToken' => $userToken,
1912: ), $options));
1913: return new ListResponse($body, function ($entity) {
1914: return new TransferMethodConfiguration($entity);
1915: });
1916: }
1917:
1918: //--------------------------------------
1919: // Receipts
1920: //--------------------------------------
1921:
1922: /**
1923: * List all program account receipts
1924: *
1925: * @param string $programToken The program token
1926: * @param string $accountToken The program account token
1927: * @param array $options The query parameters
1928: * @return ListResponse of HyperwalletReceipt
1929: *
1930: * @throws HyperwalletArgumentException
1931: * @throws HyperwalletApiException
1932: */
1933: public function listReceiptsForProgramAccount($programToken, $accountToken, $options = array()) {
1934: if (empty($programToken)) {
1935: throw new HyperwalletArgumentException('programToken is required!');
1936: }
1937: if (empty($accountToken)) {
1938: throw new HyperwalletArgumentException('accountToken is required!');
1939: }
1940: if (!empty($options)) {
1941: $filteredArr = array_diff_key($options, array_flip(Receipt::FILTERS_ARRAY_ACCOUNT()));
1942: if (!empty($filteredArr)) {
1943: throw new HyperwalletArgumentException('Invalid filter');
1944: }
1945: }
1946:
1947: $body = $this->client->doGet('/rest/v4/programs/{program-token}/accounts/{account-token}/receipts', array(
1948: 'program-token' => $programToken,
1949: 'account-token' => $accountToken
1950: ), $options);
1951: return new ListResponse($body, function ($entry) {
1952: return new Receipt($entry);
1953: });
1954: }
1955:
1956: /**
1957: * List all user receipts
1958: *
1959: * @param string $userToken The user token
1960: * @param array $options The query parameters
1961: * @return ListResponse of HyperwalletReceipt
1962: *
1963: * @throws HyperwalletArgumentException
1964: * @throws HyperwalletApiException
1965: */
1966: public function listReceiptsForUser($userToken, $options = array()) {
1967: if (empty($userToken)) {
1968: throw new HyperwalletArgumentException('userToken is required!');
1969: }
1970: if (!empty($options)) {
1971: $filteredArr = array_diff_key($options, array_flip(Receipt::FILTERS_ARRAY_USER()));
1972: if (!empty($filteredArr)) {
1973: throw new HyperwalletArgumentException('Invalid filter');
1974: }
1975: }
1976:
1977: $body = $this->client->doGet('/rest/v4/users/{user-token}/receipts', array(
1978: 'user-token' => $userToken
1979: ), $options);
1980: return new ListResponse($body, function ($entry) {
1981: return new Receipt($entry);
1982: });
1983: }
1984:
1985: /**
1986: * List all prepaid card receipts
1987: *
1988: * @param string $userToken The user token
1989: * @param string $prepaidCardToken The prepaid card token
1990: * @param array $options The query parameters
1991: * @return ListResponse of HyperwalletReceipt
1992: *
1993: * @throws HyperwalletArgumentException
1994: * @throws HyperwalletApiException
1995: */
1996: public function listReceiptsForPrepaidCard($userToken, $prepaidCardToken, $options = array()) {
1997: if (empty($userToken)) {
1998: throw new HyperwalletArgumentException('userToken is required!');
1999: }
2000: if (empty($prepaidCardToken)) {
2001: throw new HyperwalletArgumentException('prepaidCardToken is required!');
2002: }
2003: if (!empty($options)) {
2004: $filteredArr = array_diff_key($options, array_flip(Receipt::FILTERS_ARRAY_PREPAID_CARD()));
2005: if (!empty($filteredArr)) {
2006: throw new HyperwalletArgumentException('Invalid filter');
2007: }
2008: }
2009:
2010: $body = $this->client->doGet('/rest/v4/users/{user-token}/prepaid-cards/{prepaid-card-token}/receipts', array(
2011: 'user-token' => $userToken,
2012: 'prepaid-card-token' => $prepaidCardToken
2013: ), $options);
2014: return new ListResponse($body, function ($entry) {
2015: return new Receipt($entry);
2016: });
2017: }
2018:
2019: //--------------------------------------
2020: // Webhook Notifications
2021: //--------------------------------------
2022:
2023: /**
2024: * Get a webhook notification
2025: *
2026: * @param string $webhookNotificationToken The webhook notification token
2027: * @return WebhookNotification
2028: *
2029: * @throws HyperwalletArgumentException
2030: * @throws HyperwalletApiException
2031: */
2032: public function getWebhookNotification($webhookNotificationToken) {
2033: if (empty($webhookNotificationToken)) {
2034: throw new HyperwalletArgumentException('webhookNotificationToken is required!');
2035: }
2036: $body = $this->client->doGet('/rest/v4/webhook-notifications/{webhook-notification-token}', array('webhook-notification-token' => $webhookNotificationToken), array());
2037: return new WebhookNotification($body);
2038: }
2039:
2040: /**
2041: * List all webhook notifications
2042: *
2043: * @param array $options
2044: * @return ListResponse
2045: *
2046: * @throws HyperwalletApiException
2047: */
2048: public function listWebhookNotifications($options = array()) {
2049: if (!empty($options)) {
2050: $filteredArr = array_diff_key($options, array_flip(WebhookNotification::FILTERS_ARRAY()));
2051: if (!empty($filteredArr)) {
2052: throw new HyperwalletArgumentException('Invalid filter');
2053: }
2054: }
2055:
2056: $body = $this->client->doGet('/rest/v4/webhook-notifications', array(), $options);
2057: return new ListResponse($body, function ($entry) {
2058: return new WebhookNotification($entry);
2059: });
2060: }
2061:
2062: //--------------------------------------
2063: // Internal utils
2064: //--------------------------------------
2065:
2066: /**
2067: * Add program token if global specified
2068: *
2069: * @param IProgramAware $model The model
2070: */
2071: private function addProgramToken(IProgramAware $model) {
2072: if (empty($this->programToken)) {
2073: return;
2074: }
2075: if ($model->getProgramToken()) {
2076: return;
2077: }
2078: $model->setProgramToken($this->programToken);
2079: }
2080:
2081: /**
2082: * Update Transfer method
2083: *
2084: * @param string $userToken The user token
2085: * @param object $transferMethod Transfer method data
2086: * @param string $transferMethodName Transfer method name to be used in url
2087: * @return object Updated transfer method object
2088: *
2089: * @throws HyperwalletArgumentException
2090: * @throws HyperwalletApiException
2091: */
2092: private function updateTransferMethod($userToken, $transferMethod, $transferMethodName) {
2093: if (empty($userToken)) {
2094: throw new HyperwalletArgumentException('userToken is required!');
2095: }
2096: if (!$transferMethod->getToken()) {
2097: throw new HyperwalletArgumentException('transfer method token is required!');
2098: }
2099:
2100: return $this->client->doPut('/rest/v4/users/{user-token}/{transfer-method-name}/{transfer-method-token}', array(
2101: 'user-token' => $userToken,
2102: 'transfer-method-token' => $transferMethod->getToken(),
2103: 'transfer-method-name' => $transferMethodName,
2104: ), $transferMethod, array());
2105: }
2106:
2107: /*
2108: * Update user verification status
2109: *
2110: * @param string $userToken The user token
2111: * @param UserStatusTransition $transition The status transition
2112: * @return UserStatusTransition
2113: * @throws HyperwalletArgumentException
2114: * @throws HyperwalletApiException
2115: */
2116: public function updateVerificationStatus($userToken, $verificationStatus){
2117: if (empty($userToken)) {
2118: throw new HyperwalletArgumentException('userToken is required!');
2119: }
2120: if (empty($verificationStatus)) {
2121: throw new HyperwalletArgumentException('verificationStatus is required!');
2122: }
2123: $user = new User(array('verificationStatus'=> $verificationStatus));
2124: $responseUser = $this->client->doPut('/rest/v4/users/{user-token}', array('user-token' => $userToken), $user, array());
2125: return new User($responseUser);
2126: }
2127:
2128: /**
2129: * Create an User status transition
2130: *
2131: * @param string $userToken The user token
2132: * @param UserStatusTransition $transition The status transition
2133: * @return UserStatusTransition
2134: * @throws HyperwalletArgumentException
2135: * @throws HyperwalletApiException
2136: */
2137: public function createUserStatusTransition($userToken, UserStatusTransition $transition) {
2138: if (empty($userToken)) {
2139: throw new HyperwalletArgumentException('userToken is required!');
2140: }
2141: if (empty($transition->getTransition())) {
2142: throw new HyperwalletArgumentException('userStatusTransition is required!');
2143: }
2144: $body = $this->client->doPost('/rest/v4/users/{user-token}/status-transitions', array(
2145: 'user-token' => $userToken), $transition, array());
2146: return new UserStatusTransition($body);
2147: }
2148:
2149: /**
2150: * Activate a User
2151: *
2152: * @param string $userToken The user token
2153: * @return UserStatusTransition the status transition
2154: * @throws HyperwalletArgumentException
2155: * @throws HyperwalletApiException
2156: */
2157: public function activateUser($userToken) {
2158: $transition = new UserStatusTransition();
2159: $transition->setTransition(UserStatusTransition::TRANSITION_ACTIVATED);
2160: return $this->createUserStatusTransition($userToken, $transition);
2161: }
2162:
2163: /**
2164: * De-activate a User
2165: *
2166: * @param string $userToken The user token
2167: * @return UserStatusTransition the status transition
2168: * @throws HyperwalletArgumentException
2169: * @throws HyperwalletApiException
2170: */
2171: public function deactivateUser($userToken) {
2172: $transition = new UserStatusTransition();
2173: $transition->setTransition(UserStatusTransition::TRANSITION_DE_ACTIVATED);
2174: return $this->createUserStatusTransition($userToken, $transition);
2175: }
2176:
2177: /**
2178: * Lock a User account
2179: *
2180: * @param string $userToken User token
2181: * @return UserStatusTransition the status transition
2182: * @throws HyperwalletArgumentException
2183: * @throws HyperwalletApiException
2184: */
2185: public function lockUser($userToken) {
2186: $transition = new UserStatusTransition();
2187: $transition->setTransition(UserStatusTransition::TRANSITION_LOCKED);
2188: return $this->createUserStatusTransition($userToken, $transition);
2189: }
2190:
2191: /**
2192: * Freeze a User account
2193: *
2194: * @param string $userToken User token
2195: * @return UserStatusTransition the status transition
2196: * @throws HyperwalletArgumentException
2197: * @throws HyperwalletApiException
2198: */
2199: public function freezeUser($userToken) {
2200: $transition = new UserStatusTransition();
2201: $transition->setTransition(UserStatusTransition::TRANSITION_FROZEN);
2202: return $this->createUserStatusTransition($userToken, $transition);
2203: }
2204:
2205: /**
2206: * Pre-activate a User account
2207: *
2208: * @param string $userToken User token
2209: * @return UserStatusTransition the status transition
2210: * @throws HyperwalletArgumentException
2211: * @throws HyperwalletApiException
2212: */
2213: public function preactivateUser($userToken) {
2214: $transition = new UserStatusTransition();
2215: $transition->setTransition(UserStatusTransition::TRANSITION_PRE_ACTIVATED);
2216: return $this->createUserStatusTransition($userToken, $transition);
2217: }
2218:
2219:
2220: /**
2221: * Upload documents for user endpoint
2222: *
2223: * @param string $userToken The user token
2224: * @param array $options The multipart object with the required documents and json data to get uploaded
2225: *
2226: * Sample multipart array to refer. Don't set the content-type explicitly
2227: * array(
2228: *'multipart' => [
2229: * [
2230: * 'name' => 'data',
2231: * 'contents' => '{"documents":[{"type":"DRIVERS_LICENSE","country":"US","category":"IDENTIFICATION"}]}'
2232: * ],
2233: * [
2234: * 'name' => 'drivers_license_front',
2235: * 'contents' => fopen('<path>/File1.png', "r")
2236: * ],
2237: * [
2238: * 'name' => 'drivers_license_back',
2239: * 'contents' => fopen('<path>>/File2.png', 'r')
2240: * ]
2241: * ]
2242: * ));
2243: *
2244: * @return User user object with updated VerificationStatus and document details
2245: *
2246: */
2247:
2248: public function uploadDocumentsForUser($userToken, $options) {
2249: if (empty($userToken)) {
2250: throw new HyperwalletArgumentException('userToken is required!');
2251: }
2252: $body = $this->client->putMultipartData('/rest/v4/users/{user-token}', array('user-token' => $userToken), $options);
2253: $body = $this->setDocumentAndReasonFromResponseHelper($body);
2254: return new User($body);
2255: }
2256:
2257: //--------------------------------------
2258: // Venmo Accounts
2259: //--------------------------------------
2260:
2261: /**
2262: * Create a Venmo account
2263: *
2264: * @param string $userToken user token
2265: * @param VenmoAccount $venmoAccount Venmo account data
2266: * @return VenmoAccount
2267: *
2268: * @throws HyperwalletArgumentException
2269: * @throws HyperwalletApiException
2270: */
2271: public function createVenmoAccount($userToken, VenmoAccount $venmoAccount) {
2272: if (empty($userToken)) {
2273: throw new HyperwalletArgumentException('userToken is required!');
2274: }
2275: if (empty($venmoAccount->getTransferMethodCountry())) {
2276: throw new HyperwalletArgumentException('transferMethodCountry is required!');
2277: }
2278: if (empty($venmoAccount->getTransferMethodCurrency())) {
2279: throw new HyperwalletArgumentException('transferMethodCurrency is required!');
2280: }
2281: if (empty($venmoAccount->getAccountId())) {
2282: throw new HyperwalletArgumentException('Venmo account is required!');
2283: }
2284: $body = $this->client->doPost('/rest/v4/users/{user-token}/venmo-accounts', array('user-token' => $userToken), $venmoAccount, array());
2285: return new VenmoAccount($body);
2286: }
2287:
2288: /**
2289: * Get a Venmo account
2290: *
2291: * @param string $userToken user token
2292: * @param string $venmoAccountToken Venmo account token
2293: * @return VenmoAccount
2294: *
2295: * @throws HyperwalletArgumentException
2296: * @throws HyperwalletApiException
2297: */
2298: public function getVenmoAccount($userToken, $venmoAccountToken) {
2299: if (empty($userToken)) {
2300: throw new HyperwalletArgumentException('userToken is required!');
2301: }
2302: if (empty($venmoAccountToken)) {
2303: throw new HyperwalletArgumentException('venmoAccountToken is required!');
2304: }
2305: $body = $this->client->doGet('/rest/v4/users/{user-token}/venmo-accounts/{venmo-account-token}', array(
2306: 'user-token' => $userToken,
2307: 'venmo-account-token' => $venmoAccountToken
2308: ), array());
2309: return new VenmoAccount($body);
2310: }
2311:
2312: /**
2313: * Update Venmo account
2314: *
2315: * @param string $userToken user token
2316: * @param VenmoAccount $venmoAccount Venmo account data
2317: * @return VenmoAccount
2318: *
2319: */
2320: public function updateVenmoAccount($userToken, VenmoAccount $venmoAccount) {
2321: $body = $this->updateTransferMethod($userToken, $venmoAccount, 'venmo-accounts');
2322: return new VenmoAccount($body);
2323: }
2324:
2325: /**
2326: * List all Venmo accounts
2327: *
2328: * @param string $userToken user token
2329: * @param array $options The query parameters to send
2330: * @return ListResponse
2331: *
2332: * @throws HyperwalletApiException
2333: */
2334: public function listVenmoAccounts($userToken, $options = array()) {
2335: if (empty($userToken)) {
2336: throw new HyperwalletArgumentException('userToken is required!');
2337: }
2338: if (!empty($options)) {
2339: $filteredArr = array_diff_key($options, array_flip(VenmoAccount::FILTERS_ARRAY()));
2340: if (!empty($filteredArr)) {
2341: throw new HyperwalletArgumentException('Invalid filter');
2342: }
2343: }
2344:
2345: $body = $this->client->doGet('/rest/v4/users/{user-token}/venmo-accounts', array('user-token' => $userToken), $options);
2346: return new ListResponse($body, function ($entry) {
2347: return new VenmoAccount($entry);
2348: });
2349: }
2350:
2351: /**
2352: * Deactivate a Venmo account
2353: *
2354: * @param string $userToken user token
2355: * @param string $venmoAccountToken Venmo account token
2356: * @return VenmoAccountStatusTransition
2357: *
2358: * @throws HyperwalletArgumentException
2359: * @throws HyperwalletApiException
2360: */
2361: public function deactivateVenmoAccount($userToken, $venmoAccountToken) {
2362: $transition = new VenmoAccountStatusTransition();
2363: $transition->setTransition(VenmoAccountStatusTransition::TRANSITION_DE_ACTIVATED);
2364:
2365: return $this->createVenmoAccountStatusTransition($userToken, $venmoAccountToken, $transition);
2366: }
2367:
2368: /**
2369: * Create a Venmo account status transition
2370: *
2371: * @param string $userToken user token
2372: * @param string $venmoAccountToken Venmo account token
2373: * @param VenmoAccountStatusTransition $transition status transition
2374: * @return VenmoAccountStatusTransition
2375: *
2376: * @throws HyperwalletArgumentException
2377: * @throws HyperwalletApiException
2378: */
2379: public function createVenmoAccountStatusTransition($userToken, $venmoAccountToken, VenmoAccountStatusTransition $transition) {
2380: if (empty($userToken)) {
2381: throw new HyperwalletArgumentException('userToken is required!');
2382: }
2383: if (empty($venmoAccountToken)) {
2384: throw new HyperwalletArgumentException('venmoAccountToken is required!');
2385: }
2386:
2387: $body = $this->client->doPost('/rest/v4/users/{user-token}/venmo-accounts/{venmo-account-token}/status-transitions', array(
2388: 'user-token' => $userToken,
2389: 'venmo-account-token' => $venmoAccountToken
2390: ), $transition, array());
2391: return new VenmoAccountStatusTransition($body);
2392: }
2393:
2394: /**
2395: * Get a Venmo account status transition
2396: *
2397: * @param string $userToken user token
2398: * @param string $venmoAccountToken Venmo account token
2399: * @param string $statusTransitionToken status transition token
2400: * @return VenmoAccountStatusTransition
2401: *
2402: * @throws HyperwalletArgumentException
2403: * @throws HyperwalletApiException
2404: */
2405: public function getVenmoAccountStatusTransition($userToken, $venmoAccountToken, $statusTransitionToken) {
2406: if (empty($userToken)) {
2407: throw new HyperwalletArgumentException('userToken is required!');
2408: }
2409: if (empty($venmoAccountToken)) {
2410: throw new HyperwalletArgumentException('venmoAccountToken is required!');
2411: }
2412: if (empty($statusTransitionToken)) {
2413: throw new HyperwalletArgumentException('statusTransitionToken is required!');
2414: }
2415:
2416: $body = $this->client->doGet('/rest/v4/users/{user-token}/venmo-accounts/{venmo-account-token}/status-transitions/{status-transition-token}', array(
2417: 'user-token' => $userToken,
2418: 'venmo-account-token' => $venmoAccountToken,
2419: 'status-transition-token' => $statusTransitionToken
2420: ), array());
2421: return new VenmoAccountStatusTransition($body);
2422: }
2423:
2424: /**
2425: * List all Venmo account status transitions
2426: *
2427: * @param string $userToken user token
2428: * @param string $venmoAccountToken Venmo account token
2429: * @param array $options query parameters
2430: * @return ListResponse
2431: *
2432: * @throws HyperwalletArgumentException
2433: * @throws HyperwalletApiException
2434: */
2435: public function listVenmoAccountStatusTransitions($userToken, $venmoAccountToken, array $options = array()) {
2436: if (empty($userToken)) {
2437: throw new HyperwalletArgumentException('userToken is required!');
2438: }
2439: if (empty($venmoAccountToken)) {
2440: throw new HyperwalletArgumentException('venmoAccountToken is required!');
2441: }
2442: if (!empty($options)) {
2443: $filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
2444: if (!empty($filteredArr)) {
2445: throw new HyperwalletArgumentException('Invalid filter');
2446: }
2447: }
2448:
2449: $body = $this->client->doGet('/rest/v4/users/{user-token}/venmo-accounts/{venmo-account-token}/status-transitions', array(
2450: 'user-token' => $userToken,
2451: 'venmo-account-token' => $venmoAccountToken
2452: ), $options);
2453: return new ListResponse($body, function ($entry) {
2454: return new VenmoAccountStatusTransition($entry);
2455: });
2456: }
2457: /**
2458: * Upload documents for Business Stakeholder endpoint
2459: *
2460: * @param string $userToken The user token
2461: * @param array $options The multipart object with the required documents and json data to get uploaded
2462: *
2463: * Sample multipart array to refer. Don't set the content-type explicitly
2464: * array(
2465: *'multipart' => [
2466: * [
2467: * 'name' => 'data',
2468: * 'contents' => '{"documents":[{"type":"DRIVERS_LICENSE","country":"US","category":"IDENTIFICATION"}]}'
2469: * ],
2470: * [
2471: * 'name' => 'drivers_license_front',
2472: * 'contents' => fopen('<path>/File1.png', "r")
2473: * ],
2474: * [
2475: * 'name' => 'drivers_license_back',
2476: * 'contents' => fopen('<path>>/File2.png', 'r')
2477: * ]
2478: * ]
2479: * ));
2480: *
2481: * @return BusinessStakeholder object with updated VerificationStatus and document details
2482: *
2483: *
2484: * @throws HyperwalletArgumentException
2485: * @throws HyperwalletApiException
2486: */
2487: public function uploadDocumentsForBusinessStakeholder($userToken, $businessToken, $options) {
2488: if (empty($userToken)) {
2489: throw new HyperwalletArgumentException('userToken is required!');
2490: }
2491: if (empty($businessToken)) {
2492: throw new HyperwalletArgumentException('businessToken is required!');
2493: }
2494: $body = $this->client->putMultipartData('/rest/v4/users/{user-token}/business-stakeholders/{business-token}', array('user-token' => $userToken,'business-token' => $businessToken), $options);
2495: $body = $this->setDocumentAndReasonFromResponseHelper($body);
2496: return new BusinessStakeholder($body);
2497: }
2498:
2499: /**
2500: * Create a Business Stakeholder
2501: *
2502: * @param string $userToken The user token
2503: * @param BusinessStakeholder $businessStakeholder The business stakeholder
2504: * @return BusinessStakeholder
2505: *
2506: * @throws HyperwalletArgumentException
2507: * @throws HyperwalletApiException
2508: */
2509: public function createBusinessStakeholder($userToken, $businessStakeholder) {
2510: if (empty($userToken)) {
2511: throw new HyperwalletArgumentException('userToken is required!');
2512: }
2513: $body = $this->client->doPost('/rest/v4/users/{user-token}/business-stakeholders', array('user-token' => $userToken), $businessStakeholder, array());
2514: return new BusinessStakeholder($body);
2515: }
2516:
2517: /**
2518: * Update a Business Stakeholder
2519: *
2520: * @return BusinessStakeholder
2521: *
2522: * @throws HyperwalletArgumentException
2523: * @throws HyperwalletApiException
2524: */
2525: public function updateBusinessStakeholder($userToken, $businessToken, $businessStakeholder) {
2526: if (empty($userToken)) {
2527: throw new HyperwalletArgumentException('userToken is required!');
2528: }
2529: if (empty($businessToken)) {
2530: throw new HyperwalletArgumentException('businessToken is required!');
2531: }
2532: $body = $this->client->doPut('/rest/v4/users/{user-token}/business-stakeholders/{business-token}', array('user-token' => $userToken,'business-token' => $businessToken), $businessStakeholder, array());
2533: return new BusinessStakeholder($body);
2534: }
2535:
2536: /**
2537: * List all Business Stakeholders
2538: *
2539: * @param array $options
2540: * @return ListResponse
2541: *
2542: * @throws HyperwalletApiException
2543: */
2544:
2545: public function listBusinessStakeholders($userToken , $options) {
2546: if (empty($userToken)) {
2547: throw new HyperwalletArgumentException('userToken is required!');
2548: }
2549: if (!empty($options)) {
2550: $filteredArr = array_diff_key($options, array_flip(BusinessStakeholder::FILTERS_ARRAY()));
2551: if (!empty($filteredArr)) {
2552: throw new HyperwalletArgumentException('Invalid filter');
2553: }
2554: }
2555: $body = $this->client->doGet('/rest/v4/users/{user-token}/business-stakeholders',array(
2556: 'user-token' => $userToken
2557: ), $options);
2558: return new ListResponse($body, function ($entry) {
2559: return new BusinessStakeholder($entry);
2560: });
2561: }
2562:
2563: /**
2564: * Create a Business Stakeholder status transition
2565: *
2566: * @param string $userToken The user token
2567: * @param string $businessToken The Business Token
2568: * @param BusinessStakeholderStatusTransition $transition The status transition
2569: * @return BusinessStakeholderStatusTransition
2570: *
2571: * @throws HyperwalletArgumentException
2572: * @throws HyperwalletApiException
2573: */
2574: public function createBusinessStakeholderStatusTransition($userToken, $businessToken, BusinessStakeholderStatusTransition $transition) {
2575: if (empty($userToken)) {
2576: throw new HyperwalletArgumentException('userToken is required!');
2577: }
2578: if (empty($businessToken)) {
2579: throw new HyperwalletArgumentException('businessToken is required!');
2580: }
2581:
2582: $body = $this->client->doPost('/rest/v4/users/{user-token}/business-stakeholders/{business-token}/status-transitions', array(
2583: 'user-token' => $userToken,
2584: 'business-token' => $businessToken
2585: ), $transition, array());
2586: return new BusinessStakeholderStatusTransition($body);
2587: }
2588:
2589: /**
2590: * activate a Business Stakeholder
2591: *
2592: * @param string $userToken The user token
2593: * @param string $businessToken The Business Token
2594: * @return BusinessStakeholderStatusTransition
2595: *
2596: * @throws HyperwalletArgumentException
2597: * @throws HyperwalletApiException
2598: */
2599: public function activateBusinessStakeholder($userToken, $businessToken) {
2600: $transition = new BusinessStakeholderStatusTransition();
2601: $transition->setTransition(BusinessStakeholderStatusTransition::TRANSITION_ACTIVATED);
2602:
2603: return $this->createBusinessStakeholderStatusTransition($userToken, $businessToken, $transition);
2604: }
2605:
2606: /**
2607: * Deactivate a Business Stakeholder
2608: *
2609: * @param string $userToken The user token
2610: * @param string $businessToken The Business Token
2611: * @return BusinessStakeholderStatusTransition
2612: *
2613: * @throws HyperwalletArgumentException
2614: * @throws HyperwalletApiException
2615: */
2616: public function deactivateBusinessStakeholder($userToken, $businessToken) {
2617: $transition = new BusinessStakeholderStatusTransition();
2618: $transition->setTransition(BusinessStakeholderStatusTransition::TRANSITION_DE_ACTIVATED);
2619:
2620: return $this->createBusinessStakeholderStatusTransition($userToken, $businessToken, $transition);
2621: }
2622:
2623: /**
2624: * Get a Business Stakeholder status transition
2625: *
2626: * @param string $userToken The user token
2627: * @param string $businessToken The Business Token
2628: * @param string $statusTransitionToken The status transition token
2629: * @return BusinessStakeholderStatusTransition
2630: *
2631: * @throws HyperwalletArgumentException
2632: * @throws HyperwalletApiException
2633: */
2634: public function getBusinessStakeholderStatusTransition($userToken, $businessToken, $statusTransitionToken) {
2635: if (empty($userToken)) {
2636: throw new HyperwalletArgumentException('userToken is required!');
2637: }
2638: if (empty($businessToken)) {
2639: throw new HyperwalletArgumentException('businessToken is required!');
2640: }
2641: if (empty($statusTransitionToken)) {
2642: throw new HyperwalletArgumentException('statusTransitionToken is required!');
2643: }
2644:
2645: $body = $this->client->doGet('/rest/v4/users/{user-token}/business-stakeholders/{business-token}/status-transitions/{status-transition-token}', array(
2646: 'user-token' => $userToken,
2647: 'business-token' => $businessToken,
2648: 'status-transition-token' => $statusTransitionToken
2649: ), array());
2650: return new BusinessStakeholderStatusTransition($body);
2651: }
2652:
2653: /**
2654: * List all Business Stakeholder status transitions
2655: *
2656: * @param string $userToken The user token
2657: * @param string $businessToken The Business Token
2658: * @param array $options The query parameters
2659: * @return ListResponse
2660: *
2661: * @throws HyperwalletArgumentException
2662: * @throws HyperwalletApiException
2663: */
2664: public function listBusinessStakeholderStatusTransitions($userToken, $businessToken, array $options = array()) {
2665: if (empty($userToken)) {
2666: throw new HyperwalletArgumentException('userToken is required!');
2667: }
2668: if (empty($businessToken)) {
2669: throw new HyperwalletArgumentException('businessToken is required!');
2670: }
2671: if (!empty($options)) {
2672: $filteredArr = array_diff_key($options, array_flip(StatusTransition::FILTERS_ARRAY()));
2673: if (!empty($filteredArr)) {
2674: throw new HyperwalletArgumentException('Invalid filter');
2675: }
2676: }
2677:
2678: $body = $this->client->doGet('/rest/v4/users/{user-token}/business-stakeholders/{business-token}/status-transitions', array(
2679: 'user-token' => $userToken,
2680: 'business-token' => $businessToken
2681: ), $options);
2682: return new ListResponse($body, function ($entry) {
2683: return new BusinessStakeholderStatusTransition($entry);
2684: });
2685: }
2686:
2687: /**
2688: * List all Transfer Methods
2689: *
2690: * @param string $userToken The user token
2691: * @param array $options The query parameters
2692: * @return ListResponse of HyperwalletTransferMethod
2693: */
2694:
2695: public function listTransferMethods($userToken, $options = array()) {
2696: if (empty($userToken)) {
2697: throw new HyperwalletArgumentException('userToken is required!');
2698: }
2699:
2700: $body = $this->client->doGet('/rest/v4/users/{user-token}/transfer-methods', array(
2701: 'user-token' => $userToken
2702: ), $options);
2703: return new ListResponse($body, function ($entry) {
2704: return new TransferMethod($entry);
2705: });
2706: }
2707: }
2708: