Skip to content

Commit f944c63

Browse files
author
Iulian Masar
committed
added FilterRecipients.php and updated tests
1 parent 25ae74c commit f944c63

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

MangoPay/ApiRecipients.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,13 @@ public function Get($recipientId)
3535
* Get all recipients associated with a specific user
3636
* @param string $userId
3737
* @param Pagination $pagination
38+
* @param FilterRecipients $filter
3839
* @return Recipient[] Array of Recipient
3940
* @throws Exception
4041
*/
41-
public function GetUserRecipients($userId, $pagination = null, $sorting = null)
42+
public function GetUserRecipients($userId, $pagination = null, $sorting = null, $filter = null)
4243
{
43-
return $this->GetList('recipients_get_all', $pagination, '\MangoPay\Recipient', $userId, null, $sorting);
44+
return $this->GetList('recipients_get_all', $pagination, '\MangoPay\Recipient', $userId, $filter, $sorting);
4445
}
4546

4647
/**

MangoPay/FilterRecipients.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?php
2+
3+
namespace MangoPay;
4+
5+
/**
6+
* Filtering object for Recipients
7+
*/
8+
class FilterRecipients extends Libraries\Dto
9+
{
10+
/**
11+
* @var string
12+
*/
13+
public $RecipientScope;
14+
}

tests/Cases/RecipientsTest.php

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

55
use Exception;
66
use MangoPay\CurrencyIso;
7+
use MangoPay\FilterRecipients;
78
use MangoPay\IndividualRecipient;
89
use MangoPay\Recipient;
910
use MangoPay\Tests\Cases\Base;
@@ -39,6 +40,26 @@ public function test_Recipient_GetUserRecipients()
3940
self::assertTrue(sizeof($userRecipients) > 0);
4041
}
4142

43+
public function test_Recipient_GetUserRecipients_Payout()
44+
{
45+
$john = $this->getJohnSca(UserCategory::Owner, false);
46+
$this->getNewRecipient();
47+
$filter = new FilterRecipients();
48+
$filter->RecipientScope = "PAYOUT";
49+
$userRecipients = $this->_api->Recipients->GetUserRecipients($john->Id, null, null, $filter);
50+
self::assertTrue(sizeof($userRecipients) > 0);
51+
}
52+
53+
public function test_Recipient_GetUserRecipients_PayIn()
54+
{
55+
$john = $this->getJohnSca(UserCategory::Owner, false);
56+
$this->getNewRecipient();
57+
$filter = new FilterRecipients();
58+
$filter->RecipientScope = "PAYIN";
59+
$userRecipients = $this->_api->Recipients->GetUserRecipients($john->Id, null, null, $filter);
60+
self::assertTrue(sizeof($userRecipients) == 0);
61+
}
62+
4263
public function test_Recipient_GetPayoutMethods()
4364
{
4465
$payoutMethods = $this->_api->Recipients->GetPayoutMethods("DE", "EUR");

0 commit comments

Comments
 (0)