Class: FontsDotCom::Response
- Inherits:
-
Object
- Object
- FontsDotCom::Response
- Defined in:
- lib/fonts_dot_com/response.rb
Defined Under Namespace
Classes: ApiError
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#code ⇒ Object
Returns the value of attribute code.
-
#original_response_object ⇒ Object
Returns the value of attribute original_response_object.
Instance Method Summary collapse
- #error ⇒ Object
-
#initialize(response, options = {}) ⇒ Response
constructor
A new instance of Response.
- #returned_error ⇒ Object
- #session_key ⇒ Object
- #status ⇒ Object
Constructor Details
#initialize(response, options = {}) ⇒ Response
Returns a new instance of Response.
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/fonts_dot_com/response.rb', line 18 def initialize(response, ={}) @original_response_object = response json = JSON.parse(response.body) @body = json @code = response.code raise error.new(self) if returned_error end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
16 17 18 |
# File 'lib/fonts_dot_com/response.rb', line 16 def body @body end |
#code ⇒ Object
Returns the value of attribute code.
16 17 18 |
# File 'lib/fonts_dot_com/response.rb', line 16 def code @code end |
#original_response_object ⇒ Object
Returns the value of attribute original_response_object.
16 17 18 |
# File 'lib/fonts_dot_com/response.rb', line 16 def original_response_object @original_response_object end |
Instance Method Details
#error ⇒ Object
41 42 43 44 |
# File 'lib/fonts_dot_com/response.rb', line 41 def error # TODO ApiError end |
#returned_error ⇒ Object
37 38 39 |
# File 'lib/fonts_dot_com/response.rb', line 37 def returned_error code[0].to_i > 2 end |
#session_key ⇒ Object
33 34 35 |
# File 'lib/fonts_dot_com/response.rb', line 33 def session_key records[0].fetch(:sessionKey) end |
#status ⇒ Object
29 30 31 |
# File 'lib/fonts_dot_com/response.rb', line 29 def status raise 'TODO' end |