/**
  * {@inheritDoc}
  */
 public function execute(Request $request)
 {
     $uri = $this->getUri($request->getMethod(), $request->getParam('apikey'));
     $httpRequest = $this->client->post($uri, array('Content-Type' => 'application/json'))->setBody(json_encode($request->getParams()));
     $rawResponse = false;
     try {
         $rawResponse = $httpRequest->send();
         $response = $this->parseResponse($rawResponse);
     } catch (BadResponseException $e) {
         $body = $this->parseResponse($e->getResponse());
         $response = array('error' => isset($body['error']) ? $body['error'] : 'An error occured: ' . $e->getMessage(), 'code' => isset($body['code']) ? $body['code'] : self::INTERNAL_CODE_UNKNOWN_EXCEPTION_ERROR);
     } catch (\Exception $e) {
         $response = array('error' => 'An error occurred: ' . $e->getMessage(), 'code' => self::INTERNAL_CODE_UNKNOWN_EXCEPTION_ERROR);
     }
     if (false === $response) {
         $response = $this->handleEdgeCase($rawResponse);
     }
     if (is_array($response) && isset($response['error'])) {
         // return an error response
         return new Response($response, Response::STATUS_ERROR);
     }
     // return a success response
     return new Response($response);
 }