10 defined(
'JPATH_PLATFORM') or die;
36 public function getList($user, $repo, $state =
'open', $sort =
'due_date', $direction =
'desc', $page = 0, $limit = 0)
39 $path =
'/repos/' . $user .
'/' . $repo .
'/milestones?';
41 $path .=
'state=' . $state;
42 $path .=
'&sort=' . $sort;
43 $path .=
'&direction=' . $direction;
46 $response = $this->client->get($this->fetchUrl($path, $page, $limit));
49 if ($response->code != 200)
52 $error = json_decode($response->body);
53 throw new DomainException($error->message, $response->code);
56 return json_decode($response->body);
70 public function get($user, $repo, $milestoneId)
73 $path =
'/repos/' . $user .
'/' . $repo .
'/milestones/' . (int) $milestoneId;
76 $response = $this->client->get($this->fetchUrl($path));
79 if ($response->code != 200)
82 $error = json_decode($response->body);
83 throw new DomainException($error->message, $response->code);
86 return json_decode($response->body);
103 public function create($user, $repo, $title, $state = null, $description = null, $due_on = null)
106 $path =
'/repos/' . $user .
'/' . $repo .
'/milestones';
113 if (!is_null($state))
115 $data[
'state'] = $state;
118 if (!is_null($description))
120 $data[
'description'] = $description;
123 if (!is_null($due_on))
125 $data[
'due_on'] = $due_on;
128 $data = json_encode($data);
131 $response = $this->client->post($this->fetchUrl($path), $data);
134 if ($response->code != 201)
137 $error = json_decode($response->body);
138 throw new DomainException($error->message, $response->code);
141 return json_decode($response->body);
159 public function edit($user, $repo, $milestoneId, $title = null, $state = null, $description = null, $due_on = null)
162 $path =
'/repos/' . $user .
'/' . $repo .
'/milestones/' . (int) $milestoneId;
167 if (!is_null($title))
169 $data[
'title'] = $title;
172 if (!is_null($state))
174 $data[
'state'] = $state;
177 if (!is_null($description))
179 $data[
'description'] = $description;
182 if (!is_null($due_on))
184 $data[
'due_on'] = $due_on;
187 $data = json_encode($data);
190 $response = $this->client->patch($this->fetchUrl($path), $data);
193 if ($response->code != 200)
196 $error = json_decode($response->body);
197 throw new DomainException($error->message, $response->code);
200 return json_decode($response->body);
214 public function delete($user, $repo, $milestoneId)
217 $path =
'/repos/' . $user .
'/' . $repo .
'/milestones/' . (int) $milestoneId;
220 $response = $this->client->delete($this->fetchUrl($path));
223 if ($response->code != 204)
226 $error = json_decode($response->body);
227 throw new DomainException($error->message, $response->code);