Closed dhaval24071991 closed 8 years ago
Please Review this changes and merge with your code so it is useful for futute.
**_Chargify Allocation php file _****
//Reference Documentation:Allocation api
class ChargifyAllocation extends ChargifyBase { //** //\ INPUT & OUTPUT VARIABLES //**** var $quantity; var $memo;
//****************************** //*** OUTPUT ONLY VARIABLES **** //****************************** var $id; private $connector; public function __construct(SimpleXMLElement $allocation_xml_node = null, $test_mode = false) { $this->connector = new ChargifyConnector($test_mode); if ($allocation_xml_node) { //Load object dynamically and convert SimpleXMLElements into strings foreach($allocation_xml_node as $key => $element) { $this->$key = (string)$element; } } } protected function getName() { return "allocation"; } public function create($subscription_id, $component_id) { return $this->connector->createQtyComponent($subscription_id, $component_id, $this); }}
Add two functions in ChargifyConnector.php
public function createQtyComponent($subscription_id, $component_id, $chargify_usage) { $xml = $this->requestQtyComponent($subscription_id, $component_id, $chargify_usage->getXML()); $usage = new SimpleXMLElement($xml); return new ChargifyUsage($usage, $this->test_mode); } public function requestQtyComponent($subscription_id, $component_id, $componentRequest, $format = 'XML') { $extension = strtoupper($format) == 'XML' ? '.xml' : '.json'; $base_url = "/subscriptions/{$subscription_id}/components/{$component_id}/allocations"; $xml = $this->sendRequest($base_url, $format, 'POST', $componentRequest); if ($xml->code == 201) { //CREATED return $xml->response; } elseif ($xml->code == 422) { //UNPROCESSABLE ENTITY $errors = new SimpleXMLElement($xml->response); throw new ChargifyValidationException($xml->code, $errors); } }
ChargifyAllocation.txt ChargifyConnector.txt
Please review above changes for update qty based component chargify allocation qty
Please Review this changes and merge with your code so it is useful for futute.
**_Chargify Allocation php file _****
//Reference Documentation:Allocation api
class ChargifyAllocation extends ChargifyBase { //** //\ INPUT & OUTPUT VARIABLES //**** var $quantity; var $memo;
Add two functions in ChargifyConnector.php
ChargifyAllocation.txt ChargifyConnector.txt