Updated Identity Support from SDK Core

- Moved PPModels required for Identity Support
This commit is contained in:
japatel
2014-10-14 14:15:41 -05:00
parent 0cb302326a
commit dc2ac0fd63
36 changed files with 2652 additions and 587 deletions

View File

@@ -158,7 +158,7 @@ class PPModel
/** @var self $o */
$o = new $clazz();
$o->fromArray($v);
$this->setValue($k, $o);
$this->assignValue($k, $o);
} else {
$arr = array();
foreach ($v as $nk => $nv) {
@@ -170,7 +170,7 @@ class PPModel
$arr[$nk] = $nv;
}
}
$this->setValue($k, $arr);
$this->assignValue($k, $arr);
}
} else {
$this->$k = $v;
@@ -179,7 +179,7 @@ class PPModel
return $this;
}
private function setValue($key, $value)
private function assignValue($key, $value)
{
if (ModelAccessorValidator::validate($this, $this->convertToCamelCase($key))) {
$setter = "set" . $this->convertToCamelCase($key);

View File

@@ -0,0 +1,60 @@
<?php
namespace PayPal\Common;
use PayPal\Handler\IPPHandler;
use PayPal\Rest\ApiContext;
use PayPal\Rest\IResource;
use PayPal\Transport\PPRestCall;
/**
* Class ResourceModel
* An Executable PPModel Class
*
* @package PayPal\Common
*/
class ResourceModel extends PPModel implements IResource
{
/**
* OAuth Credentials to use for this call
*
* @var \PayPal\Auth\OAuthTokenCredential $credential
*/
protected static $credential;
/**
* Sets Credential
*
* @deprecated Pass ApiContext to create/get methods instead
* @param \PayPal\Auth\OAuthTokenCredential $credential
*/
public static function setCredential($credential)
{
self::$credential = $credential;
}
/**
* Execute SDK Call to Paypal services
*
* @param string $url
* @param string $method
* @param string $payLoad
* @param array $headers
* @param ApiContext $apiContext
* @param PPRestCall $restCall
* @param array $handlers
* @return string json response of the object
*/
protected static function executeCall($url, $method, $payLoad, $headers = array(), $apiContext = null, $restCall = null, $handlers = array('PayPal\Rest\RestHandler'))
{
//Initialize the context and rest call object if not provided explicitly
$apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential);
$restCall = $restCall ? $restCall : new PPRestCall($apiContext);
//Make the execution call
$json = $restCall->execute($handlers, $url, $method, $payLoad, $headers);
return $json;
}
}