示例#1
3
 /**
  * PUT command
  * @return bool true if ok
  */
 public function DELETE($url)
 {
     try {
         $this->response = Request::delete($url)->authenticateWith($this->username, $this->password)->expectsType('xml')->send();
     } catch (Exception $ex) {
         \Yii::error($exc->getMessage() . "\n" . $exc->getTraceAsString());
         return false;
     }
     if ($this->isOk()) {
         return true;
     }
     return false;
 }
 protected function delete($uri, array $params = null)
 {
     if (!is_null($params)) {
         $params = self::clean_array($params);
         return self::process_response(Request::delete(self::$base_uri . $uri . '?' . http_build_query($params))->send());
     }
     return self::process_response(Request::delete(self::$base_uri . $uri)->send());
 }
 public static function delete($url, $data = [], $auth = true)
 {
     $api = self::$api;
     $response = \Httpful\Request::delete($api->url . $url);
     // Will parse based on Content-Type
     if ($auth) {
         $response->authenticateWith($api->username, $api->password);
     }
     $response = $response->sendsJson()->body(json_encode($data))->send();
     return (array) $response->body;
 }
 public static function _DELETE($url)
 {
     $real_url = \Marketcloud\Marketcloud::$apiBaseUrl . $url;
     $response = \Httpful\Request::delete($real_url)->expectsJson()->addHeader('Authorization', \Marketcloud\Marketcloud::getAuthorizationHeader())->send();
     // We check the response code
     // If the code is 401, then the Token might be expired.
     // If it is the case, we re-authenticate the client using the stored credentials.
     //
     if ($response->code == 401) {
         // We have to re-authenticate
         $auth_response = \Marketcloud\Marketcloud::authenticate();
         return self::_DELETE($url);
     } else {
         return $response;
     }
 }
 public static function CallAPI($method, $url, $data = false)
 {
     $response = null;
     switch ($method) {
         case "GET":
             $response = \Httpful\Request::get($url)->expects("json")->send();
             break;
         case "POST":
             $response = \Httpful\Request::post($url)->body($data)->sendsAndExpects("json")->send();
             break;
         case "PUT":
             $response = \Httpful\Request::put($url)->body($data)->sendsAndExpects("json")->send();
             break;
         case "DELETE":
             $response = \Httpful\Request::delete($url)->body($data)->sendsAndExpects("json")->send();
             break;
     }
     return is_null($response) ? null : $response->body;
 }
 public function processAction(CRM_Civirules_TriggerData_TriggerData $triggerData)
 {
     //do the http post process
     $uri = $this->getFullUri($triggerData);
     $method = $this->getHttpMethod();
     $body = http_build_query($this->getBodyParams($triggerData));
     switch (strtolower($method)) {
         case 'post':
             $request = \Httpful\Request::post($uri, $body);
             break;
         case 'put':
             $request = \Httpful\Request::put($uri, $body);
             break;
         case 'delete':
             $request = \Httpful\Request::delete($uri);
             break;
         case 'head':
             $request = \Httpful\Request::head($uri);
             break;
         case 'patch':
             $request = \Httpful\Request::patch($uri, $body);
             break;
         case 'options':
             $request = \Httpful\Request::options($uri, $body);
             break;
         case 'get':
             $request = $response = \Httpful\Request::get($uri);
             break;
         default:
             throw new Exception('Invalid HTTP Method');
     }
     $request->neverSerializePayload();
     $request = $this->alterHttpRequestObject($request, $triggerData);
     $response = $request->send();
     $this->handleResponse($response, $request, $triggerData);
 }
示例#7
0
 public function RestClient($method, $entity, $payload = null, $mime = null)
 {
     $username = $this->Login();
     $password = $this->Password();
     $url = $this->BaseUrl() . $entity . "?" . $payload;
     switch ($method) {
         case 'get':
             $response = Request::get($url)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'post':
             $response = Request::post($url)->body($payload, $mime)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'delete':
             $response = Request::delete($url)->authenticateWith($username, $password)->send();
             return $response;
             break;
         case 'patch':
             $response = Request::patch($url)->body($payload, $mime)->authenticateWith($username, $password)->send();
             return $response;
             break;
     }
 }
