Updating stubs and samples to use apiContext

This commit is contained in:
aydiv
2013-04-26 12:00:20 +05:30
parent c624834f15
commit b3423b6c11
28 changed files with 931 additions and 1040 deletions

View File

@@ -237,8 +237,8 @@ class CreditCard extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/vault/credit-card",
"POST", $payLoad);
$this->fromJson($json);
@@ -259,8 +259,8 @@ class CreditCard extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/vault/credit-card/$creditcardid",
"GET", $payLoad);
$ret = new CreditCard();

View File

@@ -185,8 +185,8 @@ class Payment extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/payments/payment?" . http_build_query(array_intersect_key($params, $allowedParams)),
"GET", $payLoad);
$ret = new PaymentHistory();
@@ -206,8 +206,8 @@ class Payment extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/payments/payment",
"POST", $payLoad);
$this->fromJson($json);
@@ -228,8 +228,8 @@ class Payment extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/payments/payment/$paymentid",
"GET", $payLoad);
$ret = new Payment();
@@ -255,8 +255,8 @@ class Payment extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/payments/payment/{$this->getId()}/execute",
"POST", $payLoad);
$this->fromJson($json);

View File

@@ -192,8 +192,8 @@ class Refund extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/payments/refund/$refundid",
"GET", $payLoad);
$ret = new Refund();

View File

@@ -144,8 +144,8 @@ class Sale extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/payments/sale/$saleid",
"GET", $payLoad);
$ret = new Sale();
@@ -171,8 +171,8 @@ class Sale extends Resource implements IResource {
if($apiContext == null) {
$apiContext = new ApiContext(self::$credential);
}
$call = new \PPRestCall();
$json = $call->execute($apiContext, array('PayPal\Rest\RestHandler'),
$call = new \PPRestCall($apiContext);
$json = $call->execute( array('PayPal\Rest\RestHandler'),
"/v1/payments/sale/{$this->getId()}/refund",
"POST", $payLoad);
$this->fromJson($json);

View File

@@ -49,14 +49,15 @@ class OAuthTokenCredential {
*/
public function __construct($clientId, $clientSecret) {
$this->clientId = $clientId;
$this->clientSecret = $clientSecret;
$this->logger = new \PPLoggingManager(__CLASS__);
$this->clientSecret = $clientSecret;
}
/**
* @return the accessToken
*/
public function getAccessToken($config) {
public function getAccessToken($config) {
$this->logger = new \PPLoggingManager(__CLASS__, $config);
// Check if Access Token is not null and has not expired.
// The API returns expiry time as a relative time unit
// We use a buffer time when checking for token expiry to account