PayPalCommonPayPalResourceModel

Class PayPalResourceModel An Executable PayPalModel Class.

Defined (1)

The class is defined in the following location(s).

/classes/lib/PayPal/Common/PayPalResourceModel.php  
  1. class PayPalResourceModel extends PayPalModel implements IResource 
  2.  
  3. /** 
  4. * Sets Links 
  5. * @param \PayPal\Api\Links[] $links 
  6. * @return $this 
  7. */ 
  8. public function setLinks($links) 
  9. $this->links = $links; 
  10. return $this; 
  11.  
  12. /** 
  13. * Gets Links 
  14. * @return \PayPal\Api\Links[] 
  15. */ 
  16. public function getLinks() 
  17. return $this->links; 
  18.  
  19. public function getLink($rel) 
  20. foreach ($this->links as $link) { 
  21. if ($link->getRel() == $rel) { 
  22. return $link->getHref(); 
  23. return null; 
  24.  
  25. /** 
  26. * Append Links to the list. 
  27. * @param \PayPal\Api\Links $links 
  28. * @return $this 
  29. */ 
  30. public function addLink($links) 
  31. if (!$this->getLinks()) { 
  32. return $this->setLinks(array($links)); 
  33. } else { 
  34. return $this->setLinks( 
  35. array_merge($this->getLinks(), array($links)) 
  36. ); 
  37.  
  38. /** 
  39. * Remove Links from the list. 
  40. * @param \PayPal\Api\Links $links 
  41. * @return $this 
  42. */ 
  43. public function removeLink($links) 
  44. return $this->setLinks( 
  45. array_diff($this->getLinks(), array($links)) 
  46. ); 
  47.  
  48.  
  49. /** 
  50. * Execute SDK Call to Paypal services 
  51. * @param string $url 
  52. * @param string $method 
  53. * @param string $payLoad 
  54. * @param array $headers 
  55. * @param ApiContext $apiContext 
  56. * @param PayPalRestCall $restCall 
  57. * @param array $handlers 
  58. * @return string json response of the object 
  59. */ 
  60. protected static function executeCall($url, $method, $payLoad, $headers = array(), $apiContext = null, $restCall = null, $handlers = array('PayPal\Handler\RestHandler')) 
  61. //Initialize the context and rest call object if not provided explicitly 
  62. $apiContext = $apiContext ? $apiContext : new ApiContext(self::$credential); 
  63. $restCall = $restCall ? $restCall : new PayPalRestCall($apiContext); 
  64.  
  65. //Make the execution call 
  66. $json = $restCall->execute($handlers, $url, $method, $payLoad, $headers); 
  67. return $json;