示例#8
0
 /**
  * @param $videoID
  * @param $token
  * @param $secure
  * @return mixed
  * @throws ResponseClientError
  * @throws ResponseRedirectionError
  * @throws ResponseServerError
  * @throws UnknownResponseCodeException
  * @throws \Httpful\Exception\ConnectionErrorException
  */
 public static function deleteVideo($videoID, $token, $secure)
 {
     $uri = static::genCompositeUrl(__FUNCTION__, [':video_id' => $videoID], [], $secure);
     $headers = static::getHeaders($token);
     $response = \Httpful\Request::delete($uri)->addHeaders($headers)->send();
     static::checkCode($response->meta_data['http_code'], $response->body);
     return $response->meta_data['http_code'] == 204;
 }
示例#9
0
echo "response http status: " . $response->code . "\n\n";
echo "Teilinhalt der response: " . $response->body->createdPersonWithName . "\n\n";
// var_dump($response);
// ------------- der anfang des var_dump - outputs hier: ---------------------
// ["body"]=>
// object(stdClass)#14 (2) {
// ["func"]=>
// string(6) "create"
// ["createdPersonWithName"]=>
// string(4) "emma"
// }
// ["raw_body"]=>
// string(48) "{"func":"create","createdPersonWithName":"emma"}"
// ===================================================================
// PUT Request  (update single person)
// ===================================================================
$uri = "http://localhost/testapp/index.php/api/persons/emma";
$payload = array('attributeToBeUPdated' => 'newValue');
echo "\n\n================ PUT:  {$uri} \n";
$response = \Httpful\Request::put($uri)->sendsJson()->body($payload)->send();
// and finally, fire that thing off!
# var_dump($response);
echo "response http status: " . $response->code . "\n\n";
echo "Teilinhalt der response: " . $response->body->updatedPersonWithId . "\n\n";
// ===================================================================
// DELETE Request  (delete single person)
// ===================================================================
$uri = "http://localhost/testapp/index.php/api/persons/todelete";
echo "\n\n================ DELETE:  {$uri} \n";
$response = \Httpful\Request::delete($uri)->send();
echo "response http status: " . $response->code . "\n\n";
示例#10
0
 /**
  * Delete a project run. This cancels a run if running, and deletes the run
  * and its data.
  * @param  string $run_token run token of a project run.
  * @return string            json response with run token that run was
  *                                deleted.
  */
 public function deleteProjectRun($run_token)
 {
     $url = $this->getProjectRunDeleteApiUrl($run_token);
     $api_key = self::$config['api_key'];
     $response = PHPHttpful::delete($url)->send();
     if ($this->isResponseValid($response)) {
         self::$logger->info("Project run deleted successfully on parsehub of run_token {$run_token}");
         $data = $response->body;
         return $data;
     }
 }
 public function deleteBusOperation($plat_nomor)
 {
     if (getenv('APP_ENV') == 'local') {
         $baseUrl = env('URL_DEV_API');
     }
     if (getenv('APP_ENV') == 'production') {
         $baseUrl = env('URL_API');
     }
     $deleteBusUrl = $baseUrl . 'bus/operation/' . $plat_nomor;
     $response = \Httpful\Request::delete($deleteBusUrl)->send();
     return redirect()->action('UserController@viewAllBus');
 }
示例#12
0
 /**
  * Removes user from _users database 
  * @return associative array of the Httpful response
  */
 public function destroy()
 {
     $con = $this->config;
     $this->read();
     $rev = "?rev=" . $this->doc["_rev"];
     $delete_response = h\Request::delete($con->user_doc_url($this->name, "main") . $rev)->authenticateWith($con->constants->ADMIN_U, $con->constants->ADMIN_P)->send();
     return json_decode($delete_response, true);
 }
