Class: TxAsr::Request
- Inherits:
-
Object
- Object
- TxAsr::Request
- Defined in:
- lib/tx_asr/request.rb
Instance Method Summary collapse
- #call(action) ⇒ Object
-
#initialize(payload) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(payload) ⇒ Request
Returns a new instance of Request.
4 5 6 |
# File 'lib/tx_asr/request.rb', line 4 def initialize(payload) @payload = default_payload.merge(payload) end |
Instance Method Details
#call(action) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tx_asr/request.rb', line 8 def call(action) result = request(action) if result["Response"]["Error"].present? # { # "Response": # { # "Error": { # "Code": "AuthFailure.SignatureFailure", # "Message": "The provided credentials could not be validated. Please check your signature is correct." # }, # "RequestId":"ff48f384-6da7-4797-874a-b88e5e186136" # } # } ServiceResult.new(errors: result["Response"]["Error"], message: result["Response"]["Error"].fetch("Message")) else # { # "Response": # { # "RequestId": "6f24aeab-9929-4aec-81de-e3eff87639f6", # "Data": { # "TaskId": # 1357048750 # } # } # } ServiceResult.new(success: true, data: result["Response"]) end end |