Skip to content

Commit

Permalink
Merge pull request #217 from Mangopay/feature/MPSDK-199-get-transacti…
Browse files Browse the repository at this point in the history
…ons-for-mandate

Implemented support for Get Transactions of a Mandate endpoint.
  • Loading branch information
mickaelpois authored Dec 26, 2017
2 parents a278658 + c03faf8 commit 120e408
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
12 changes: 12 additions & 0 deletions MangoPay/ApiMandates.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,16 @@ public function GetAll(& $pagination = null, $filter = null, $sorting = null)
{
return $this->GetList('mandates_all', $pagination, 'MangoPay\Mandate', null, $filter, $sorting);
}

/**
* Retrieves list of Transactions pertaining to a certain Mandate
* @param string $mandateId Mandate identifier
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\FilterTransactions $filter Filtering object
* @param \MangoPay\Sorting $sorting Sorting object
*/
public function GetTransactions($mandateId, & $pagination = null, $filter = null, $sorting = null)
{
return $this->GetList('transactions_get_for_mandate', $pagination, '\MangoPay\Transaction', $mandateId, $filter, $sorting);
}
}
2 changes: 2 additions & 0 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ protected function getLogger()
'ubo_declaration_update' => array( '/ubodeclarations/%s', RequestType::PUT ),
'ubo_declaration_get' => array( '/ubodeclarations/%s', RequestType::GET ),

'transactions_get_for_mandate' => array( '/mandates/%s/transactions', RequestType::GET ),
'transactions_get_for_card' => array( '/cards/%s/transactions', RequestType::GET ),
'transactions_get_for_bank_account' => array( '/bankaccounts/%s/transactions', RequestType::GET )

);

/**
Expand Down
11 changes: 11 additions & 0 deletions tests/cases/mandates.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,15 @@ function test_Mandates_GetAll() {

$this->assertTrue(count($mandates) > 0);
}

function test_Mandate_GetTransactions() {
$mandate = $this->getJohnsMandate();
$pagination = new \MangoPay\Pagination();
$filter = new \MangoPay\FilterTransactions();

$transactions = $this->_api->Mandates->GetTransactions($mandate->Id, $pagination, $filter);

$this->assertNotNull($transactions);
$this->assertIsA($transactions, 'array');
}
}

0 comments on commit 120e408

Please sign in to comment.