示例#13
0
 public function delete(Entity $instance)
 {
     if (!$instance->isAllowedMethod(__FUNCTION__)) {
         throw new \DomainException(__FUNCTION__ . ' not allowed on this entity.');
     }
     $url = sprintf('%s/%s/%s/%s', $this->getApiUrl(), $this->getNetworkId(), $this->getEndpointName($instance), $instance->getId());
     $response = \Httpful\Request::delete($url)->authenticateWith($this->getLogin(), $this->getPassword())->send();
     if ($response->hasErrors()) {
         $exception = json_decode($response->raw_body);
         throw new \UnexpectedValueException(sprintf("API response raised a '%s' exception with a message: '%s'. Status code %s", $exception->name, $exception->message, $response->code));
     }
     return $instance;
 }
 function remove_user_from_project($userID, $projectID)
 {
     if (empty($this->endPoint)) {
         return array('result' => 'error', 'message' => 'API Endpoint Not Found.');
     }
     if (empty($this->privateToken)) {
         return array('result' => 'error', 'message' => 'Private Token Not Found.');
     }
     $args = array('id' => $projectID, 'user_id' => $userID);
     $response = \Httpful\Request::delete($this->endPoint . 'projects/' . $projectID . '/members/' . $userID)->addHeader('PRIVATE-TOKEN', $this->privateToken)->body(json_encode($args))->sendsJson()->send();
     $result = $this->identify_response($response);
     return $result;
 }
 private function invoke($action, $uri, $headers, $method, $expects, $payload)
 {
     if ($this->fds_config->isMetricsEnabled()) {
         $request_metrics = new RequestMetrics($action);
         $request_metrics->startEvent(RequestMetrics::EXECUTION_TIME);
     }
     $request = null;
     switch ($method) {
         case Http::GET:
             $request = Request::get($uri);
             break;
         case Http::PUT:
             $request = Request::put($uri, $payload);
             break;
         case Http::POST:
             $request = Request::post($uri, $payload);
             break;
         case Http::DELETE:
             $request = Request::delete($uri);
             break;
         case Http::HEAD:
             $request = Request::head($uri);
     }
     if ($expects != null) {
         $request = $request->expects($expects);
     }
     $response = $request->addHeaders($headers)->retry($this->fds_config->getRetry())->timeout($this->fds_config->getConnectionTimeoutSecs())->send();
     if ($this->fds_config->isMetricsEnabled()) {
         $request_metrics->endEvent(RequestMetrics::EXECUTION_TIME);
         $this->metrics_collector->collect($request_metrics);
     }
     return $response;
 }
示例#16
0
 /**
  * Deletes a Resource
  * 
  * @param  mixed $code String code or the ApiResourceInterface instance
  * @return \Httpful\Response
  */
 public function delete($code)
 {
     if ($code instanceof $this->resourceClassName) {
         $idField = $code->getIdField();
         $code = $code->{$idField};
     }
     $url = $this->generateUrl($code);
     $response = \Httpful\Request::delete($url)->send();
     $this->checkResponseErrors($response);
     return $response;
 }
示例#17
0
 protected function createDeleteRequestJson($resourceName, $resourceId)
 {
     $resourcePath = $this->calculateResourcePath($resourceName, $resourceId);
     $uri = $this->calculateUriForResourcePath($resourcePath);
     /** @var \Httpful\Request $getRequest  */
     $getRequest = Request::delete($uri);
     $getRequest->autoParse(false);
     $this->addAuthenticationHeadersToRequest($getRequest, $resourcePath);
     return $getRequest;
 }
示例#18
0
文件: client.php 项目: vicioux/apisdk
 public function delete($endpoint, $options = [])
 {
     $uri = Client::endpoint() . $endpoint . Client::getUriOptions($options);
     $response = \Httpful\Request::delete($uri)->authenticateWith(Client::key(), Client::secret())->addHeaders(Client::headers())->send();
     return $response;
 }
