Class: Transfer
- Inherits:
-
TransferBase
- Object
- Base
- TransferBase
- Transfer
- Defined in:
- lib/rave_ruby/rave_objects/transfer.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#bulk_transfer(data) ⇒ Object
method to perform bulk transfer request.
-
#fetch(reference) ⇒ Object
method to fetch a single transfer.
-
#fetch_all_transfers ⇒ Object
method to fetch all transfers.
-
#get_balance(currency) ⇒ Object
method to perform get balance request.
-
#get_fee(currency) ⇒ Object
method to perform get fee request.
-
#initiate_transfer(data) ⇒ Object
method to initiate single transfer.
Methods inherited from TransferBase
#handle_balance_status, #handle_bulk_response, #handle_fetch_status, #handle_initiate_response, #handle_transfer_status
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
#bulk_transfer(data) ⇒ Object
method to perform bulk transfer request
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rave_ruby/rave_objects/transfer.rb', line 28 def bulk_transfer(data) base_url = rave_object.base_url data.merge!({"seckey" => rave_object.secret_key.dup}) required_parameters = ["title", "bulk_data"] check_passed_parameters(required_parameters, data) payload = data.to_json response = post_request("#{base_url}#{BASE_ENDPOINTS::TRANSFER_ENDPOINT}/create_bulk", payload) return handle_bulk_response(response) end |
#fetch(reference) ⇒ Object
method to fetch a single transfer
67 68 69 70 71 |
# File 'lib/rave_ruby/rave_objects/transfer.rb', line 67 def fetch(reference) base_url = rave_object.base_url response = get_request("#{base_url}#{BASE_ENDPOINTS::FETCH_ENDPOINT}", {"seckey" => rave_object.secret_key.dup, "reference" => reference}) return handle_fetch_status(response) end |
#fetch_all_transfers ⇒ Object
method to fetch all transfers
74 75 76 77 78 |
# File 'lib/rave_ruby/rave_objects/transfer.rb', line 74 def fetch_all_transfers base_url = rave_object.base_url response = get_request("#{base_url}#{BASE_ENDPOINTS::FETCH_ENDPOINT}", {"seckey" => rave_object.secret_key.dup}) return handle_fetch_status(response) end |
#get_balance(currency) ⇒ Object
method to perform get balance request
51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rave_ruby/rave_objects/transfer.rb', line 51 def get_balance(currency) base_url = rave_object.base_url payload = { "seckey" => rave_object.secret_key.dup, "currency" => currency } payload = payload.to_json response = post_request("#{base_url}#{BASE_ENDPOINTS::GET_BALANCE_ENDPOINT}", payload) return handle_balance_status(response) end |
#get_fee(currency) ⇒ Object
method to perform get fee request
44 45 46 47 48 |
# File 'lib/rave_ruby/rave_objects/transfer.rb', line 44 def get_fee(currency) base_url = rave_object.base_url response = get_request("#{base_url}#{BASE_ENDPOINTS::GET_FEE_ENDPOINT}", {"seckey" => rave_object.secret_key.dup, "currency" => currency}) return handle_transfer_status(response) end |
#initiate_transfer(data) ⇒ Object
method to initiate single transfer
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/rave_ruby/rave_objects/transfer.rb', line 7 def initiate_transfer(data) base_url = rave_object.base_url # only update the payload with the transaction reference if it isn't already added to the payload if !data.key?("reference") data.merge!({"reference" => Util.transaction_reference_generator}) end data.merge!({"seckey" => rave_object.secret_key.dup}) required_parameters = ["amount", "currency"] check_passed_parameters(required_parameters, data) payload = data.to_json response = post_request("#{base_url}#{BASE_ENDPOINTS::TRANSFER_ENDPOINT}/create", payload) return handle_initiate_response(response) end |