Enabled EC Parameters support

- Updated Api to enabled EC Parameters
- Updated Tests
- Updated Logging Manager
- Added a feature to do validation on accessors.
This commit is contained in:
japatel
2014-10-09 11:30:12 -05:00
parent 459293838e
commit 61a52e4623
99 changed files with 9148 additions and 3609 deletions

View File

@@ -7,32 +7,42 @@ use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Api\Capture;
use PayPal\Transport\PPRestCall;
use PayPal\Validation\ArgumentValidator;
/**
* Class Authorization
*
* @property string id
* @property string create_time
* @property string update_time
* An authorization transaction.
*
* @package PayPal\Api
*
* @property string id
* @property string create_time
* @property string update_time
* @property \PayPal\Api\Amount amount
* @property string state
* @property string parent_payment
* @property string valid_until
* @property \PayPal\Api\Links links
* @property string payment_mode
* @property string state
* @property string protection_eligibility
* @property string protection_eligibility_type
* @property string parent_payment
* @property string clearing_time
* @property string valid_until
* @property \PayPal\Api\Links links
*/
class Authorization extends PPModel implements IResource
{
/**
* @var
* OAuth Credentials to use for this call
*
* @var \PayPal\Auth\OAuthTokenCredential $credential
*/
private static $credential;
protected static $credential;
/**
* Set Credential
*
* @param $credential
* Sets Credential
*
* @deprecated Pass ApiContext to create/get methods instead
* @param \PayPal\Auth\OAuthTokenCredential $credential
*/
public static function setCredential($credential)
{
@@ -40,23 +50,21 @@ class Authorization extends PPModel implements IResource
}
/**
* Set ID
* Identifier of the authorization transaction
* Identifier of the authorization transaction.
*
*
* @param string $id
*
*
* @return $this
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* Get ID
* Identifier of the authorization transaction
* Identifier of the authorization transaction.
*
* @return string
*/
@@ -66,23 +74,21 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Create Time
* Time the resource was created
* Time the resource was created in UTC ISO8601 format.
*
*
* @param string $create_time
*
*
* @return $this
*/
public function setCreateTime($create_time)
{
$this->create_time = $create_time;
return $this;
}
/**
* Get Create Time
* Time the resource was created
* Time the resource was created in UTC ISO8601 format.
*
* @return string
*/
@@ -92,27 +98,22 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Create Time
* Time the resource was created
* Time the resource was created in UTC ISO8601 format.
*
* @deprecated Instead use setCreateTime
*
* @param string $create_time
*
* @deprecated Use setCreateTime
*
* @return $this
*/
public function setCreate_time($create_time)
{
$this->create_time = $create_time;
return $this;
}
/**
* Get Create Time
* Time the resource was created
*
* @deprecated Use getCreateTime
* Time the resource was created in UTC ISO8601 format.
* @deprecated Instead use getCreateTime
*
* @return string
*/
@@ -122,23 +123,21 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Update Time
* Time the resource was last updated
* Time the resource was last updated in UTC ISO8601 format.
*
*
* @param string $update_time
*
*
* @return $this
*/
public function setUpdateTime($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Get Update Time
* Time the resource was last updated
* Time the resource was last updated in UTC ISO8601 format.
*
* @return string
*/
@@ -148,27 +147,22 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Update Time
* Time the resource was last updated
* Time the resource was last updated in UTC ISO8601 format.
*
* @deprecated Instead use setUpdateTime
*
* @param string $update_time
*
* @deprecated Use setUpdateTime
*
* @return $this
*/
public function setUpdate_time($update_time)
{
$this->update_time = $update_time;
return $this;
}
/**
* Get Update Time
* Time the resource was last updated
*
* @deprecated Use getUpdateTime
* Time the resource was last updated in UTC ISO8601 format.
* @deprecated Instead use getUpdateTime
*
* @return string
*/
@@ -178,21 +172,21 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Amount
* Amount being authorized for.
*
*
* @param \PayPal\Api\Amount $amount
*
*
* @return $this
*/
public function setAmount($amount)
{
$this->amount = $amount;
return $this;
}
/**
* Get Amount
* Amount being authorized for.
*
* @return \PayPal\Api\Amount
*/
@@ -202,23 +196,70 @@ class Authorization extends PPModel implements IResource
}
/**
* Set State
* State of the authorization transaction
* specifies payment mode of the transaction
* Valid Values: ["INSTANT_TRANSFER", "MANUAL_BANK_TRANSFER", "DELAYED_TRANSFER", "ECHECK"]
*
* @param string $payment_mode
*
* @return $this
*/
public function setPaymentMode($payment_mode)
{
$this->payment_mode = $payment_mode;
return $this;
}
/**
* specifies payment mode of the transaction
*
* @return string
*/
public function getPaymentMode()
{
return $this->payment_mode;
}
/**
* specifies payment mode of the transaction
*
* @deprecated Instead use setPaymentMode
*
* @param string $payment_mode
* @return $this
*/
public function setPayment_mode($payment_mode)
{
$this->payment_mode = $payment_mode;
return $this;
}
/**
* specifies payment mode of the transaction
* @deprecated Instead use getPaymentMode
*
* @return string
*/
public function getPayment_mode()
{
return $this->payment_mode;
}
/**
* State of the authorization transaction.
* Valid Values: ["pending", "authorized", "partially_captured", "captured", "expired", "voided"]
*
* @param string $state
*
*
* @return $this
*/
public function setState($state)
{
$this->state = $state;
return $this;
}
/**
* Get State
* State of the authorization transaction
* State of the authorization transaction.
*
* @return string
*/
@@ -228,23 +269,119 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Parent Payment
* ID of the Payment resource that this transaction is based on
* Protection Eligibility of the Payer
* Valid Values: ["ELIGIBLE", "PARTIALLY_ELIGIBLE", "INELIGIBLE"]
*
* @param string $protection_eligibility
*
* @return $this
*/
public function setProtectionEligibility($protection_eligibility)
{
$this->protection_eligibility = $protection_eligibility;
return $this;
}
/**
* Protection Eligibility of the Payer
*
* @return string
*/
public function getProtectionEligibility()
{
return $this->protection_eligibility;
}
/**
* Protection Eligibility of the Payer
*
* @deprecated Instead use setProtectionEligibility
*
* @param string $protection_eligibility
* @return $this
*/
public function setProtection_eligibility($protection_eligibility)
{
$this->protection_eligibility = $protection_eligibility;
return $this;
}
/**
* Protection Eligibility of the Payer
* @deprecated Instead use getProtectionEligibility
*
* @return string
*/
public function getProtection_eligibility()
{
return $this->protection_eligibility;
}
/**
* Protection Eligibility Type of the Payer
* Valid Values: ["ELIGIBLE", "ITEM_NOT_RECEIVED_ELIGIBLE", "INELIGIBLE", "UNAUTHORIZED_PAYMENT_ELIGIBLE"]
*
* @param string $protection_eligibility_type
*
* @return $this
*/
public function setProtectionEligibilityType($protection_eligibility_type)
{
$this->protection_eligibility_type = $protection_eligibility_type;
return $this;
}
/**
* Protection Eligibility Type of the Payer
*
* @return string
*/
public function getProtectionEligibilityType()
{
return $this->protection_eligibility_type;
}
/**
* Protection Eligibility Type of the Payer
*
* @deprecated Instead use setProtectionEligibilityType
*
* @param string $protection_eligibility_type
* @return $this
*/
public function setProtection_eligibility_type($protection_eligibility_type)
{
$this->protection_eligibility_type = $protection_eligibility_type;
return $this;
}
/**
* Protection Eligibility Type of the Payer
* @deprecated Instead use getProtectionEligibilityType
*
* @return string
*/
public function getProtection_eligibility_type()
{
return $this->protection_eligibility_type;
}
/**
* ID of the Payment resource that this transaction is based on.
*
*
* @param string $parent_payment
*
*
* @return $this
*/
public function setParentPayment($parent_payment)
{
$this->parent_payment = $parent_payment;
return $this;
}
/**
* Get Parent Payment
* ID of the Payment resource that this transaction is based on
* ID of the Payment resource that this transaction is based on.
*
* @return string
*/
@@ -254,27 +391,22 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Parent Payment
* ID of the Payment resource that this transaction is based on
* ID of the Payment resource that this transaction is based on.
*
* @deprecated Instead use setParentPayment
*
* @param string $parent_payment
*
* @deprecated Use setParentPayment
*
* @return $this
*/
public function setParent_payment($parent_payment)
{
$this->parent_payment = $parent_payment;
return $this;
}
/**
* Get Parent Payment
* ID of the Payment resource that this transaction is based on
*
* @deprecated Use getParentPayment
* ID of the Payment resource that this transaction is based on.
* @deprecated Instead use getParentPayment
*
* @return string
*/
@@ -284,23 +416,70 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Valid Until
* Date/Time until which funds may be captured against this resource
* Expected clearing time for eCheck Transactions
*
*
* @param string $clearing_time
*
* @return $this
*/
public function setClearingTime($clearing_time)
{
$this->clearing_time = $clearing_time;
return $this;
}
/**
* Expected clearing time for eCheck Transactions
*
* @return string
*/
public function getClearingTime()
{
return $this->clearing_time;
}
/**
* Expected clearing time for eCheck Transactions
*
* @deprecated Instead use setClearingTime
*
* @param string $clearing_time
* @return $this
*/
public function setClearing_time($clearing_time)
{
$this->clearing_time = $clearing_time;
return $this;
}
/**
* Expected clearing time for eCheck Transactions
* @deprecated Instead use getClearingTime
*
* @return string
*/
public function getClearing_time()
{
return $this->clearing_time;
}
/**
* Date/Time until which funds may be captured against this resource.
*
*
* @param string $valid_until
*
*
* @return $this
*/
public function setValidUntil($valid_until)
{
$this->valid_until = $valid_until;
return $this;
}
/**
* Get Valid Until
* Date/Time until which funds may be captured against this resource
* Date/Time until which funds may be captured against this resource.
*
* @return string
*/
@@ -310,27 +489,22 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Valid Until
* Date/Time until which funds may be captured against this resource
* Date/Time until which funds may be captured against this resource.
*
* @deprecated Instead use setValidUntil
*
* @param string $valid_until
*
* @deprecated Use setValidUntil
*
* @return $this
*/
public function setValid_until($valid_until)
{
$this->valid_until = $valid_until;
return $this;
}
/**
* Get Valid Until
* Date/Time until which funds may be captured against this resource
*
* @deprecated Use getValidUntil
* Date/Time until which funds may be captured against this resource.
* @deprecated Instead use getValidUntil
*
* @return string
*/
@@ -340,23 +514,23 @@ class Authorization extends PPModel implements IResource
}
/**
* Set Links
* Sets Links
*
*
* @param \PayPal\Api\Links $links
*
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Get Links
* Gets Links
*
* @return \PayPal\Api\Links
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
@@ -364,122 +538,88 @@ class Authorization extends PPModel implements IResource
}
/**
* Get
*
* @param int $authorizationId
* @param \PayPal\Rest\ApiContext|null $apiContext
* Obtain the Authorization transaction resource for the given identifier.
*
* @param string $authorizationId
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @return Authorization
* @throws \InvalidArgumentException
*/
public static function get($authorizationId, $apiContext = null)
{
if (($authorizationId == null) || (strlen($authorizationId) <= 0)) {
throw new \InvalidArgumentException("authorizationId cannot be null or empty");
}
ArgumentValidator::validate($authorizationId, 'authorizationId');
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/$authorizationId", "GET", $payLoad);
$ret = new Authorization();
$ret->fromJson($json);
return $ret;
}
/**
* Capture
*
* @param \Paypal\Api\Capture $capture
* @param \PayPal\Rest\ApiContext|null $apiContext
* Creates (and processes) a new Capture Transaction added as a related resource.
*
* @param Capture $capture
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @return Capture
* @throws \InvalidArgumentException
*/
public function capture($capture, $apiContext = null)
{
if ($this->getId() == null) {
throw new \InvalidArgumentException("Id cannot be null");
}
if (($capture == null)) {
throw new \InvalidArgumentException("capture cannot be null or empty");
}
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($capture, 'capture');
$payLoad = $capture->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/capture", "POST", $payLoad);
$ret = new Capture();
$ret->fromJson($json);
return $ret;
}
/**
* Void
*
* @param \PayPal\Rest\ApiContext|null $apiContext
* Voids (cancels) an Authorization.
*
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @return Authorization
* @throws \InvalidArgumentException
*/
public function void($apiContext = null)
{
if ($this->getId() == null) {
throw new \InvalidArgumentException("Id cannot be null");
}
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = "";
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/void", "POST", $payLoad);
$ret = new Authorization();
$ret->fromJson($json);
return $ret;
$this->fromJson($json);
return $this;
}
/**
* Reauthorize
* Reauthorizes an expired Authorization.
*
* @param \PayPal\Rest\ApiContext|null $apiContext
*
* @return $this
* @throws \InvalidArgumentException
* @param \PayPal\Rest\ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @return Authorization
*/
public function reauthorize($apiContext = null)
{
if ($this->getId() == null) {
throw new \InvalidArgumentException("Id cannot be null");
}
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = $this->toJSON();
if ($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new PPRestCall($apiContext);
$json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/payments/authorization/{$this->getId()}/reauthorize", "POST", $payLoad);
$this->fromJson($json);
return $this;
}
}