示例#19
0
 public function request($url, $data, $header, $method = 'POST')
 {
     $logger = JPushLog::getLogger();
     $logger->debug("Send " . $method, array("method" => $method, "uri" => $url, "headers" => $header, "body" => $data));
     $request = null;
     if ($method === 'POST') {
         $request = Request::post($url);
     } else {
         if ($method == 'DELETE') {
             $request = Request::delete($url);
         } else {
             $request = Request::get($url);
         }
     }
     if (!is_null($data)) {
         $request->body($data);
     }
     $request->addHeaders($header)->authenticateWith($this->appKey, $this->masterSecret)->timeout(self::READ_TIMEOUT);
     $response = null;
     for ($retryTimes = 0;; $retryTimes++) {
         try {
             $response = $request->send();
             break;
         } catch (ConnectionErrorException $e) {
             if (strpos($e->getMessage(), '28')) {
                 throw new APIConnectionException("Response timeout. Your request has probably be received by JPush Server,please check that whether need to be pushed again.", true);
             }
             if (strpos($e->getMessage(), '56')) {
                 // resolve error[56 Problem (2) in the Chunked-Encoded data]
                 throw new APIConnectionException("Response timeout, maybe cause by old CURL version. Your request has probably be received by JPush Server, please check that whether need to be pushed again.", true);
             }
             if ($retryTimes >= $this->retryTimes) {
                 throw new APIConnectionException("Connect timeout. Please retry later.");
             } else {
                 $logger->debug("Exception - Message:" . $e->getMessage() . ", Code:" . $e->getCode());
                 $logger->debug("Retry again send " . $method, array("method" => $method, "uri" => $url, "headers" => $header, "body" => $data, "retryTimes" => $retryTimes + 1));
             }
         }
     }
     return $response;
 }
示例#20
0
 /**
  *
  * Makes a call to the API server and returns the response
  *
  * @param string $modulePath The module path (generally provided by the API Class)
  * @param string $id The id for a get method
  * @param array  $params Any params that need to be added used for creating, editing, or filtering data
  * @param int    $method The HTTP method to be used
  * @return mixed The result of the call
  */
 public function makeCall($modulePath, $id = '', $params = [], $method = self::METHOD_GET)
 {
     $uri = $this->endPoint . '/' . $modulePath . (!empty(trim($id)) ? '/' . $id : '');
     //Setup Request Object
     switch ($method) {
         case self::METHOD_GET:
             $request = Request::get($uri)->sendsJson();
             break;
         case self::METHOD_POST:
             $request = Request::post($uri)->sendsJson();
             break;
         case self::METHOD_PATCH:
             $request = Request::patch($uri)->sendsJson();
             break;
         case self::METHOD_DELETE:
             $request = Request::delete($uri)->sendsJson();
             break;
         default:
             $request = Request::get($uri)->sendsJson();
             break;
     }
     $request->expectsJson();
     //Handle Data
     if ($method == self::METHOD_GET || $method == self::METHOD_DELETE) {
         $params['access_token'] = $this->token;
         $request->uri .= '?' . http_build_query($params);
     } else {
         $request->uri .= '?access_token=' . $this->token;
         $request->body(json_encode($params));
     }
     return $request->send();
 }
示例#21
0
 /**
  * Запрос DELETE
  * @param string $uri
  * @return mixed
  */
 public function delete($uri)
 {
     $this->request = Request::delete($uri);
     return $this;
 }
示例#22
0
 public function delete()
 {
     try {
         $response = \Httpful\Request::delete($this->path . "/" . $this->msisdn)->send();
     } catch (Httpful\Exception\ConnectionErrorException $e) {
         throw new SubscriberException($e->getMessage());
     }
     $data = $response->body;
     if ($data->status == 'failed') {
         throw new SubscriberException($data->error);
     }
 }
