10 defined(
'JPATH_PLATFORM') or die;
35 public function create($user, $repo, $sha, $state, $targetUrl = null, $description = null)
38 $path =
'/repos/' . $user .
'/' . $repo .
'/statuses/' . $sha;
40 if (!in_array($state, array(
'pending',
'success',
'error',
'failure')))
42 throw new InvalidArgumentException(
'State must be one of pending, success, error or failure.');
50 if (!is_null($targetUrl))
52 $data[
'target_url'] = $targetUrl;
55 if (!is_null($description))
57 $data[
'description'] = $description;
61 $response = $this->client->post($this->fetchUrl($path), json_encode($data));
64 if ($response->code != 201)
67 $error = json_decode($response->body);
68 throw new DomainException($error->message, $response->code);
71 return json_decode($response->body);
85 public function getList($user, $repo, $sha)
88 $path =
'/repos/' . $user .
'/' . $repo .
'/statuses/' . $sha;
91 $response = $this->client->get($this->fetchUrl($path));
94 if ($response->code != 200)
97 $error = json_decode($response->body);
98 throw new DomainException($error->message, $response->code);
101 return json_decode($response->body);