Helper Function to Retrieve Specific Link from Model Object

- Helper Methods in Payment and Agreement to get ApprovalLink
- Fixes #195
This commit is contained in:
japatel
2014-12-18 15:41:11 -06:00
parent d5450c64aa
commit f090642fae
12 changed files with 89 additions and 387 deletions

View File

@@ -11,6 +11,7 @@ use PayPal\Transport\PayPalRestCall;
* Class PayPalResourceModel
* An Executable PayPalModel Class
*
* @property \PayPal\Api\Links[] links
* @package PayPal\Common
*/
class PayPalResourceModel extends PayPalModel implements IResource
@@ -34,6 +35,69 @@ class PayPalResourceModel extends PayPalModel implements IResource
self::$credential = $credential;
}
/**
* Sets Links
*
* @param \PayPal\Api\Links[] $links
*
* @return $this
*/
public function setLinks($links)
{
$this->links = $links;
return $this;
}
/**
* Gets Links
*
* @return \PayPal\Api\Links[]
*/
public function getLinks()
{
return $this->links;
}
public function getLink($rel)
{
foreach ($this->links as $link) {
if ($link->getRel() == $rel) {
return $link->getHref();
}
}
return null;
}
/**
* Append Links to the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function addLink($links)
{
if (!$this->getLinks()) {
return $this->setLinks(array($links));
} else {
return $this->setLinks(
array_merge($this->getLinks(), array($links))
);
}
}
/**
* Remove Links from the list.
*
* @param \PayPal\Api\Links $links
* @return $this
*/
public function removeLink($links)
{
return $this->setLinks(
array_diff($this->getLinks(), array($links))
);
}
/**
* Execute SDK Call to Paypal services