Class: AGCOD::Response
- Inherits:
-
Object
- Object
- AGCOD::Response
- Defined in:
- lib/aws_agcod/response.rb
Instance Attribute Summary collapse
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #error_message ⇒ Object
-
#initialize(raw_json) ⇒ Response
constructor
A new instance of Response.
- #success? ⇒ Boolean
Constructor Details
#initialize(raw_json) ⇒ Response
Returns a new instance of Response.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/aws_agcod/response.rb', line 7 def initialize(raw_json) @payload = JSON.parse(raw_json) # All status: # SUCCESS -- Operation succeeded # FAILURE -- Operation failed # RESEND -- A temporary/recoverable system failure that can be resolved by the partner retrying the request @status = if payload['status'] payload['status'] elsif payload['agcodResponse'] payload['agcodResponse']['status'] else 'FAILURE' end end |
Instance Attribute Details
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
5 6 7 |
# File 'lib/aws_agcod/response.rb', line 5 def payload @payload end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/aws_agcod/response.rb', line 5 def status @status end |
Instance Method Details
#error_message ⇒ Object
27 28 29 |
# File 'lib/aws_agcod/response.rb', line 27 def "#{payload['errorCode']} #{payload['errorType']} - #{payload['message']}" end |
#success? ⇒ Boolean
23 24 25 |
# File 'lib/aws_agcod/response.rb', line 23 def success? status == 'SUCCESS' end |