File tree Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Expand file tree Collapse file tree 4 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 1+ ## 8.1.0
2+ - ` RateLimit ` queries ` /rate_limit ` and no longer uses quota
3+
14## 8.0.1
25 - Minor tweaks to improve pub score
36
Original file line number Diff line number Diff line change 11import 'dart:async' ;
2+ import 'dart:convert' ;
23import 'package:github/src/common.dart' ;
34
45/// The [MiscService] handles communication with misc related methods of the
@@ -61,8 +62,8 @@ class MiscService extends Service {
6162 ///
6263 /// API docs: https://developer.github.com/v3/rate_limit/
6364 Future <RateLimit > getRateLimit () {
64- return github.request ('GET' , '/' ).then ((response) {
65- return RateLimit .fromHeaders ( response.headers );
65+ return github.request ('GET' , '/rate_limit ' ).then ((response) {
66+ return RateLimit .fromRateLimitResponse ( jsonDecode ( response.body) );
6667 });
6768 }
6869
Original file line number Diff line number Diff line change @@ -39,6 +39,17 @@ class RateLimit {
3939 return RateLimit (limit, remaining, resets);
4040 }
4141
42+ /// Construct [RateLimit] from JSON response of /rate_limit.
43+ ///
44+ /// API docs: https://developer.github.com/v3/rate_limit/
45+ factory RateLimit .fromRateLimitResponse (Map <String , dynamic > response) {
46+ final rateJson = response['rate' ] as Map <String , dynamic >;
47+ final limit = int .parse (rateJson['limit' ]! );
48+ final remaining = int .parse (rateJson['remaining' ]! );
49+ final resets = DateTime .fromMillisecondsSinceEpoch (rateJson['reset' ]! );
50+ return RateLimit (limit, remaining, resets);
51+ }
52+
4253 factory RateLimit .fromJson (Map <String , dynamic > input) =>
4354 _$RateLimitFromJson (input);
4455 Map <String , dynamic > toJson () => _$RateLimitToJson (this );
Original file line number Diff line number Diff line change 11name : github
2- version : 8.0.1
2+ version : 8.1.0
33description : A high-level GitHub API Client Library that uses Github's v3 API
44homepage : https://github.com/SpinlockLabs/github.dart
55
You can’t perform that action at this time.
0 commit comments