示例#23
0
 /**
  * Completely deletes a database, on $user's word.
  */
 public function destroy(User $user = null)
 {
     $con = $this->config;
     // assert non-null user
     if ($user == null) {
         throw new InvalidArgumentException('Method requires an user.');
     }
     // assert admin user
     $security_doc = $this->get_security_doc();
     if (!in_array($user->get_name(), $security_doc['admins']['names']) && count($security_doc['admins']['names']) == 1) {
         throw new InvalidArgumentException('User must be group admin.');
     }
     /*
      * Your papers check out sir, deleting database.
      */
     $data = array("create_target" => true, "source" => $con->group_db_name($this->name, "main"), "target" => $con->deleted_db_name($this->name));
     // stash a copy
     $post_response = h\Request::post($con->db_url("_replicate", "main"))->authenticateWith($con->constants->ADMIN_U, $con->constants->ADMIN_P)->sendsJson()->body(json_encode($data))->send();
     $delete_response_raw = h\Request::delete($con->group_db_url($this->name, "main"))->authenticateWith($con->constants->ADMIN_U, $con->constants->ADMIN_P)->send();
     $delete_response = json_decode($delete_response_raw, true);
     // If the database was deleted, remove user's references to it
     if (!isset($delete_response['error'])) {
         $this->isExtant = false;
         $user_categories = array($security_doc['admins']['names'], $security_doc['members']['names']);
         foreach ($user_categories as $category) {
             foreach ($category as $user) {
                 $notify_user = new User(array("name" => $user, "admin" => true));
                 $notify_user->remove_group($this);
             }
         }
         // Remove the uploader user
         $uploader_user = new User(array("name" => "uploader-" . $this->get_name(), "admin" => true));
         $uploader_user->destroy();
         /*
          * remove the backup entry in _replicator
          */
         $backup_name = $con->constants->SERVER_NICKNAME . "_" . $this->name . "_" . $con->constants->BACKUP_SUFFIX;
         $replicator_response = json_decode(h\Request::get($con->doc_url($backup_name, "_replicator", "backup", true))->send(), true);
         $rev = "?rev=" . $replicator_response['_rev'];
         $delete_response_raw = h\Request::delete($con->doc_url($backup_name, "_replicator", "backup", true) . $rev)->authenticateWith($con->constants->ADMIN_U, $con->constants->ADMIN_P)->send();
     }
     return $delete_response;
 }
 protected function httpDelete($uri)
 {
     $this->log[] = ['request' => ['method' => 'DELETE', 'uri' => $uri]];
     $response = \Httpful\Request::delete($uri)->addHeader('X-Auth-Email', $this->email)->addHeader('X-Auth-Key', $this->apikey)->expects(\Httpful\Mime::JSON)->parseWith(function ($body) {
         return \Metaclassing\Utility::decodeJson($body);
     })->send()->body;
     $this->log[count($this->log) - 1]['response'] = $response;
     if ($response['success'] != true) {
         throw new \Exception("delete to {$uri} unsuccessful");
     }
     return $response['result'];
 }
示例#25
0
 /**
  * Release a static number.
  * @throws \Exception
  * @param string $number a number to release
  * @return object|null
  */
 public function releaseStatic($number)
 {
     $apiMethodUrl = $this->getMethodUrl("/calltracking/static/number/{$number}/");
     $response = \Httpful\Request::delete($apiMethodUrl)->expectsJson()->addHeaders($this->getAuthHeader())->send();
     $msg = 'Unable to release';
     if (property_exists($response, 'body')) {
         if (property_exists($response->body, 'success') && $response->body->success) {
             return true;
         } else {
             $msg = $response->raw_body;
         }
     }
     throw new \Exception($msg);
 }
