@@ -107,6 +107,63 @@ class Gist extends Requestable {
107
107
isStarred ( cb ) {
108
108
return this . _request204or404 ( `/gists/${ this . __id } /star` , null , cb ) ;
109
109
}
110
+
111
+
112
+
113
+ /**
114
+ * List the comments on a gist
115
+ * @see https://developer.github.com/v3/gists/comments/#list-comments-on-a-gist
116
+ * @param {Requestable.callback } [cb] - will receive the array of comments
117
+ * @return {Promise } - the promise for the http request
118
+ */
119
+ listComments ( cb ) {
120
+ return this . _requestAllPages ( `/gists/${ this . __id } /comments` , null , cb ) ;
121
+ }
122
+
123
+ /**
124
+ * Fetch a comment of the gist
125
+ * @see https://developer.github.com/v3/gists/comments/#get-a-single-comment
126
+ * @param {number } comment - the id of the comment
127
+ * @param {Requestable.callback } [cb] - will receive the comment
128
+ * @return {Promise } - the Promise for the http request
129
+ */
130
+ getComment ( comment , cb ) {
131
+ return this . _request ( 'GET' , `/gists/${ this . __id } /comments/${ comment } ` , null , cb ) ;
132
+ }
133
+
134
+ /**
135
+ * Create Comment to a gist.
136
+ * @see https://developer.github.com/v3/gists/comments/#create-a-comment
137
+ * @param {string } comment - the comment to add
138
+ * @param {Requestable.callback } [cb] - the function that receives the API result
139
+ * @return {Promise } - the Promise for the http request
140
+ */
141
+ createComment ( comment , cb ) {
142
+ return this . _request ( 'POST' , `/gists/${ this . __id } /comments` , { body : comment } , cb ) ;
143
+ }
144
+
145
+ /**
146
+ * Edit a Gist Comment
147
+ * @see https://developer.github.com/v3/gists/comments/#edit-a-comment
148
+ * @param {number } comment - the id of the comment
149
+ * @param {string } body - the new comment
150
+ * @param {Requestable.callback } [cb] - will receive the modified issue
151
+ * @return {Promise } - the promise for the http request
152
+ */
153
+ editComment ( comment , body , cb ) {
154
+ return this . _request ( 'PATCH' , `/gists/${ this . __id } /comments/${ comment } ` , { body : body } , cb ) ;
155
+ }
156
+
157
+ /**
158
+ * Delete a comment of a gist.
159
+ * @see https://developer.github.com/v3/gists/comments/#delete-a-comment
160
+ * @param {number } comment - the id of the comment
161
+ * @param {Requestable.callback } [cb] - will receive true if the request succeeds
162
+ * @return {Promise } - the Promise for the http request
163
+ */
164
+ deleteComment ( comment , cb ) {
165
+ return this . _request ( 'DELETE' , `/gists/${ this . __id } /comments/${ comment } ` , null , cb ) ;
166
+ }
110
167
}
111
168
112
169
module . exports = Gist ;
0 commit comments