diff options
Diffstat (limited to 'lib/github/client.rb')
-rw-r--r-- | lib/github/client.rb | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/github/client.rb b/lib/github/client.rb new file mode 100644 index 00000000000..2511523bf6a --- /dev/null +++ b/lib/github/client.rb @@ -0,0 +1,21 @@ +module Github + class Client + attr_reader :connection + + def initialize(token) + @connection = Faraday.new(url: 'https://api.github.com') do |faraday| + faraday.adapter :net_http_persistent + faraday.response :json, content_type: /\bjson$/ + faraday.authorization 'token', token + faraday.response :logger + end + end + + def get(url, query = {}) + rate_limit = RateLimit.new(connection) + sleep rate_limit.reset_in if rate_limit.exceed? + + Github::Response.new(connection.get(url, query)) + end + end +end |