Class: K2Settlement

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

Overview

For Creating 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

Methods inherited from K2Entity

#initialize, #query

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

#make_hash

Constructor Details

This class inherits a constructor from K2Entity

Instance Method Details

#add_settlement_account(params) ⇒ Object

Create a Verified Settlement Account via API (Mobile Wallet and Bank Account)



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
35
36
37
38
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_settlement.rb', line 4

def (params)
  params=params.with_indifferent_access
  the_path_url = ''
  settlement_body = {}
  @exception_array += %w[type]
  # The Request Body Parameters
  if params[:type].eql?('merchant_wallet')
    params = validate_input(params, @exception_array += %w[first_name last_name phone_number network])
    settlement_body = {
      first_name: params[:first_name],
      last_name: params[:last_name],
      phone_number: validate_phone(params[:phone_number]),
      network: params[:network]
    }
    the_path_url = K2Config.path_url('settlement_mobile_wallet')
  elsif params[:type].eql?('merchant_bank_account')
    params = validate_input(params, @exception_array += %w[account_name bank_ref bank_branch_ref account_number currency value, settlement_method])
    settlement_body = {
        account_name: params[:account_name],
        bank_branch_ref: params[:bank_branch_ref],
        account_number: params[:account_number],
        settlement_method: params[:settlement_method]
    }
    the_path_url = K2Config.path_url('settlement_bank_account')
  else
    raise ArgumentError, 'Unknown Settlement Account'
  end

  settlement_hash = make_hash(the_path_url, 'post', @access_token, 'Transfer', settlement_body)
  @threads << Thread.new do
    sleep 0.25
    @location_url = K2Connect.make_request(settlement_hash)
  end
  @threads.each(&:join)
end

#query_resource(url) ⇒ Object

Query Location URL



46
47
48
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_settlement.rb', line 46

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

#query_statusObject

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



41
42
43
# File 'lib/k2-connect-ruby/k2_entity/k2_financial_entities/k2_settlement.rb', line 41

def query_status
  super('Settlement', path_url=@location_url)
end