Skip to content
This repository was archived by the owner on Jul 28, 2022. It is now read-only.

Commit d717bbc

Browse files
committed
adding more API coverage
1 parent 493b831 commit d717bbc

File tree

20 files changed

+1683
-132
lines changed

20 files changed

+1683
-132
lines changed

lib/GitHub/API/Event/Event.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
namespace GitHub\API\Event;
4+
5+
use GitHub\API\Api;
6+
use GitHub\API\ApiException;
7+
use GitHub\API\AuthenticationException;
8+
9+
/**
10+
* Github Events
11+
*
12+
* @link http://developer.github.com/v3/issues/events/
13+
* @author dsyph3r <d.syph.3r@gmail.com>
14+
*/
15+
abstract class Key extends Api
16+
{
17+
/**
18+
* List events
19+
*
20+
* Authentication Required: false|true
21+
*
22+
* @param string $url API resource URL
23+
* @return array|bool List of events or FALSE if the request failed
24+
*/
25+
protected function _all($url)
26+
{
27+
return $this->processResponse(
28+
$this->requestGet($url)
29+
);
30+
}
31+
32+
/**
33+
* Get event
34+
*
35+
* Authentication Required: false|true
36+
*
37+
* @param string $username User GitHub username
38+
* @param string $repo Repo name
39+
* @param int $id ID of event
40+
* @return array|bool The key or FALSE if key could not
41+
* be found
42+
*/
43+
protected function get($username, $repo, $id)
44+
{
45+
return $this->processResponse(
46+
$this->requestGet("repos/$username/$repo/issues/events/$id")
47+
);
48+
}
49+
}

lib/GitHub/API/Gist/Comment.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,6 @@ class Comment extends Api
2626
*
2727
* Authentication Required: false|true
2828
*
29-
* @todo Test
30-
*
3129
* @link http://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
3230
*
3331
* @param int $gistId ID of gist
@@ -50,8 +48,6 @@ public function all($gistId, $format = self::FORMAT_RAW)
5048
*
5149
* Authentication Required: false|true
5250
*
53-
* @todo Test
54-
*
5551
* @link http://developer.github.com/v3/gists/comments/#get-a-single-comment
5652
*
5753
* @param int $id ID of comment
@@ -71,8 +67,6 @@ public function get($id, $format = self::FORMAT_RAW)
7167
*
7268
* Authentication Required: true
7369
*
74-
* @todo Test
75-
*
7670
* @link http://developer.github.com/v3/gists/comments/#create-a-comment
7771
*
7872
* @param int $gistId ID of gist
@@ -96,8 +90,6 @@ public function create($gistId, $body, $format = self::FORMAT_RAW)
9690
*
9791
* Authentication Required: true
9892
*
99-
* @todo Test
100-
*
10193
* @link http://developer.github.com/v3/gists/comments/#edit-a-comment
10294
*
10395
* @param int $id ID of gist
@@ -120,9 +112,7 @@ public function update($id, $body, $format = self::FORMAT_RAW)
120112
* Delete a gist comment
121113
*
122114
* Authentication Required: true
123-
*
124-
* @todo Test
125-
*
115+
*
126116
* @link http://developer.github.com/v3/gists/comments/#delete-a-comment
127117
*
128118
* @param int $id ID of comment

lib/GitHub/API/Gist/Gist.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Gist extends Api
2626
*
2727
* @var Comment
2828
*/
29-
protected $comments = null;
29+
protected $comment = null;
3030

