Class: Espago::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/espago/response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Response

Returns a new instance of Response.



9
10
11
12
# File 'lib/espago/response.rb', line 9

def initialize(response)
  @body = parse(response.body)
  @status = response.status
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(attribute_name) ⇒ Object



14
15
16
# File 'lib/espago/response.rb', line 14

def method_missing(attribute_name)
  body[attribute_name.to_s]
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/espago/response.rb', line 7

def body
  @body
end

#statusObject (readonly)

Returns the value of attribute status.



6
7
8
# File 'lib/espago/response.rb', line 6

def status
  @status
end

Instance Method Details

#cardObject



18
19
20
# File 'lib/espago/response.rb', line 18

def card
  body["card"] || {}
end

#created_atObject



22
23
24
# File 'lib/espago/response.rb', line 22

def created_at
  Time.at(body["created_at"]) rescue nil
end