gitlab-org--gitlab-foss/lib/github/client.rb

20 lines
505 B
Ruby
Raw Normal View History

2017-04-11 21:33:54 -04:00
module Github
class Client
attr_reader :connection
2017-04-13 12:59:26 -04:00
def initialize(token = '881a01d03026458e51285a4c7038c9fe4daa5561')
2017-04-11 21:33:54 -04:00
@connection = Faraday.new(url: 'https://api.github.com') do |faraday|
faraday.authorization 'token', token
faraday.adapter :net_http
2017-04-11 21:33:54 -04:00
end
end
def get(url, query = {})
rate_limit = RateLimit.new(connection)
sleep rate_limit.reset_in if rate_limit.exceed?
2017-04-13 12:59:26 -04:00
Github::Response.new(connection.get(url, query))
2017-04-11 21:33:54 -04:00
end
end
end