10 defined(
'JPATH_PLATFORM') or die;
27 protected $events = array(
28 'push',
'issues',
'issue_comment',
'commit_comment',
'pull_request',
'gollum',
'watch',
'download',
'fork',
'fork_apply',
29 'member',
'public',
'status'
48 public function create($user, $repo, $name, array $config, array $events = array(
'push'), $active =
true)
51 $path =
'/repos/' . $user .
'/' . $repo .
'/hooks';
54 foreach ($events as $event)
56 if (!in_array($event, $this->events))
58 throw new RuntimeException(
'Your events array contains an unauthorized event.');
63 array(
'name' => $name,
'config' => $config,
'events' => $events,
'active' => $active)
66 return $this->processResponse(
67 $this->client->post($this->fetchUrl($path), $data),
84 public function delete($user, $repo, $id)
87 $path =
'/repos/' . $user .
'/' . $repo .
'/hooks/' . $id;
89 return $this->processResponse(
90 $this->client->delete($this->fetchUrl($path)),
114 public function edit($user, $repo, $id, $name, array $config, array $events = array(
'push'), array $addEvents = array(),
115 array $removeEvents = array(), $active =
true)
118 foreach ($events as $event)
120 if (!in_array($event, $this->events))
122 throw new RuntimeException(
'Your events array contains an unauthorized event.');
126 foreach ($addEvents as $event)
128 if (!in_array($event, $this->events))
130 throw new RuntimeException(
'Your active_events array contains an unauthorized event.');
134 foreach ($removeEvents as $event)
136 if (!in_array($event, $this->events))
138 throw new RuntimeException(
'Your remove_events array contains an unauthorized event.');
142 $path =
'/repos/' . $user .
'/' . $repo .
'/hooks/' . $id;
149 'add_events' => $addEvents,
150 'remove_events' => $removeEvents,
154 return $this->processResponse(
155 $this->client->patch($this->fetchUrl($path), $data)
171 public function get($user, $repo, $id)
174 $path =
'/repos/' . $user .
'/' . $repo .
'/hooks/' . $id;
176 return $this->processResponse(
177 $this->client->get($this->fetchUrl($path))
194 public function getList($user, $repo, $page = 0, $limit = 0)
197 $path =
'/repos/' . $user .
'/' . $repo .
'/hooks';
199 return $this->processResponse(
200 $this->client->get($this->fetchUrl($path))
216 public function test($user, $repo, $id)
219 $path =
'/repos/' . $user .
'/' . $repo .
'/hooks/' . $id .
'/test';
221 return $this->processResponse(
222 $this->client->post($this->fetchUrl($path), json_encode(
'')),