Exemplo n.º 1
0
 /**
  * {@inheritDoc}
  **/
 public function changeStatus($id, $status, $comment = '')
 {
     $statusId = $this->convertStatusToId($status);
     $params = ['issue' => ['status_id' => $statusId, 'notes' => '<pre>' . $comment . '</pre>']];
     try {
         $this->client->put("/issues/{$id}.json", $params);
     } catch (\Exception $ex) {
         return false;
     }
     return true;
 }
 private function send($endpoint, $operation, $request)
 {
     $pest = new PestJSON($this->url);
     $pest->setupAuth($this->username, $this->password);
     $pest->curl_opts[CURLOPT_FOLLOWLOCATION] = false;
     // Not supported on hosts running safe_mode!
     $pest->curl_opts[CURLOPT_HTTPHEADER] = "Content-Type: application/json";
     $pest->curl_opts[CURLOPT_USERAGENT] = $this->USER_AGENT . " (v" . $this->CLIENT_VERSION . ")";
     $response = "";
     try {
         // Send request to rest service
         switch ($operation) {
             case $this->OP_PUT:
                 $response = $pest->put("/{$endpoint}", $request);
                 break;
             case $this->OP_GET:
                 $response = $pest->get("/{$endpoint}", $request);
                 break;
             case $this->OP_POST:
                 $response = $pest->post("/{$endpoint}", $request);
                 break;
             case $this->OP_DELETE:
                 $response = $pest->delete("/{$endpoint}", $request);
                 break;
         }
     } catch (Exception $e) {
         echo "Caught exception when sending request : " . $e->getMessage();
     }
     return $response;
 }