public function &__get($key) { if ($key == 'redemption' && parent::__isset('redemptions')) { return new Recurly_Stub('redemption', $this->_href . "/redemption", $this->_client); } else { return parent::__get($key); } }
function __construct($accountCode = null, $client = null) { parent::__construct(null, $client); if (!is_null($accountCode)) { $this->account_code = $accountCode; } $this->address = new Recurly_Address(); $this->balance_in_cents_invoiced = new Recurly_CurrencyList('balance_in_cents_invoiced'); $this->balance_in_cents_uninvoiced = new Recurly_CurrencyList('balance_in_cents_uninvoiced'); }
protected function _save($method, $uri) { $this->_errors = array(); // reset errors if (is_null($this->_client)) { $this->_client = new Recurly_Client(); } $response = $this->_client->request($method, $uri, $this->xml()); Recurly_Resource::__parseXmlToUpdateObject($response->body); $response->assertSuccessResponse($this); }
/** * Delete the object at the given URI. * @param string URI of the object to delete * @param array Additional parameters for the delete */ protected function _delete($uri) { if (is_null($this->_client)) { $this->_client = new Recurly_Client(); } $response = $this->_client->request(Recurly_Client::DELETE, $uri); if ($response->body) { Recurly_Resource::__parseXmlToUpdateObject($response->body); } $response->assertSuccessResponse($this); return true; }
protected function _save($method, $uri, $data = null) { $this->_errors = array(); // reset errors if (is_null($data)) { $data = $this->xml(); } $response = $this->_client->request($method, $uri, $data); $response->assertValidResponse(); if (isset($response->body)) { Recurly_Resource::__parseXmlToUpdateObject($response->body); } $response->assertSuccessResponse($this); }
protected function populateXmlDoc(&$doc, &$node, &$obj) { $addonNode = $node->appendChild($doc->createElement($this->getNodeName())); parent::populateXmlDoc($doc, $addonNode, $obj); }
protected static function __parseXmlToObject($node, &$object) { while ($node) { //print "Node: {$node->nodeType} -- {$node->nodeName}\n"; if ($node->nodeType == XML_TEXT_NODE) { if ($node->wholeText != null) { $text = trim($node->wholeText); if (!empty($text)) { $object->description = $text; } } } else { if ($node->nodeType == XML_ELEMENT_NODE) { $nodeName = str_replace("-", "_", $node->nodeName); if ($object instanceof Recurly_Pager) { $new_obj = Recurly_Resource::__createNodeObject($node); if (!is_null($new_obj)) { Recurly_Resource::__parseXmlToObject($node->firstChild, $new_obj); $object->_objects[] = $new_obj; } $node = $node->nextSibling; continue; } else { if ($object instanceof Recurly_ErrorList) { if ($nodeName == 'error') { $object[] = Recurly_Resource::parseErrorNode($node); $node = $node->nextSibling; continue; } } else { if (is_array($object)) { if ($nodeName == 'error') { $object[] = Recurly_Resource::parseErrorNode($node); $node = $node->nextSibling; continue; } $new_obj = Recurly_Resource::__createNodeObject($node); if (!is_null($new_obj)) { if (is_object($new_obj) || is_array($new_obj)) { Recurly_Resource::__parseXmlToObject($node->firstChild, $new_obj); } $object[] = $new_obj; } $node = $node->nextSibling; continue; } } } $numChildren = $node->childNodes->length; if ($numChildren == 0) { // No children, we might have a link $href = $node->getAttribute('href'); if (!empty($href)) { if ($nodeName == 'a') { $linkName = $node->getAttribute('name'); $method = $node->getAttribute('method'); $object->addLink($linkName, $href, $method); } else { if (!is_object($object)) { $object->{$nodeName} = new Recurly_Stub($nodeName, $href); } else { $object->{$nodeName} = new Recurly_Stub($nodeName, $href, $object->_client); } } } } else { if ($node->firstChild->nodeType == XML_ELEMENT_NODE) { // has element children, drop in and continue parsing $new_obj = Recurly_Resource::__createNodeObject($node); if (!is_null($new_obj)) { $object->{$nodeName} = Recurly_Resource::__parseXmlToObject($node->firstChild, $new_obj); } } else { // we have a single text child if ($node->hasAttribute('nil')) { $object->{$nodeName} = null; } else { switch ($node->getAttribute('type')) { case 'boolean': $object->{$nodeName} = $node->nodeValue == 'true'; break; case 'date': case 'datetime': $object->{$nodeName} = new DateTime($node->nodeValue); break; case 'float': $object->{$nodeName} = (double) $node->nodeValue; break; case 'integer': $object->{$nodeName} = (int) $node->nodeValue; break; case 'array': $object->{$nodeName} = array(); break; default: $object->{$nodeName} = $node->nodeValue; } } } } } } $node = $node->nextSibling; } if (isset($object->_unsavedKeys)) { $object->_unsavedKeys = array(); } return $object; }
function __construct($href = null, $client = null) { parent::__construct($href, $client); $this->discount_in_cents = new Recurly_CurrencyList('discount_in_cents'); }
public function delete() { return Recurly_Resource::_delete($this->uri()); }
function __construct() { parent::__construct(); $this->discount_in_cents = new Recurly_CurrencyList('discount_in_cents'); }
public static function deletePlan($planCode) { return Recurly_Resource::_delete(Recurly_Plan::uriForPlan($planCode)); }
public static function deleteForAccount($accountCode) { return Recurly_Resource::_delete(Recurly_BillingInfo::uriForBillingInfo($accountCode)); }
public function __construct($href = null, $client = null) { parent::__construct($href, $client); $this->subscription_add_ons = array(); }
public static function closeAccount($accountCode) { return Recurly_Resource::_delete(Recurly_Account::uriForAccount($accountCode)); }
function __construct() { parent::__construct(); $this->balance_in_cents = new Recurly_CurrencyList('balance_in_cents'); }
function __construct($accountCode = null, $client = null) { parent::__construct(null, $client); if (!is_null($accountCode)) $this->account_code = $accountCode; $this->address = new Recurly_Address(); }
function __construct() { parent::__construct(); $this->setup_fee_in_cents = new Recurly_CurrencyList('setup_fee_in_cents'); $this->unit_amount_in_cents = new Recurly_CurrencyList('unit_amount_in_cents'); }
public function delete($accountCode = null) { return Recurly_Resource::_delete($this->uri($accountCode)); }
protected function populateXmlDoc(&$doc, &$node, &$obj, $nested = false) { $shippingAddressNode = $node->appendChild($doc->createElement($this->getNodeName())); parent::populateXmlDoc($doc, $shippingAddressNode, $obj); }
public static function deleteCoupon($couponCode) { return Recurly_Resource::_delete(Recurly_Coupon::uriForCoupon($couponCode)); }