public function getCustomerSubscriptionByCId($client_id)
{
$r = $this->sendRequest("/customers/{$client_id}/subscriptions.xml", 'GET');
if ($r->getResponseCode() == 200) {
$xml_node = new SimpleXMLElement($r->getBody()->toString());
$subscription = new ChargifySubscription($xml_node);
return $subscription;
} else {
if ($r->getResponseCode() == 422) {
$xml_node = new SimpleXMLElement($r->getBody()->toString());
if ($xml_node->error) {
return (string) $xml_node->error;
}
}
throw new Exception("Cannot get subscription info. Response code: " . $r->getResponseCode() . ". Response body: " . $r->getBody()->toString());
}
}