Module: RestClientWrapper::Http

Included in:
RestClient
Defined in:
lib/rest_client_wrapper/http.rb

Overview

Http

Constant Summary collapse

SUCCESS_STATUS_CODES =
{
  200 => "OK",
  201 => "Created",
  202 => "Accepted",
  203 => "Non-Authoritative Information",
  205 => "No Content",
  206 => "Partial Content",
  207 => "Multi-Status"
}.freeze

Class Method Summary collapse

Class Method Details

.bad_request?(code) ⇒ Boolean

400

Returns:

  • (Boolean)


45
46
47
# File 'lib/rest_client_wrapper/http.rb', line 45

def self.bad_request?(code)
  return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:bad_request]
end

.not_found?(code) ⇒ Boolean

404

Returns:

  • (Boolean)


55
56
57
# File 'lib/rest_client_wrapper/http.rb', line 55

def self.not_found?(code)
  return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:not_found]
end

.ok?(code) ⇒ Boolean

200

Returns:

  • (Boolean)


40
41
42
# File 'lib/rest_client_wrapper/http.rb', line 40

def self.ok?(code)
  return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:ok]
end

.success?(code) ⇒ Boolean

success

Returns:

  • (Boolean)


35
36
37
# File 'lib/rest_client_wrapper/http.rb', line 35

def self.success?(code)
  return SUCCESS_STATUS_CODES[code].nil? ? false : true
end

.too_many_requests?(code) ⇒ Boolean

429

Returns:

  • (Boolean)


60
61
62
# File 'lib/rest_client_wrapper/http.rb', line 60

def self.too_many_requests?(code)
  return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:too_many_requests]
end

.unauthorized?(code) ⇒ Boolean

401

Returns:

  • (Boolean)


50
51
52
# File 'lib/rest_client_wrapper/http.rb', line 50

def self.unauthorized?(code)
  return code == Rack::Utils::SYMBOL_TO_STATUS_CODE[:unauthorized]
end