Class: K2ConnectRuby::K2Entity::K2Transfer

Inherits:
K2Entity
  • Object
show all
Defined in:
lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb

Constant Summary

Constants included from K2ConnectRuby::K2Utilities::K2Validation

K2ConnectRuby::K2Utilities::K2Validation::ALL_EVENT_TYPES, K2ConnectRuby::K2Utilities::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

Methods inherited from K2Entity

#initialize, #query

Methods included from K2ConnectRuby::K2Utilities::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 K2ConnectRuby::K2Utilities

#make_hash

Constructor Details

This class inherits a constructor from K2ConnectRuby::K2Entity::K2Entity

Instance Method Details

#query_resource(url) ⇒ Object

Query Location URL



39
40
41
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb', line 39

def query_resource(url)
  super('Transfer', url)
end

#query_statusObject

Check the status of a prior initiated Transfer. Make sure to add the id to the url



34
35
36
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb', line 34

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.



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
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_transfer.rb', line 5

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 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(K2ConnectRuby::K2Utilities::Config::K2Config.path_url('transfers'), 'post', @access_token, 'Transfer', transfer_body)
  @location_url = K2ConnectRuby::K2Utilities::K2Connection.make_request(transfer_hash)
end