Class: V2Intuity::Response
- Inherits:
-
Object
- Object
- V2Intuity::Response
- Defined in:
- lib/v2_intuity/response.rb
Instance Attribute Summary collapse
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#request ⇒ Object
Returns the value of attribute request.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #add_errors(error) ⇒ Object
- #body ⇒ Object
- #code ⇒ Object
- #define_response_and_json(response) ⇒ Object
-
#g_json ⇒ Object
store parsed response so we don’t have to reparse.
- #headers ⇒ Object
-
#initialize(attributes = {}) ⇒ Response
constructor
A new instance of Response.
- #message ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Response
Returns a new instance of Response.
5 6 7 8 9 |
# File 'lib/v2_intuity/response.rb', line 5 def initialize(attributes = {}) @request = attributes[:request] @response = attributes[:response] @errors = [] end |
Instance Attribute Details
#errors ⇒ Object
Returns the value of attribute errors.
3 4 5 |
# File 'lib/v2_intuity/response.rb', line 3 def errors @errors end |
#request ⇒ Object
Returns the value of attribute request.
3 4 5 |
# File 'lib/v2_intuity/response.rb', line 3 def request @request end |
#response ⇒ Object
Returns the value of attribute response.
3 4 5 |
# File 'lib/v2_intuity/response.rb', line 3 def response @response end |
Instance Method Details
#add_errors(error) ⇒ Object
24 25 26 |
# File 'lib/v2_intuity/response.rb', line 24 def add_errors(error) @errors.push(error) end |
#body ⇒ Object
20 21 22 |
# File 'lib/v2_intuity/response.rb', line 20 def body !@response.nil? ? @response.body : nil end |
#code ⇒ Object
40 41 42 |
# File 'lib/v2_intuity/response.rb', line 40 def code !@response.nil? ? @response.code : nil end |
#define_response_and_json(response) ⇒ Object
11 12 13 14 |
# File 'lib/v2_intuity/response.rb', line 11 def define_response_and_json(response) @response = response if @response.nil? g_json if @json.nil? end |
#g_json ⇒ Object
store parsed response so we don’t have to reparse
34 35 36 37 38 |
# File 'lib/v2_intuity/response.rb', line 34 def g_json # store parsed response so we don't have to reparse return @json if @json json(parse_json(@response.body)) unless @response.to_s.nil? end |
#headers ⇒ Object
16 17 18 |
# File 'lib/v2_intuity/response.rb', line 16 def headers !@response.nil? ? @response.headers : nil end |
#message ⇒ Object
44 45 46 |
# File 'lib/v2_intuity/response.rb', line 44 def !@response.nil? ? @response. : nil end |
#success? ⇒ Boolean
28 29 30 31 32 |
# File 'lib/v2_intuity/response.rb', line 28 def success? return nil if @response.nil? @errors.to_a.empty? ? true : false end |