Skip to content

Commit

Permalink
Merge pull request #345 from Mangopay/340-users-emoney-multiperiod-su…
Browse files Browse the repository at this point in the history
…pport

Add support for users emoney multiperiod
  • Loading branch information
mickaelpois authored Sep 11, 2019
2 parents b4f2fed + c86023d commit 92bee03
Show file tree
Hide file tree
Showing 24 changed files with 297 additions and 269 deletions.
2 changes: 1 addition & 1 deletion MangoPay/ApiBankingAliases.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class ApiBankingAliases extends Libraries\ApiBase
*/
public function Get($bankingAliasId)
{
$response = $this->GetObject('banking_aliases_get', $bankingAliasId);
$response = $this->GetObject('banking_aliases_get', null, $bankingAliasId);
return $this->GetBankingAliasResponse($response);
}

Expand Down
2 changes: 1 addition & 1 deletion MangoPay/ApiCardPreAuthorizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function Create($cardPreAuthorization, $idempotencyKey = null)
*/
public function Get($cardPreAuthorizationId)
{
return $this->GetObject('preauthorization_get', $cardPreAuthorizationId, '\MangoPay\CardPreAuthorization');
return $this->GetObject('preauthorization_get', '\MangoPay\CardPreAuthorization', $cardPreAuthorizationId);
}

/**
Expand Down
7 changes: 4 additions & 3 deletions MangoPay/ApiCardRegistrations.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace MangoPay;

/**
Expand All @@ -15,17 +16,17 @@ public function Create($cardRegistration, $idempotencyKey = null)
{
return $this->CreateObject('cardregistration_create', $cardRegistration, '\MangoPay\CardRegistration', null, null, $idempotencyKey);
}

/**
* Get card registration
* @param string $cardRegistrationId Card Registration identifier
* @return \MangoPay\CardRegistration Card registration object returned from API
*/
public function Get($cardRegistrationId)
{
return $this->GetObject('cardregistration_get', $cardRegistrationId, '\MangoPay\CardRegistration');
return $this->GetObject('cardregistration_get', '\MangoPay\CardRegistration', $cardRegistrationId);
}

/**
* Update card registration
* @param \MangoPay\CardRegistration $cardRegistration Card registration object to save
Expand Down
2 changes: 1 addition & 1 deletion MangoPay/ApiCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class ApiCards extends Libraries\ApiBase
*/
public function Get($cardId)
{
return $this->GetObject('card_get', $cardId, '\MangoPay\Card');
return $this->GetObject('card_get', '\MangoPay\Card', $cardId);
}

/**
Expand Down
101 changes: 51 additions & 50 deletions MangoPay/ApiClients.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

namespace MangoPay;

/**
Expand All @@ -8,33 +9,33 @@ class ApiClients extends Libraries\ApiBase
{
/**
* Get client information
*
*
* @return \MangoPay\Client Client object returned from API
*/
public function Get()
{
return $this->GetObject('client_get', null, '\MangoPay\Client');
return $this->GetObject('client_get', '\MangoPay\Client');
}

/**
* Save client
* @param Client $client Client object to save
* @return \MangoPay\Client Client object returned from API
*/
public function Update($client)
{
if (!is_null($client->HeadquartersAddress)
if (!is_null($client->HeadquartersAddress)
&& is_a($client->HeadquartersAddress, "MangoPay\Address")
&& $client->HeadquartersAddress->CanBeNull()) {
$client->HeadquartersAddress = null;
$client->HeadquartersAddress = null;
}

return $this->SaveObject('client_save', $client, '\MangoPay\Client');
}

/**
* Upload a logo for client.
* Only GIF, PNG, JPG, JPEG, BMP, PDF and DOC formats are accepted,
* Only GIF, PNG, JPG, JPEG, BMP, PDF and DOC formats are accepted,
* and file must be less than about 7MB
* @param \MangoPay\ClientLogoUpload $logo ClientLogoUpload object
*/
Expand All @@ -48,10 +49,10 @@ public function UploadLogo($logoUpload, $idempotencyKey = null)
}
}
}

