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.



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

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

Instance Attribute Details

#responseObject

Returns the value of attribute response.



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

def response
  @response
end

Instance Method Details

#failure?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/go_api_client/http_fetcher.rb', line 74

def failure?
  !success?
end

#statusObject



66
67
68
# File 'lib/go_api_client/http_fetcher.rb', line 66

def status
  @response.code.to_i
end

#success?Boolean

Returns:

  • (Boolean)


70
71
72
# File 'lib/go_api_client/http_fetcher.rb', line 70

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