Example #1
0
 /**
  * Do request and return response.
  *
  * @return object
  *
  * @throws \Exception
  */
 protected function fire()
 {
     $response = null;
     try {
         $url = $this->getRequestUrl();
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage());
     }
     try {
         $response = $this->requester->doRequest($url);
     } catch (\Exception $e) {
         throw new \Exception($e->getMessage());
     }
     if ($response) {
         $jsonResponse = json_decode($response);
         if (isset($jsonResponse->error)) {
             throw new \Exception('API error: ' . $jsonResponse->error);
         }
         return $jsonResponse;
     }
     throw new \Exception('Empty response');
 }