/**
* Upload a logo for client from file.
* Only GIF, PNG, JPG, JPEG, BMP, PDF and DOC formats are accepted,
* Only GIF, PNG, JPG, JPEG, BMP, PDF and DOC formats are accepted,
* and file must be less than about 7MB
* @param string $file Path of file with logo
* @throws \MangoPay\Libraries\Exception
Expand All @@ -62,109 +63,109 @@ public function UploadLogoFromFile($file, $idempotencyKey = null)
if (is_array($file)) {
$filePath = $file['tmp_name'];
}

if (empty($filePath)) {
throw new \MangoPay\Libraries\Exception('Path of file cannot be empty');
}

if (!file_exists($filePath)) {
throw new \MangoPay\Libraries\Exception('File not exist');
}

$logoUpload = new \MangoPay\ClientLogoUpload();
$logoUpload->File = base64_encode(file_get_contents($filePath));

if (empty($logoUpload->File)) {
throw new \MangoPay\Libraries\Exception('Content of the file cannot be empty');
}

$this->UploadLogo($logoUpload, $idempotencyKey);
}

/**
* View your client wallets. To see your fees or credit wallets
* View your client wallets. To see your fees or credit wallets
* for each currency set second $fundsType parameter.
*
*
* @param \MangoPay\FundsType $fundsType FundsType enum
* @param \MangoPay\Sorting $sorting Sorting object
*
*
* @return \MangoPay\Wallet[] List with your client wallets
*/
public function GetWallets($fundsType = null, $sorting = null)
{
$pagination = new \MangoPay\Pagination();

if (is_null($fundsType)){
if (is_null($fundsType)) {
return $this->GetList('client_wallets', $pagination, '\MangoPay\Wallet', null, null, $sorting);
} else if ($fundsType == FundsType::FEES){
} else if ($fundsType == FundsType::FEES) {
return $this->GetList('client_wallets_fees', $pagination, '\MangoPay\Wallet', null, null, $sorting);
} else if ($fundsType == FundsType::CREDIT){
} else if ($fundsType == FundsType::CREDIT) {
return $this->GetList('client_wallets_credit', $pagination, '\MangoPay\Wallet', null, null, $sorting);
}
throw new \MangoPay\Libraries\Exception('\MangoPay\FundsType object has wrong value and cannot get wallets');

throw new \MangoPay\Libraries\Exception('\MangoPay\FundsType object has wrong value and cannot get wallets');
}

/**
* View one of your client wallets (fees or credit) with a particular currency.
*
*
* @param \MangoPay\FundsType $fundsType FundsType enum
* @param \MangoPay\CurrencyIso $currencyIso CurrencyIso enum
*
* @return \MangoPay\Wallet Wallet (fees or credit) with a particular currency
*/
public function GetWallet($fundsType, $currencyIso)
{
if (is_null($fundsType)){
{
if (is_null($fundsType)) {
throw new \MangoPay\Libraries\Exception(
'First parameter in function GetWallet in class ApiClients is required.');
'First parameter in function GetWallet in class ApiClients is required.');
}
if (is_null($currencyIso)){

if (is_null($currencyIso)) {
throw new \MangoPay\Libraries\Exception(
'Second parameter in function GetWallet in class ApiClients is required.');
'Second parameter in function GetWallet in class ApiClients is required.');
}

$methodKey = null;
if ($fundsType == FundsType::FEES){
if ($fundsType == FundsType::FEES) {
$methodKey = 'client_wallets_fees_currency';
} else if ($fundsType == FundsType::CREDIT){
} else if ($fundsType == FundsType::CREDIT) {
$methodKey = 'client_wallets_credit_currency';
} else {
throw new \MangoPay\Libraries\Exception('\MangoPay\FundsType object has wrong value and cannot get wallets');
throw new \MangoPay\Libraries\Exception('\MangoPay\FundsType object has wrong value and cannot get wallets');
}
return $this->GetObject($methodKey, $currencyIso, '\MangoPay\Wallet');

return $this->GetObject($methodKey, '\MangoPay\Wallet', $currencyIso);
}

/**
* View the transactions linked to your client wallets (fees and credit)
*
*
* @param \MangoPay\FundsType $fundsType FundsType enum
* @param \MangoPay\CurrencyIso $currencyIso CurrencyIso enum
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\FilterTransactions $filter Object to filter data
*
*
* @return \MangoPay\Transaction[] Transactions linked to your client wallets (fees and credit)
*/
public function GetWalletTransactions($fundsType = null, $currencyIso = null, & $pagination = null, $filter = null)
{
if (is_null($fundsType)){
if (is_null($fundsType)) {
$methodKey = 'client_wallets_transactions';
} else if ($fundsType == FundsType::FEES){
} else if ($fundsType == FundsType::FEES) {
$methodKey = 'client_wallets_transactions_fees_currency';
} else if ($fundsType == FundsType::CREDIT){
} else if ($fundsType == FundsType::CREDIT) {
$methodKey = 'client_wallets_transactions_credit_currency';
} else {
throw new \MangoPay\Libraries\Exception(
'\MangoPay\FundsType object has wrong value.');
'\MangoPay\FundsType object has wrong value.');
}
if (!is_null($fundsType) && is_null($currencyIso)){
throw new \MangoPay\Libraries\Exception(
'If FundsType is defined the second parameter (currency) is required.');

if (!is_null($fundsType) && is_null($currencyIso)) {
throw new \MangoPay\Libraries\Exception(
'If FundsType is defined the second parameter (currency) is required.');
}

return $this->GetList($methodKey, $pagination, '\MangoPay\Transaction', $currencyIso, $filter, null);
}
}
4 changes: 3 additions & 1 deletion MangoPay/ApiDisputeDocuments.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
<?php

namespace MangoPay;

/**
* Class to management MangoPay API for dispute documents
*/

/**
* Class ApiDisputeDocuments
* @package MangoPay
Expand All @@ -17,7 +19,7 @@ class ApiDisputeDocuments extends Libraries\ApiBase
*/
public function Get($documentId)
{
return $this->GetObject('disputes_document_get', $documentId, 'MangoPay\DisputeDocument');
return $this->GetObject('disputes_document_get', 'MangoPay\DisputeDocument', $documentId);
}

/**
Expand Down
Loading

0 comments on commit 92bee03

Please sign in to comment.