Class: Tosuto::API::Response

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/tosuto/api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(obj) ⇒ Response

Returns a new instance of Response.



28
29
30
# File 'lib/tosuto/api.rb', line 28

def initialize(obj)
  @original = obj
end

Instance Attribute Details

#originalObject (readonly)

Returns the value of attribute original.



25
26
27
# File 'lib/tosuto/api.rb', line 25

def original
  @original
end

Instance Method Details

#errorObject



40
41
42
# File 'lib/tosuto/api.rb', line 40

def error
  API::Error.new(response: self) unless success?
end

#json_bodyObject



32
33
34
# File 'lib/tosuto/api.rb', line 32

def json_body
  @json_body ||= JSON.parse(body)
end

#success?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/tosuto/api.rb', line 36

def success?
  original.is_a?(Net::HTTPSuccess)
end