protected function httpRequest($action, $data, $method = 'POST', $options = [])
{
$response = $this->{$this->http_request_type}($action, $data, $method, $options);
$json = json_decode($response, true);
if ($json === NULL) {
throw new Sailthru_Client_Exception("Response: {$response} is not a valid JSON", Sailthru_Client_Exception::CODE_RESPONSE_INVALID);
}
if (isset($json['error'])) {
throw new Sailthru_Client_Exception($json['errormsg'], $json['error']);
}
return $json;
}