Example #1
0
 /**
  * Creates a new Desk.com instance, with a default transport.
  *
  * @param string $subdomain The subdomain of desk.com to connect to
  * @param string $consumerKey The Desk.com API consumer key
  * @param string $consumerSecret The Desk.com API consumer secret
  * @param string $accessToken The Desk.com access token
  * @param string $accessSecret The Desk.com access secret
  */
 public function __construct($subdomain, $consumerKey, $consumerSecret, $accessToken, $accessSecret)
 {
     $hostname = self::getHostname($subdomain);
     $transport = new Transport\OAuth($hostname, $consumerKey, $consumerSecret);
     $transport->setToken($accessToken, $accessSecret);
     $this->transport($transport);
 }
Example #2
0
 private function request($method = 'GET', $path, $parameters = array(), $headers = array())
 {
     $url = rtrim($this->host, '/') . '/' . ltrim($path, '/');
     try {
         $result = $this->adapter->fetch($url, $parameters, strtoupper($method), $headers);
     } catch (\OAuthException $e) {
         $response = new Response($this->adapter->getLastResponse());
         $json = $response->json();
         if (empty($json->success)) {
             throw new \Desk\Exception\ApiCallFailureException('Desk.com request failed', $response);
         } else {
             throw $e;
         }
     }
     $body = $this->adapter->getLastResponse();
     return new Response($body);
 }