public function getSubscription($subscriptionId)
{
$r = $this->sendRequest("/subscriptions/{$subscriptionId}.json", 'GET');
if ($r->getResponseCode() == 200) {
return json_decode($r->getBody()->toString(), true);
} else {
if ($r->getResponseCode() == 422) {
$response = json_decode($r->getBody()->toString(), true);
throw new Exception($response['errors'][0]);
}
throw new Exception("Cannot get subscription info. Response code: " . $r->getResponseCode() . ". Response body: " . $r->getBody()->toString());
}
}