Add samples for Invoice Template API

This commit is contained in:
Jay Patel
2016-09-19 16:22:06 -05:00
parent 4f20bc4b97
commit f0feddc8f2
8 changed files with 336 additions and 117 deletions

View File

@@ -3,6 +3,7 @@
namespace PayPal\Api;
use PayPal\Common\PayPalResourceModel;
use PayPal\Transport\PayPalRestCall;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\Template;
use PayPal\Rest\ApiContext;
@@ -237,6 +238,8 @@ class Templates extends PayPalResourceModel
/**
* Retrieve the details for a particular template by passing the template ID to the request URI.
*
* @deprecated Please use `Template::get()` instead.
* @see Template::get
* @param string $templateId
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
@@ -267,7 +270,7 @@ class Templates extends PayPalResourceModel
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Templates
*/
public static function getAll($params, $apiContext = null, $restCall = null)
public static function getAll($params = array(), $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($params, 'params');
$payLoad = "";
@@ -286,78 +289,4 @@ class Templates extends PayPalResourceModel
$ret->fromJson($json);
return $ret;
}
/**
* Delete a particular template by passing the template ID to the request URI.
*
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return bool
*/
public function delete($apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
$payLoad = "";
self::executeCall(
"/v1/invoicing/templates/{$this->getId()}",
"DELETE",
$payLoad,
null,
$apiContext,
$restCall
);
return true;
}
/**
* Creates a template.
*
* @param Template $template
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Template
*/
public function create($template, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($template, 'template');
$payLoad = $template->toJSON();
$json = self::executeCall(
"/v1/invoicing/templates",
"POST",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Template();
$ret->fromJson($json);
return $ret;
}
/**
* Update an existing template by passing the template ID to the request URI. In addition, pass a complete template object in the request JSON. Partial updates are not supported.
*
* @param Template $template
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PayPalRestCall $restCall is the Rest Call Service that is used to make rest calls
* @return Template
*/
public function update($template, $apiContext = null, $restCall = null)
{
ArgumentValidator::validate($this->getId(), "Id");
ArgumentValidator::validate($template, 'template');
$payLoad = $template->toJSON();
$json = self::executeCall(
"/v1/invoicing/templates/{$this->getId()}",
"PUT",
$payLoad,
null,
$apiContext,
$restCall
);
$ret = new Template();
$ret->fromJson($json);
return $ret;
}
}