Updated Billing Plan to have Delete Plan sample code.

- Added helper method in Plan.php to allow deleting a billing plan
- Fixes #171
This commit is contained in:
japatel
2014-12-01 13:20:36 -06:00
parent 493c6f8531
commit ff5588bbfe
6 changed files with 107 additions and 2 deletions

View File

@@ -2,6 +2,7 @@
namespace PayPal\Api;
use PayPal\Common\PPModel;
use PayPal\Common\ResourceModel;
use PayPal\Validation\ArgumentValidator;
use PayPal\Api\PlanList;
@@ -543,6 +544,28 @@ class Plan extends ResourceModel
return true;
}
/**
* Delete a billing plan by passing the ID of the billing plan to the request URI.
*
* @param ApiContext $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
* @param PPRestCall $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");
$patchRequest = new PatchRequest();
$patch = new Patch();
$value = new PPModel('{
"state":"DELETED"
}');
$patch->setOp('replace')
->setPath('/')
->setValue($value);
$patchRequest->addPatch($patch);
return $this->update($patchRequest, $apiContext, $restCall);
}
/**
* List billing plans according to optional query string parameters specified.
*