class M2X::Client::Response

Response wrapper for M2X client

Attributes

response[R]

Public Class Methods

new(response) click to toggle source
# File lib/m2x/response.rb, line 5
def initialize(response)
  @response = response
end

Public Instance Methods

client_error?() click to toggle source
# File lib/m2x/response.rb, line 29
def client_error?
  (400..499).include?(status)
end
error?() click to toggle source
# File lib/m2x/response.rb, line 37
def error?
  client_error? || server_error?
end
headers() click to toggle source
# File lib/m2x/response.rb, line 21
def headers
  @headers ||= @response.to_hash
end
json() click to toggle source
# File lib/m2x/response.rb, line 13
def json
  @json ||= ::JSON.parse(raw)
end
raw() click to toggle source
# File lib/m2x/response.rb, line 9
def raw
  @response.body
end
server_error?() click to toggle source
# File lib/m2x/response.rb, line 33
def server_error?
  (500..599).include?(status)
end
status() click to toggle source
# File lib/m2x/response.rb, line 17
def status
  @status ||= @response.code.to_i
end
success?() click to toggle source
# File lib/m2x/response.rb, line 25
def success?
  (200..299).include?(status)
end