Class: Gitrob::Github::HttpClient
- Inherits:
-
Object
- Object
- Gitrob::Github::HttpClient
show all
- Includes:
- HTTParty
- Defined in:
- lib/gitrob/github/http_client.rb
Defined Under Namespace
Classes: AccessTokenError, AccessTokensDepletedError, ClientError, ConnectionError, HttpError, MissingAccessTokensError, RequestError, Response, ServerError, UnhandledError
Constant Summary
collapse
- DEFAULT_TIMEOUT =
0.5
- DEFAULT_RETRIES =
3
- RETRIABLE_EXCEPTIONS =
[
ServerError,
AccessTokenError,
Timeout::Error,
Errno::ETIMEDOUT,
Errno::ECONNRESET,
Errno::ECONNREFUSED,
Errno::ENETUNREACH,
Errno::EHOSTUNREACH,
EOFError
]
Instance Method Summary
collapse
Constructor Details
#initialize(options) ⇒ HttpClient
Returns a new instance of HttpClient.
45
46
47
48
49
50
51
52
|
# File 'lib/gitrob/github/http_client.rb', line 45
def initialize(options)
@config = {
:timeout => DEFAULT_TIMEOUT,
:retries => DEFAULT_RETRIES
}.merge(options)
raise MissingAccessTokensErrors.new("No access tokens given") unless @config[:access_tokens]
default_timeout = @config[:timeout]
end
|
Instance Method Details
#do_delete(path, params = nil, options = {}) ⇒ Object
66
67
68
|
# File 'lib/gitrob/github/http_client.rb', line 66
def do_delete(path, params=nil, options={})
do_request(:delete, path, {:query => params}.merge(options))
end
|
#do_get(path, params = nil, options = {}) ⇒ Object
54
55
56
|
# File 'lib/gitrob/github/http_client.rb', line 54
def do_get(path, params=nil, options={})
do_request(:get, path, {:query => params}.merge(options))
end
|
#do_post(path, params = nil, options = {}) ⇒ Object
58
59
60
|
# File 'lib/gitrob/github/http_client.rb', line 58
def do_post(path, params=nil, options={})
do_request(:post, path, {:query => params}.merge(options))
end
|
#do_put(path, params = nil, options = {}) ⇒ Object
62
63
64
|
# File 'lib/gitrob/github/http_client.rb', line 62
def do_put(path, params=nil, options={})
do_request(:put, path, {:query => params}.merge(options))
end
|