Class: K2Transfer
- Defined in:
- lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb
Overview
For Transferring funds to pre-approved and owned settlement accounts
Constant Summary
Constants included from K2Validation
K2Validation::ALL_EVENT_TYPES, K2Validation::TILL_SCOPE_EVENT_TYPES
Instance Attribute Summary
Attributes inherited from K2Entity
#access_token, #k2_response_body, #location_url, #query_hash, #the_array
Instance Method Summary collapse
-
#query_resource(url) ⇒ Object
Query Location URL.
-
#query_status ⇒ Object
Check the status of a prior initiated Transfer.
-
#transfer_funds(params) ⇒ Object
Create a either a ‘blind’ transfer, for when destination is specified, and a ‘targeted’ transfer which has a specified destination.
Methods inherited from K2Entity
Methods included from K2Validation
#determine_scope_details, #incorrect_keys, #nil_values, #to_indifferent_access, #validate_email, #validate_hash, #validate_input, #validate_network, #validate_phone, #validate_settlement_method, #validate_till_number_prefix, #validate_url, #validate_webhook, #validate_webhook_input
Methods included from K2Utilities
Constructor Details
This class inherits a constructor from K2Entity
Instance Method Details
#query_resource(url) ⇒ Object
Query Location URL
42 43 44 |
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb', line 42 def query_resource(url) super('Transfer', url) end |
#query_status ⇒ Object
Check the status of a prior initiated Transfer. Make sure to add the id to the url
37 38 39 |
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb', line 37 def query_status super('Transfer', path_url=@location_url) end |
#transfer_funds(params) ⇒ Object
Create a either a ‘blind’ transfer, for when destination is specified, and a ‘targeted’ transfer which has a specified destination.
4 5 6 7 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 |
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb', line 4 def transfer_funds(params) # Validation unless params["destination_reference"].blank? && params["destination_type"].blank? params = validate_input(params, @exception_array += %w[destination_reference destination_type currency value callback_url metadata]) end params = params.with_indifferent_access # The Request Body Parameters k2_request_transfer = { destination_reference: params[:destination_reference], destination_type: params[:destination_type], amount: { currency: params[:currency], value: params[:value] } } = params[:metadata] transfer_body = k2_request_transfer.merge( { _links: { callback_url: params[:callback_url] }, metadata: }) transfer_hash = make_hash(K2Config.path_url('transfers'), 'post', @access_token, 'Transfer', transfer_body) @threads << Thread.new do sleep 0.25 @location_url = K2Connect.make_request(transfer_hash) end @threads.each(&:join) end |