File tree 4 files changed +18
-3
lines changed
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
+
1
4
## 8.0.1
2
5
- Minor tweaks to improve pub score
3
6
Original file line number Diff line number Diff line change 1
1
import 'dart:async' ;
2
+ import 'dart:convert' ;
2
3
import 'package:github/src/common.dart' ;
3
4
4
5
/// The [MiscService] handles communication with misc related methods of the
@@ -61,8 +62,8 @@ class MiscService extends Service {
61
62
///
62
63
/// API docs: https://developer.github.com/v3/rate_limit/
63
64
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) );
66
67
});
67
68
}
68
69
Original file line number Diff line number Diff line change @@ -39,6 +39,17 @@ class RateLimit {
39
39
return RateLimit (limit, remaining, resets);
40
40
}
41
41
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
+
42
53
factory RateLimit .fromJson (Map <String , dynamic > input) =>
43
54
_$RateLimitFromJson (input);
44
55
Map <String , dynamic > toJson () => _$RateLimitToJson (this );
Original file line number Diff line number Diff line change 1
1
name : github
2
- version : 8.0.1
2
+ version : 8.1.0
3
3
description : A high-level GitHub API Client Library that uses Github's v3 API
4
4
homepage : https://github.com/SpinlockLabs/github.dart
5
5
You can’t perform that action at this time.
0 commit comments