Class: Idsimple::Rack::Api::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/idsimple/rack/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Result

Returns a new instance of Result.



48
49
50
# File 'lib/idsimple/rack/api.rb', line 48

def initialize(response)
  @response = response
end

Instance Attribute Details

#responseObject (readonly)

Returns the value of attribute response.



46
47
48
# File 'lib/idsimple/rack/api.rb', line 46

def response
  @response
end

Instance Method Details

#bodyObject



64
65
66
# File 'lib/idsimple/rack/api.rb', line 64

def body
  @body ||= JSON.parse(response.body) if response.body
end

#fail?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/idsimple/rack/api.rb', line 56

def fail?
  !success?
end

#full_error_messageObject



68
69
70
# File 'lib/idsimple/rack/api.rb', line 68

def full_error_message
  "#{body["errors"].join(". ")}." if body && body["errors"]
end

#statusObject



60
61
62
# File 'lib/idsimple/rack/api.rb', line 60

def status
  response.code
end

#success?Boolean

Returns:

  • (Boolean)


52
53
54
# File 'lib/idsimple/rack/api.rb', line 52

def success?
  response.kind_of?(Net::HTTPSuccess)
end