public function fetch($action, $params)
{
$endpoint = sprintf('%s/api/%s/', $this->domain, $this->version);
$query = http_build_query($params);
$url = sprintf('%s%s?%s', $endpoint, $action, $query);
$response = $this->download($url);
$result = json_decode($response, true);
if (is_null($result)) {
$message = sprintf('There was an error reading the response from the Marketplace: Please try again later.');
throw new Service\Exception($message, Service\Exception::HTTP_ERROR);
}
if (!empty($result['error'])) {
throw new Service\Exception($result['error'], Service\Exception::API_ERROR);
}
return $result;
}