Skip to content

Commit

Permalink
Fix merge conflicts and add PSR-2 compliance #59
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Bailey committed Feb 10, 2016
1 parent 0838105 commit bbbcb2b
Show file tree
Hide file tree
Showing 83 changed files with 823 additions and 674 deletions.
15 changes: 9 additions & 6 deletions MangoPay/ApiCardPreAuthorizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* Class to management MangoPay API for pre-authorization process
*/
class ApiCardPreAuthorizations extends Libraries\ApiBase {

class ApiCardPreAuthorizations extends Libraries\ApiBase
{
/**
* Create new pre-authorization object
* @param \MangoPay\CardPreAuthorization $cardPreAuthorization PreAuthorization object to create
* @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API
*/
public function Create($cardPreAuthorization, $idempotencyKey = null) {
public function Create($cardPreAuthorization, $idempotencyKey = null)
{
return $this->CreateObject('preauthorization_create', $cardPreAuthorization, '\MangoPay\CardPreAuthorization', null, null, $idempotencyKey);
}

Expand All @@ -20,7 +21,8 @@ public function Create($cardPreAuthorization, $idempotencyKey = null) {
* @param int $cardPreAuthorizationId PreAuthorization identifier
* @return \MangoPay\CardPreAuthorization Card registration object returned from API
*/
public function Get($cardPreAuthorizationId) {
public function Get($cardPreAuthorizationId)
{
return $this->GetObject('preauthorization_get', $cardPreAuthorizationId, '\MangoPay\CardPreAuthorization');
}

Expand All @@ -29,7 +31,8 @@ public function Get($cardPreAuthorizationId) {
* @param \MangoPay\CardPreAuthorization $preAuthorization PreAuthorization object to save
* @return \MangoPay\CardPreAuthorization PreAuthorization object returned from API
*/
public function Update($cardPreAuthorization) {
public function Update($cardPreAuthorization)
{
return $this->SaveObject('preauthorization_save', $cardPreAuthorization, '\MangoPay\CardPreAuthorization');
}
}
}
15 changes: 9 additions & 6 deletions MangoPay/ApiCardRegistrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* Class to management MangoPay API for card registrations
*/
class ApiCardRegistrations extends Libraries\ApiBase {

class ApiCardRegistrations extends Libraries\ApiBase
{
/**
* Create new card registration
* @param \MangoPay\CardRegistration $cardRegistration Card registration object to create
* @return \MangoPay\CardRegistration Card registration object returned from API
*/
public function Create($cardRegistration, $idempotencyKey = null) {
public function Create($cardRegistration, $idempotencyKey = null)
{
return $this->CreateObject('cardregistration_create', $cardRegistration, '\MangoPay\CardRegistration', null, null, $idempotencyKey);
}

Expand All @@ -20,7 +21,8 @@ public function Create($cardRegistration, $idempotencyKey = null) {
* @param int $cardRegistrationId Card Registration identifier
* @return \MangoPay\CardRegistration Card registration object returned from API
*/
public function Get($cardRegistrationId) {
public function Get($cardRegistrationId)
{
return $this->GetObject('cardregistration_get', $cardRegistrationId, '\MangoPay\CardRegistration');
}

Expand All @@ -29,7 +31,8 @@ public function Get($cardRegistrationId) {
* @param \MangoPay\CardRegistration $cardRegistration Card registration object to save
* @return \MangoPay\CardRegistration Card registration object returned from API
*/
public function Update($cardRegistration) {
public function Update($cardRegistration)
{
return $this->SaveObject('cardregistration_save', $cardRegistration, '\MangoPay\CardRegistration');
}
}
}
22 changes: 13 additions & 9 deletions MangoPay/ApiCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* Class to management MangoPay API for cards
*/
class ApiCards extends Libraries\ApiBase {
class ApiCards extends Libraries\ApiBase
{
/**
* Get card
* @param int $cardId Card identifier
* @return \MangoPay\Card object returned from API
*/
public function Get($cardId) {
public function Get($cardId)
{
return $this->GetObject('card_get', $cardId, '\MangoPay\Card');
}

Expand All @@ -20,33 +21,36 @@ public function Get($cardId) {
* @param \MangoPay\Card $card Card object to save
* @return \MangoPay\Card Card object returned from API
*/
public function Update($card) {
public function Update($card)
{
return $this->SaveObject('card_save', $card, '\MangoPay\Card');
}

/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have any questions.
*
*
* Create new temporary payment card
* @param \MangoPay\TemporaryPaymentCard $paymentCard Payment card object to create
* @return \MangoPay\TemporaryPaymentCard Card registration object returned from API
*/
public function CreateTemporaryPaymentCard($paymentCard, $idempotencyKey = null) {
public function CreateTemporaryPaymentCard($paymentCard, $idempotencyKey = null)
{
return $this->CreateObject('temp_paymentcards_create', $paymentCard, '\MangoPay\TemporaryPaymentCard', null, null, $idempotencyKey);
}

/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have any questions.
*
*
* Get temporary payment card
* @param string $paymentCardId Card identifier
* @return \MangoPay\TemporaryPaymentCard object returned from API
*/
public function GetTemporaryPaymentCard($paymentCardId) {
public function GetTemporaryPaymentCard($paymentCardId)
{
return $this->GetObject('temp_paymentcards_get', $paymentCardId, '\MangoPay\TemporaryPaymentCard');
}
}
}
9 changes: 5 additions & 4 deletions MangoPay/ApiEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@
/**
* Class to management MangoPay API for cards
*/
class ApiEvents extends Libraries\ApiBase {
class ApiEvents extends Libraries\ApiBase
{
/**
* Get events
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\FilterEvents $filter Object to filter data
* @param \MangoPay\Sorting $sorting Object to sorting data
*
*
* @return \MangoPay\Event[] Events list
*/
public function GetAll(& $pagination = null, $filter = null, $sorting = null) {
public function GetAll(& $pagination = null, $filter = null, $sorting = null)
{
return $this->GetList('events_all', $pagination, '\MangoPay\Event', null, $filter, $sorting);
}
}
18 changes: 11 additions & 7 deletions MangoPay/ApiHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* Class to management MangoPay API for hooks and notifications
*/
class ApiHooks extends Libraries\ApiBase {
class ApiHooks extends Libraries\ApiBase
{
/**
* Create new hook
* @param Hook $hook
* @return \MangoPay\Hook Hook object returned from API
*/
public function Create($hook, $idempotencyKey = null) {
public function Create($hook, $idempotencyKey = null)
{
return $this->CreateObject('hooks_create', $hook, '\MangoPay\Hook', null, null, $idempotencyKey);
}

Expand All @@ -20,7 +21,8 @@ public function Create($hook, $idempotencyKey = null) {
* @param type $hookId Hook identifier
* @return \MangoPay\Hook Wallet object returned from API
*/
public function Get($hookId) {
public function Get($hookId)
{
return $this->GetObject('hooks_get', $hookId, '\MangoPay\Hook');
}

Expand All @@ -29,7 +31,8 @@ public function Get($hookId) {
* @param type $hook Hook object to save
* @return \MangoPay\Hook Hook object returned from API
*/
public function Update($hook) {
public function Update($hook)
{
return $this->SaveObject('hooks_save', $hook, '\MangoPay\Hook');
}

Expand All @@ -38,7 +41,8 @@ public function Update($hook) {
* @param \MangoPay\Pagination $pagination Pagination object
* @return \MangoPay\Hook[] Array with objects returned from API
*/
public function GetAll(& $pagination = null) {
public function GetAll(& $pagination = null)
{
return $this->GetList('hooks_all', $pagination, '\MangoPay\Hook');
}
}
}
12 changes: 7 additions & 5 deletions MangoPay/ApiKycDocuments.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
/**
* Class to management MangoPay API for KYC document list
*/
class ApiKycDocuments extends Libraries\ApiBase {
class ApiKycDocuments extends Libraries\ApiBase
{
/**
* Get all KYC documents
* @param \MangoPay\Pagination $pagination Pagination object
* @param \MangoPay\Sorting $sorting Object to sorting data
* @param \MangoPay\FilterKycDocuments $filter Object to filter data
* @return \MangoPay\KycDocument[] Array with objects returned from API
*/
public function GetAll(& $pagination = null, $sorting = null, $filter = null) {
public function GetAll(& $pagination = null, $sorting = null, $filter = null)
{
return $this->GetList('kyc_documents_all', $pagination, '\MangoPay\KycDocument', null, $filter, $sorting);
}

Expand All @@ -22,7 +23,8 @@ public function GetAll(& $pagination = null, $sorting = null, $filter = null) {
* @param string $kycDocumentId Document identifier
* @return \MangoPay\KycDocument Document returned from API
*/
public function Get($kycDocumentId) {
public function Get($kycDocumentId)
{
return $this->GetObject('kyc_documents_get_alt', $kycDocumentId, '\MangoPay\KycDocument');
}
}
}
38 changes: 22 additions & 16 deletions MangoPay/ApiPayIns.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* Class to management MangoPay API for pay-ins
*/
class ApiPayIns extends Libraries\ApiBase {
class ApiPayIns extends Libraries\ApiBase
{
/**
* Create new pay-in object
* @param \MangoPay\PayIn $payIn \MangoPay\PayIn object
* @return \MangoPay\PayIn Object returned from API
*/
public function Create($payIn, $idempotencyKey = null) {
public function Create($payIn, $idempotencyKey = null)
{
$paymentKey = $this->GetPaymentKey($payIn);
$executionKey = $this->GetExecutionKey($payIn);
return $this->CreateObject('payins_' . $paymentKey . '-' . $executionKey . '_create', $payIn, '\MangoPay\PayIn', null, null, $idempotencyKey);
Expand All @@ -22,7 +23,8 @@ public function Create($payIn, $idempotencyKey = null) {
* @param $payInId Pay-in identifier
* @return \MangoPay\PayIn Object returned from API
*/
public function Get($payInId) {
public function Get($payInId)
{
return $this->GetObject('payins_get', $payInId, '\MangoPay\PayIn');
}

Expand All @@ -32,38 +34,42 @@ public function Get($payInId) {
* @param \MangoPay\Refund $refund Refund object to create
* @return \MangoPay\Refund Object returned by REST API
*/
public function CreateRefund($payInId, $refund, $idempotencyKey = null) {
public function CreateRefund($payInId, $refund, $idempotencyKey = null)
{
return $this->CreateObject('payins_createrefunds', $refund, '\MangoPay\Refund', $payInId, null, $idempotencyKey);
}

/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have any questions.
*
*
* Create new temporary immediate pay-in
* @param \MangoPay\TemporaryImmediatePayIn $immediatePayIn Immediate pay-in object to create
* @return \MangoPay\TemporaryImmediatePayIn Immediate pay-in object returned from API
*/
public function CreateTemporaryImmediatePayIn($immediatePayIn, $idempotencyKey = null) {
public function CreateTemporaryImmediatePayIn($immediatePayIn, $idempotencyKey = null)
{
return $this->CreateObject('temp_immediatepayins_create', $immediatePayIn, '\MangoPay\TemporaryImmediatePayIn', null, null, $idempotencyKey);
}

private function GetPaymentKey($payIn) {

if (!isset($payIn->PaymentDetails) || !is_object($payIn->PaymentDetails))
throw new Libraries\Exception ('Payment is not defined or it is not object type');
private function GetPaymentKey($payIn)
{
if (!isset($payIn->PaymentDetails) || !is_object($payIn->PaymentDetails)) {
throw new Libraries\Exception('Payment is not defined or it is not object type');
}

$className = str_replace('MangoPay\\PayInPaymentDetails', '', get_class($payIn->PaymentDetails));
return strtolower($className);
}

private function GetExecutionKey($payIn) {

if (!isset($payIn->ExecutionDetails) || !is_object($payIn->ExecutionDetails))
throw new Libraries\Exception ('Execution is not defined or it is not object type');
private function GetExecutionKey($payIn)
{
if (!isset($payIn->ExecutionDetails) || !is_object($payIn->ExecutionDetails)) {
throw new Libraries\Exception('Execution is not defined or it is not object type');
}

$className = str_replace('MangoPay\\PayInExecutionDetails', '', get_class($payIn->ExecutionDetails));
return strtolower($className);
}
}
}
19 changes: 11 additions & 8 deletions MangoPay/ApiPayOuts.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
/**
* Class to management MangoPay API for pay-outs
*/
class ApiPayOuts extends Libraries\ApiBase {
class ApiPayOuts extends Libraries\ApiBase
{
/**
* Create new pay-out
* @param PayOut $payOut
* @return \MangoPay\PayOut Object returned from API
*/
public function Create($payOut, $idempotencyKey = null) {
public function Create($payOut, $idempotencyKey = null)
{
$paymentKey = $this->GetPaymentKey($payOut);
return $this->CreateObject('payouts_' . $paymentKey . '_create', $payOut, '\MangoPay\PayOut', null, null, $idempotencyKey);
}
Expand All @@ -21,16 +22,18 @@ public function Create($payOut, $idempotencyKey = null) {
* @param $payOutId PayOut identifier
* @return \MangoPay\PayOut Object returned from API
*/
public function Get($payOutId) {
public function Get($payOutId)
{
return $this->GetObject('payouts_get', $payOutId, '\MangoPay\PayOut');
}

private function GetPaymentKey($payOut) {
if (!isset($payOut->MeanOfPaymentDetails) || !is_object($payOut->MeanOfPaymentDetails))
private function GetPaymentKey($payOut)
{
if (!isset($payOut->MeanOfPaymentDetails) || !is_object($payOut->MeanOfPaymentDetails)) {
throw new Libraries\Exception('Mean of payment is not defined or it is not object type');
}

$className = str_replace('MangoPay\\PayOutPaymentDetails', '', get_class($payOut->MeanOfPaymentDetails));
return strtolower($className);
}
}
}
Loading

0 comments on commit bbbcb2b

Please sign in to comment.