Class: Transfer

Inherits:
Base
  • Object
show all
Defined in:
lib/flutterwave_sdk/flutterwave_objects/transfer.rb

Instance Attribute Summary

Attributes inherited from Base

#flutterwave_object

Instance Method Summary collapse

Methods inherited from Base

#check_passed_parameters, #delete_request, #get_request, #initialize, #post_request, #put_request

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#get_a_transfer(id) ⇒ Object



41
42
43
44
45
# File 'lib/flutterwave_sdk/flutterwave_objects/transfer.rb', line 41

def get_a_transfer(id)
    base_url = flutterwave_object.base_url
    response = get_request("#{base_url}/transfers/#{id}")
    return response
end

#get_all_transfersObject



35
36
37
38
39
# File 'lib/flutterwave_sdk/flutterwave_objects/transfer.rb', line 35

def get_all_transfers
    base_url = flutterwave_object.base_url
    response = get_request("#{base_url}/transfers")
    return response
end

#initiate_bulk_transfer(data) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/flutterwave_sdk/flutterwave_objects/transfer.rb', line 26

def initiate_bulk_transfer(data)
    base_url = flutterwave_object.base_url 
    required_parameters = ["title", "bulk_data"]
    check_passed_parameters(required_parameters, data)   
    payload = data.to_json
    response = post_request("#{base_url}/bulk-transfers", payload) 
    return response
end

#initiate_transfer(data) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/flutterwave_sdk/flutterwave_objects/transfer.rb', line 12

def initiate_transfer(data)
    base_url = flutterwave_object.base_url      
    # only update the payload with the transaction reference if it isn't already added to the payload
    if !data.key?("tx_ref")
        data.merge!({"tx_ref" => Util.transaction_reference_generator})
    end

    required_parameters = ["amount", "currency", "account_bank", "account_number"]
    check_passed_parameters(required_parameters, data)
    payload = data.to_json
    response = post_request("#{base_url}/transfers", payload)
    return response
end

#transfer_fee(currency, amount) ⇒ Object



6
7
8
9
10
# File 'lib/flutterwave_sdk/flutterwave_objects/transfer.rb', line 6

def transfer_fee(currency,amount)
    base_url = flutterwave_object.base_url
    response = get_request("#{base_url}/transfers/fee?currency=#{currency}&amount=#{amount}")
    return response
end