示例#26
0
 /**
  * Method for performing requests to PromisePay endpoints.
  *
  * @param string $method One of the four supported requests methods (get, post, delete, patch)
  * @param string $entity Endpoint name
  * @param string $payload optional URL encoded data query
  * @param string $mime optional Set specific MIME type.
  */
 public static function RestClient($method, $entity, $payload = null, $mime = null)
 {
     Helpers\Functions::runtimeChecks();
     if (!is_scalar($payload) && $payload !== null) {
         $payload = http_build_query($payload);
     }
     $url = constant(__NAMESPACE__ . '\\API_URL') . $entity . '?' . $payload;
     if (self::$sendAsync) {
         self::$pendingRequests[] = array($method, $url);
         // set and return an empty array instead of null
         // to avoid breaking any BC
         self::$jsonResponse = array();
         return self::$jsonResponse;
     }
     switch ($method) {
         case 'get':
             $response = \Httpful\Request::get($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'post':
             $response = \Httpful\Request::post($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'delete':
             $response = \Httpful\Request::delete($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'patch':
             $response = \Httpful\Request::patch($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         default:
             throw new Exception\ApiUnsupportedRequestMethod(sprintf('%s is not a supported request method.', $method));
     }
     self::$debugData = $response;
     if (self::isRetry() && ($response->http_code === 503 || $response->http_code === 504)) {
         if (self::$debug) {
             fwrite(STDOUT, sprintf("HTTP Code %d detected while retrying is enabled; retrying" . PHP_EOL, $response->http_code));
         }
         return forward_static_call_array(array(__NAMESPACE__ . '\\PromisePay', 'RestClient'), func_get_args());
     }
     // check for errors
     if ($response->hasErrors()) {
         $errors = Helpers\Functions::buildErrorMessage($response);
         switch ($response->code) {
             case 401:
                 throw new Exception\Unauthorized($errors);
                 break;
             case 404:
                 if (empty($errors)) {
                     $errors = "{$url} wasn't found.";
                 }
                 throw new Exception\NotFound($errors);
                 break;
             default:
                 if (empty($errors) && isset($response->raw_headers)) {
                     list($errors) = explode("\n", $response->raw_headers);
                 }
                 throw new Exception\Api($errors);
         }
     }
     $data = json_decode($response, true);
     if ($data) {
         self::$jsonResponse = $data;
     }
     return $response;
 }
示例#27
-5
 /**
  * @param Request $request
  *
  * @return HttpServer
  */
 public function getHttpServer(Request $request)
 {
     $url = $request->getUri();
     switch ($request->getMethod()) {
         case Request::METHOD_POST:
             $httpServer = HttpServer::post($url);
             break;
         case Request::METHOD_PUT:
             $httpServer = HttpServer::put($url);
             break;
         case Request::METHOD_DELETE:
             $httpServer = HttpServer::delete($url);
             break;
         default:
             $httpServer = HttpServer::get($url);
             break;
     }
     if ($request->headers) {
         $httpServer->addHeaders($request->headers->all());
     }
     if ($request->getUser()) {
         $httpServer->authenticateWith($request->getUser(), $request->getPassword());
     }
     if ($request->getContent()) {
         $httpServer->body($request->getContent());
     }
     return $httpServer;
 }
示例#28
-5
 /**
  * Interface for performing requests to PromisePay endpoints
  *
  * @param string $method required One of the four supported requests methods (get, post, delete, patch)
  * @param string $entity required Endpoint name
  * @param string $payload optional URL encoded data query
  * @param string $mime optional Set specific MIME type. Supported list can be seen here: http://phphttpclient.com/docs/class-Httpful.Mime.html
  */
 public static function RestClient($method, $entity, $payload = null, $mime = null)
 {
     // Check whether critical constants are defined.
     if (!defined(__NAMESPACE__ . '\\API_URL')) {
         die("Fatal error: API_URL constant missing. Check if environment has been set.");
     }
     if (!defined(__NAMESPACE__ . '\\API_LOGIN')) {
         die("Fatal error: API_LOGIN constant missing.");
     }
     if (!defined(__NAMESPACE__ . '\\API_PASSWORD')) {
         die("Fatal error: API_PASSWORD constant missing.");
     }
     if (!is_null($payload)) {
         if (is_array($payload) || is_object($payload)) {
             $payload = http_build_query($payload);
         }
         // if the payload isn't array or object, leave it intact
     }
     $url = constant(__NAMESPACE__ . '\\API_URL') . $entity . '?' . $payload;
     switch ($method) {
         case 'get':
             $response = Request::get($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'post':
             $response = Request::post($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'delete':
             $response = Request::delete($url)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         case 'patch':
             $response = Request::patch($url)->body($payload, $mime)->authenticateWith(constant(__NAMESPACE__ . '\\API_LOGIN'), constant(__NAMESPACE__ . '\\API_PASSWORD'))->send();
             break;
         default:
             throw new Exception\ApiUnsupportedRequestMethod("Unsupported request method {$method}.");
     }
     // check for errors
     if ($response->hasErrors()) {
         $errors = static::buildErrorMessage($response);
         switch ($response->code) {
             case 401:
                 throw new Exception\Unauthorized($errors);
                 break;
             case 404:
                 throw new Exception\NotFound($errors);
             default:
                 throw new Exception\Api($errors);
                 break;
         }
     }
     return $response;
 }
示例#29
-10
 /**
  * {@inheritdoc}
  */
 public function delete($url, $content = '')
 {
     $response = Request::delete()->addHeader("Accept", "application/json")->addHeader('Content-type', "application/json")->addHeader("X-TOKEN", $this->api)->body($content)->send();
     if ($this->isResponseOk($response->code)) {
         return $response->body;
     }
 }