Class: IContact::Response
- Inherits:
-
Object
- Object
- IContact::Response
- Includes:
- ActiveAttr::BasicModel
- Defined in:
- lib/i_contact/response.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#parsed_response ⇒ Object
readonly
Returns the value of attribute parsed_response.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
-
#initialize(resp) ⇒ Response
constructor
A new instance of Response.
- #valid? ⇒ Boolean
Constructor Details
#initialize(resp) ⇒ Response
9 10 11 12 13 14 15 16 17 |
# File 'lib/i_contact/response.rb', line 9 def initialize(resp) @parsed_response = JSON.parse(resp.body) if resp.status != 200 @errors = ["Server responded with a #{resp.status}: #{resp.body}"] else @errors = @parsed_response['errors'] || [] @warnings = @parsed_response['warnings'] || [] end end |
Instance Attribute Details
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
5 6 7 |
# File 'lib/i_contact/response.rb', line 5 def errors @errors end |
#parsed_response ⇒ Object (readonly)
Returns the value of attribute parsed_response.
7 8 9 |
# File 'lib/i_contact/response.rb', line 7 def parsed_response @parsed_response end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
6 7 8 |
# File 'lib/i_contact/response.rb', line 6 def warnings @warnings end |
Instance Method Details
#valid? ⇒ Boolean
19 20 21 |
# File 'lib/i_contact/response.rb', line 19 def valid? errors.size == 0 end |