Class: Suretax::Response
- Inherits:
-
Object
- Object
- Suretax::Response
- Defined in:
- lib/suretax/response.rb
Instance Attribute Summary collapse
-
#api ⇒ Object
readonly
Returns the value of attribute api.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(api_response) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(api_response) ⇒ Response
Returns a new instance of Response.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/suretax/response.rb', line 8 def initialize(api_response) @response = api_response sanitized_body = remove_xml_brackets(api_response.body) if sanitized_body == 'invalid request' @body = sanitized_body @status = 400 @api = nil log_response return self end @body = JSON.parse(sanitized_body) @api = Api::Response.new(@body) @status = map_response_code_to_http_status(api.status) log_response end |
Instance Attribute Details
#api ⇒ Object (readonly)
Returns the value of attribute api.
6 7 8 |
# File 'lib/suretax/response.rb', line 6 def api @api end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/suretax/response.rb', line 6 def body @body end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
6 7 8 |
# File 'lib/suretax/response.rb', line 6 def response @response end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/suretax/response.rb', line 6 def status @status end |
Instance Method Details
#success? ⇒ Boolean
26 27 28 |
# File 'lib/suretax/response.rb', line 26 def success? status == 200 end |