Class: GoApiClient::HttpFetcher

Inherits:
Object
  • Object
show all
Defined in:
lib/go_api_client/http_fetcher.rb

Defined Under Namespace

Classes: ConnectionError, HttpError

Constant Summary collapse

NET_HTTP_EXCEPTIONS =
[
    EOFError,
    Errno::ECONNABORTED,
    Errno::ECONNREFUSED,
    Errno::ECONNRESET,
    Errno::ECONNRESET, EOFError,
    Errno::EINVAL,
    Errno::ETIMEDOUT,
    Net::HTTPBadResponse,
    Net::HTTPClientError,
    Net::HTTPError,
    Net::HTTPFatalError,
    Net::HTTPHeaderSyntaxError,
    Net::HTTPRetriableError,
    Net::HTTPServerException,
    Net::ProtocolError,
    SocketError,
    Timeout::Error,
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ HttpFetcher

Returns a new instance of HttpFetcher.



43
44
45
46
47
# File 'lib/go_api_client/http_fetcher.rb', line 43

def initialize(options={})
  @username = options[:username]
  @password = options[:password]
  @ssl_verify_mode = options[:ssl_verify_mode]
end

Instance Attribute Details

#responseObject

Returns the value of attribute response.



41
42
43
# File 'lib/go_api_client/http_fetcher.rb', line 41

def response
  @response
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


76
77
78
# File 'lib/go_api_client/http_fetcher.rb', line 76

def failure?
  !success?
end

#statusObject



68
69
70
# File 'lib/go_api_client/http_fetcher.rb', line 68

def status
  @response.code.to_i
end

#success?Boolean

Returns:

  • (Boolean)


72
73
74
# File 'lib/go_api_client/http_fetcher.rb', line 72

def success?
  (200..299).include?(status)
end