예제 #1
0
 /**
  * Make a Request
  *
  * @param    string API Endpoint
  * @param    string HTTP Method
  * @param    array Parameters to pass
  * @return resource
  */
 public function make($location, $method = 'GET', $params = [], $headers = [])
 {
     $options = [];
     switch (strtoupper($method)) {
         case 'GET':
             $options['query'] = $params;
             break;
         case 'POST':
         case 'PUT':
         case 'PATCH':
             $options['body'] = $params;
             break;
     }
     $options['headers'] = $headers;
     $options['headers']['Authorization'] = 'token ' . $this->client->getToken();
     try {
         return $this->getHttpClient()->{$method}($location, $options);
     } catch (ClientErrorResponseException $e) {
         return Error::create($e);
     } catch (ServerException $e) {
         return Error::create($e);
     } catch (Exception $e) {
         return Error::create($e);
     }
 }
예제 #2
0
 public function testCreate()
 {
     $error = Error::create($this->error);
     $this->assertInstanceOf('Srtfisher\\Automatic\\Error', $error);
     $this->assertEquals((string) $error, '[ERROR] mockexception: Exception Message');
 }