3131
/**
3232
* List gists

lib/GitHub/API/Issue/Comment.php

Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
<?php
2+
3+
namespace GitHub\API\Issue;
4+
5+
use GitHub\API\Api;
6+
use GitHub\API\ApiException;
7+
use GitHub\API\AuthenticationException;
8+
9+
/**
10+
* Issue comment
11+
*
12+
* @link http://developer.github.com/v3/issues/comments/
13+
* @author dsyph3r <d.syph.3r@gmail.com>
14+
*/
15+
class Comment extends Api
16+
{
17+
/**
18+
* Constant for GitHub resource mime type identifier
19+
*
20+
* @link http://developer.github.com/v3/issues/comments/#custom-mime-types
21+
*/
22+
const MIME_TYPE_RESOURCE = 'issuecomment';
23+
24+
/**
25+
* List comments for issue
26+
*
27+
* Authentication Required: false|true
28+
*
29+
* @link http://developer.github.com/v3/repos/issues/#list-comments-on-an-issue
30+
*
31+
* @param string $username User GitHub username
32+
* @param string $repo Repo name
33+
* @param int $issueId Id of issue
34+
* @param string $format Response format of comment
35+
* FORMAT_RAW|FORMAT_TEXT|FORMAT_HTML|FORMAT_FULL
36+
* @return array List of comments for issue or FALSE if
37+
* comments could not be retrieved for issue
38+
*/
39+
public function all($username, $repo, $issueId = null, $format = self::FORMAT_RAW)
40+
{
41+
$url = "repos/$username/$repo/issues/$issueId/comments";
42+
43+
return $this->processResponse(
44+
$this->requestGet($url, array(), $this->setResponseFormatOptions($format, self::MIME_TYPE_RESOURCE, array()))
45+
);
46+
}
47+
48+
/**
49+
* Get an issue comment
50+
*
51+
* Authentication Required: false|true
52+
*
53+
* @link http://developer.github.com/v3/repos/issues/#get-a-single-comment
54+
*
55+
* @param string $username User GitHub username
56+
* @param string $repo Repo name
57+
* @param int $id ID of comment
58+
* @param string $format Response format of comment
59+
* FORMAT_RAW|FORMAT_TEXT|FORMAT_HTML|FORMAT_FULL
60+
* @return array|bool Details of the comment or FALSE if the request failed
61+
*/
62+
public function get($username, $repo, $id, $format = self::FORMAT_RAW)
63+
{
64+
$options = $this->setResponseFormatOptions($format, self::MIME_TYPE_RESOURCE, array());
65+
66+
return $this->processResponse(
67+
$this->requestGet("repos/$username/$repo/issues/comments/$id", array(), $options)
68+
);
69+
}
70+
71+
/**
72+
* Create an issue comment
73+
*
74+
* Authentication Required: true
75+
*
76+
* @link http://developer.github.com/v3/repos/issues/#create-a-comment
77+
*
78+
* @param string $username User GitHub username
79+
* @param string $repo Repo name
80+
* @param int $issueId Id of issue
81+
* @param string $body The comment body
82+
* @param string $format Response format of comment
83+
* FORMAT_RAW|FORMAT_TEXT|FORMAT_HTML|FORMAT_FULL
84+
* @return array Details of the created comment or FALSE if
85+
* comment failed to create
86+
*/
87+
public function create($username, $repo, $issueId, $body, $format = self::FORMAT_RAW)
88+
{
89+
$details = array('body' => $body);
90+
91+
$options = $this->setResponseFormatOptions($format, self::MIME_TYPE_RESOURCE, array());
92+
93+
return $this->processResponse(
94+
$this->requestPost("repos/$username/$repo/issues/$issueId/comments", $details, $options)
95+
);
96+
}
97+
98+
/**
99+
* Edit an issue comment
100+
*
101+
* Authentication Required: true
102+
*
103+
* @link http://developer.github.com/v3/repos/issues/#edit-a-comment
104+
*
105+
* @param string $username User GitHub username
106+
* @param string $repo Repo name
107+
* @param int $id ID of issue
108+
* @param string $body The comment body
109+
* @param string $format Response format of comment
110+
* FORMAT_RAW|FORMAT_TEXT|FORMAT_HTML|FORMAT_FULL
111+
* @return array Details of the updated comment or FALSE if
112+
* comment failed to update
113+
*/
114+
public function update($username, $repo, $id, $body, $format = self::FORMAT_RAW)
115+
{
116+
$details = array('body' => $body);
117+
118+
$options = $this->setResponseFormatOptions($format, self::MIME_TYPE_RESOURCE, array());
119+
120+
return $this->processResponse(
121+
$this->requestPatch("repos/$username/$repo/issues/comments/$id", $details, $options)
122+
);
123+
}
124+
125+
/**
126+
* Delete an issue comment
127+
*
128+
* Authentication Required: true
129+
*
130+
* @link http://developer.github.com/v3/repos/issues/#delete-a-comment
131+
*
132+
* @param string $username User GitHub username
133+
* @param string $repo Repo name
134+
* @param int $id ID of comment
135+
* @param bool Returns TRUE if issue comment was deleted
136+
*/
137+
public function delete($username, $repo, $id)
138+
{
139+
return $this->processResponse(
140+
$this->requestDelete("repos/$username/$repo/issues/comments/$id")
141+
);
142+
}
143+
}

lib/GitHub/API/Issue/Event.php

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
namespace GitHub\API\Issue;
4+
5+
use GitHub\API\Api;
6+
use GitHub\API\ApiException;
7+
use GitHub\API\AuthenticationException;
8+
9+
/**
10+
* Issue event
11+
*
12+
* @link http://developer.github.com/v3/issues/events/
13+
* @author dsyph3r <d.syph.3r@gmail.com>
14+
*/
15+
class Event extends \GitHub\API\Event\Event
16+
{
17+
/**
18+
* List events for repo
19+
*
20+
* Authentication Required: false|true
21+
*
22+
* @link http://developer.github.com/v3/issues/events/#list-events-for-an-issue
23+
*
24+
* @param string $username GitHub username of repo owner
25+
* @param string $repo Repo name
26+
* @param int $issueId ID of issue
27+
* @return array List of events
28+
*/
29+
public function all($usename, $repo, $issueId)
30+
{
31+
return $this->_all("repos/$username/$repo/issues/$issueId/events");
32+
}
33+
}

lib/GitHub/API/Issue/Label.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace GitHub\API\Issue;
4+
5+
use GitHub\API\Api;
6+
use GitHub\API\ApiException;
7+
use GitHub\API\AuthenticationException;
8+
9+
/**
10+
* Issue label
11+
*
12+
* @link http://developer.github.com/v3/issues/labels/
13+
* @author dsyph3r <d.syph.3r@gmail.com>
14+
*/
15+
class Label extends Api {}

0 commit comments

Comments
 (0)