Class: TransferBase
- Defined in:
- lib/rave_ruby/rave_objects/base/transfer_base.rb
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#handle_balance_status(response) ⇒ Object
method to handle get balance response.
-
#handle_bulk_response(response) ⇒ Object
method to handle bulk transfer response.
-
#handle_fetch_status(response) ⇒ Object
method to handle fetch account response.
-
#handle_initiate_response(response) ⇒ Object
method to handle single transfer response.
-
#handle_transfer_status(response) ⇒ Object
method to handle get fee response.
Methods inherited from Base
#check_passed_parameters, #get_request, #handle_list_bank, #initialize, #post_request
Constructor Details
This class inherits a constructor from Base
Instance Method Details
#handle_balance_status(response) ⇒ Object
method to handle get balance response
52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/rave_ruby/rave_objects/base/transfer_base.rb', line 52 def handle_balance_status(response) balance_status = response status = balance_status["status"] if status == "success" response = {"error" => false, "returned_data" => JSON.parse(balance_status.body)} return response else response = {"error" => true, "returned_data" => JSON.parse(balance_status.body)} raise InitiateTransferError, response end end |
#handle_bulk_response(response) ⇒ Object
method to handle bulk transfer response
22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rave_ruby/rave_objects/base/transfer_base.rb', line 22 def handle_bulk_response(response) bulk_response = response status = bulk_response["status"] id = bulk_response["data"]["id"] if status == "success" response = {"error": false, "status": status, "message": bulk_response["message"], "id": id, "data": bulk_response["data"]} return JSON.parse(response.to_json) else response = {"error": true, "data": initiate_response["data"]} raise InitiateTransferError, JSON.parse(response.to_json) end end |
#handle_fetch_status(response) ⇒ Object
method to handle fetch account response
67 68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/rave_ruby/rave_objects/base/transfer_base.rb', line 67 def handle_fetch_status(response) fetch_status = response if fetch_status.code == 200 response = {"error" => false, "returned_data" => JSON.parse(fetch_status.body)} return response else response = {"error" => true, "returned_data" => JSON.parse(fetch_status.body)} raise InitiateTransferError, response end end |
#handle_initiate_response(response) ⇒ Object
method to handle single transfer response
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/rave_ruby/rave_objects/base/transfer_base.rb', line 6 def handle_initiate_response(response) initiate_response = response status = initiate_response["status"] id = initiate_response["data"]["id"] if status == "success" response = {"error": false, "id": id, "data": initiate_response["data"]} return JSON.parse(response.to_json) else response = {"error": true, "data": initiate_response["data"]} raise InitiateTransferError, JSON.parse(response.to_json) end end |
#handle_transfer_status(response) ⇒ Object
method to handle get fee response
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rave_ruby/rave_objects/base/transfer_base.rb', line 38 def handle_transfer_status(response) transfer_status = response if transfer_status.code == 200 response = {"error" => false, "data" => JSON.parse(transfer_status.body)} return response else response = {"error" => true, "data" => JSON.parse(transfer_status.body)} raise InitiateTransferError, response end end |