@@ -124,7 +124,7 @@ class IssuesService extends Service {
124
124
return PaginationHelper (github).objects (
125
125
'GET' ,
126
126
pathSegment,
127
- Issue .fromJSON ,
127
+ (i) => Issue .fromJson (i) ,
128
128
params: params,
129
129
);
130
130
}
@@ -136,9 +136,9 @@ class IssuesService extends Service {
136
136
RepositorySlug slug, int issueNumber, IssueRequest issue) async {
137
137
return github
138
138
.request ('PATCH' , '/repos/${slug .fullName }/issues/$issueNumber ' ,
139
- body: issue. toJSON ( ))
139
+ body: jsonEncode (issue ))
140
140
.then <Issue >((response) {
141
- return Issue .fromJSON (jsonDecode (response.body) as Map <String , dynamic >);
141
+ return Issue .fromJson (jsonDecode (response.body) as Map <String , dynamic >);
142
142
});
143
143
}
144
144
@@ -147,7 +147,7 @@ class IssuesService extends Service {
147
147
/// API docs: https://developer.github.com/v3/issues/#get-a-single-issue
148
148
Future <Issue > get (RepositorySlug slug, int issueNumber) =>
149
149
github.getJSON ('/repos/${slug .fullName }/issues/$issueNumber ' ,
150
- convert: Issue .fromJSON );
150
+ convert: (i) => Issue .fromJson (i) );
151
151
152
152
/// Create an issue.
153
153
///
@@ -156,24 +156,24 @@ class IssuesService extends Service {
156
156
final response = await github.request (
157
157
'POST' ,
158
158
'/repos/${slug .fullName }/issues' ,
159
- body: issue. toJSON ( ),
159
+ body: jsonEncode (issue ),
160
160
);
161
161
162
162
if (StatusCodes .isClientError (response.statusCode)) {
163
163
//TODO: throw a more friendly error – better this than silent failure
164
164
throw GitHubError (github, response.body);
165
165
}
166
166
167
- return Issue .fromJSON (jsonDecode (response.body) as Map <String , dynamic >);
167
+ return Issue .fromJson (jsonDecode (response.body) as Map <String , dynamic >);
168
168
}
169
169
170
170
/// Lists all available assignees (owners and collaborators) to which issues
171
171
/// may be assigned.
172
172
///
173
173
/// API docs: https://developer.github.com/v3/issues/assignees/#list-assignees
174
174
Stream <User > listAssignees (RepositorySlug slug) {
175
- return PaginationHelper (github)
176
- . objects ( 'GET' , '/repos/${slug .fullName }/assignees' , User .fromJson);
175
+ return PaginationHelper (github). objects (
176
+ 'GET' , '/repos/${slug .fullName }/assignees' , (i) => User .fromJson (i) );
177
177
}
178
178
179
179
/// Checks if a user is an assignee for the specified repository.
@@ -193,23 +193,25 @@ class IssuesService extends Service {
193
193
return PaginationHelper (github).objects (
194
194
'GET' ,
195
195
'/repos/${slug .fullName }/issues/$issueNumber /comments' ,
196
- IssueComment .fromJSON );
196
+ (i) => IssueComment .fromJson (i) );
197
197
}
198
198
199
199
/// Lists all comments in a repository.
200
200
///
201
201
/// API docs: https://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
202
202
Stream <IssueComment > listCommentsByRepo (RepositorySlug slug) {
203
- return PaginationHelper (github).objects ('GET' ,
204
- '/repos/${slug .fullName }/issues/comments' , IssueComment .fromJSON);
203
+ return PaginationHelper (github).objects (
204
+ 'GET' ,
205
+ '/repos/${slug .fullName }/issues/comments' ,
206
+ (i) => IssueComment .fromJson (i));
205
207
}
206
208
207
209
/// Fetches the specified issue comment.
208
210
///
209
211
/// API docs: https://developer.github.com/v3/issues/comments/#get-a-single-comment
210
212
Future <IssueComment > getComment (RepositorySlug slug, int id) =>
211
213
github.getJSON ('/repos/${slug .fullName }/issues/comments/$id ' ,
212
- convert: IssueComment .fromJSON );
214
+ convert: (i) => IssueComment .fromJson (i) );
213
215
214
216
/// Creates a new comment on the specified issue
215
217
///
@@ -220,7 +222,7 @@ class IssuesService extends Service {
220
222
return github.postJSON (
221
223
'/repos/${slug .fullName }/issues/$issueNumber /comments' ,
222
224
body: it,
223
- convert: IssueComment .fromJSON ,
225
+ convert: (i) => IssueComment .fromJson (i) ,
224
226
statusCode: StatusCodes .CREATED ,
225
227
);
226
228
}
@@ -242,16 +244,16 @@ class IssuesService extends Service {
242
244
///
243
245
/// API docs: https://developer.github.com/v3/issues/labels/#list-all-labels-for-this-repository
244
246
Stream <IssueLabel > listLabels (RepositorySlug slug) {
245
- return PaginationHelper (github)
246
- . objects ( 'GET' , '/repos/${slug .fullName }/labels' , IssueLabel .fromJSON );
247
+ return PaginationHelper (github). objects (
248
+ 'GET' , '/repos/${slug .fullName }/labels' , (i) => IssueLabel .fromJson (i) );
247
249
}
248
250
249
251
/// Fetches a single label.
250
252
///
251
253
/// API docs: https://developer.github.com/v3/issues/labels/#get-a-single-label
252
254
Future <IssueLabel > getLabel (RepositorySlug slug, String name) =>
253
255
github.getJSON ('/repos/${slug .fullName }/labels/$name ' ,
254
- convert: IssueLabel .fromJSON , statusCode: StatusCodes .OK );
256
+ convert: (i) => IssueLabel .fromJson (i) , statusCode: StatusCodes .OK );
255
257
256
258
/// Creates a new label on the specified repository.
257
259
///
@@ -260,7 +262,7 @@ class IssuesService extends Service {
260
262
RepositorySlug slug, String name, String color) {
261
263
return github.postJSON ('/repos/${slug .fullName }/labels' ,
262
264
body: jsonEncode ({'name' : name, 'color' : color}),
263
- convert: IssueLabel .fromJSON );
265
+ convert: (i) => IssueLabel .fromJson (i) );
264
266
}
265
267
266
268
/// Edits a label.
@@ -269,7 +271,7 @@ class IssuesService extends Service {
269
271
Future <IssueLabel > editLabel (RepositorySlug slug, String name, String color) {
270
272
return github.postJSON ('/repos/${slug .fullName }/labels/$name ' ,
271
273
body: jsonEncode ({'name' : name, 'color' : color}),
272
- convert: IssueLabel .fromJSON );
274
+ convert: (i) => IssueLabel .fromJson (i) );
273
275
}
274
276
275
277
/// Deletes a label.
@@ -289,7 +291,7 @@ class IssuesService extends Service {
289
291
return PaginationHelper (github).objects (
290
292
'GET' ,
291
293
'/repos/${slug .fullName }/issues/$issueNumber /labels' ,
292
- IssueLabel .fromJSON );
294
+ (i) => IssueLabel .fromJson (i) );
293
295
}
294
296
295
297
/// Adds labels to an issue.
@@ -300,8 +302,10 @@ class IssuesService extends Service {
300
302
return github.postJSON <List <dynamic >, List <IssueLabel >>(
301
303
'/repos/${slug .fullName }/issues/$issueNumber /labels' ,
302
304
body: jsonEncode (labels),
303
- convert: (input) =>
304
- input.cast <Map <String , dynamic >>().map (IssueLabel .fromJSON).toList (),
305
+ convert: (input) => input
306
+ .cast <Map <String , dynamic >>()
307
+ .map ((i) => IssueLabel .fromJson (i))
308
+ .toList (),
305
309
);
306
310
}
307
311
@@ -315,7 +319,7 @@ class IssuesService extends Service {
315
319
body: jsonEncode (labels))
316
320
.then ((response) {
317
321
return jsonDecode (response.body)
318
- .map ((Map <String , dynamic > it) => IssueLabel .fromJSON (it));
322
+ .map ((Map <String , dynamic > it) => IssueLabel .fromJson (it));
319
323
});
320
324
}
321
325
@@ -345,8 +349,8 @@ class IssuesService extends Service {
345
349
///
346
350
/// API docs: https://developer.github.com/v3/issues/milestones/#list-milestones-for-a-repository
347
351
Stream <Milestone > listMilestones (RepositorySlug slug) {
348
- return PaginationHelper (github).objects (
349
- 'GET' , ' /repos/${slug .fullName }/milestones' , Milestone .fromJSON );
352
+ return PaginationHelper (github).objects ('GET' ,
353
+ '/repos/${slug .fullName }/milestones' , (i) => Milestone .fromJson (i) );
350
354
}
351
355
352
356
// TODO: Implement getMilestone: https://developer.github.com/v3/issues/milestones/#get-a-single-milestone
@@ -357,7 +361,7 @@ class IssuesService extends Service {
357
361
Future <Milestone > createMilestone (
358
362
RepositorySlug slug, CreateMilestone request) {
359
363
return github.postJSON ('/repos/${slug .fullName }/milestones' ,
360
- body: jsonEncode (request. toJSON ()) , convert: Milestone .fromJSON );
364
+ body: jsonEncode (request) , convert: (i) => Milestone .fromJson (i) );
361
365
}
362
366
363
367
// TODO: Implement editMilestone: https://developer.github.com/v3/issues/milestones/#update-a-milestone
0 commit comments