Example #1
0
 /**
  * @param Actions\ActionsInterface $action
  * @param array                    $requestParams
  * @return Url
  */
 protected function buildRequestUrl(Actions\ActionsInterface $action, array $requestParams)
 {
     $url = new Url('https', $this->connection->getEndpoint());
     $url->setPath($action->getAction());
     $url->setQuery($requestParams);
     return $url;
 }
Example #2
0
 /**
  * @param \Guzzle\Http\Message\Response $guzzleResponse
  * @param ActionsInterface              $action
  * @return Response
  */
 public static function parseGuzzleResponse(\Guzzle\Http\Message\Response $guzzleResponse, ActionsInterface $action)
 {
     $response = new self();
     if ($guzzleResponse->getStatusCode() != 200) {
         $response->setStatus(false);
         $response->setError($response::ERROR_REQUEST_ERROR);
         return $response;
     }
     $responseArray = json_decode($guzzleResponse->getBody(true), true);
     $response->setStatus($responseArray['ok']);
     if ($response->getStatus() === false) {
         $response->setError($responseArray['error']);
         return $response;
     }
     $response->setData($action->parseResponse($responseArray));
     return $response;
 }