Class: Flutterwave::BankAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/flutterwave/bank.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ BankAPI

Returns a new instance of BankAPI.



5
6
7
# File 'lib/flutterwave/bank.rb', line 5

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



3
4
5
# File 'lib/flutterwave/bank.rb', line 3

def client
  @client
end

Instance Method Details

#find_by_code(code) ⇒ Object



21
22
23
24
25
# File 'lib/flutterwave/bank.rb', line 21

def find_by_code(code)
  list.detect do |bank|
    bank.code == code
  end
end

#find_by_name(name_match) ⇒ Object



27
28
29
30
31
# File 'lib/flutterwave/bank.rb', line 27

def find_by_name(name_match)
  list.detect do |bank|
    !(bank.name.downcase =~ /#{name_match.downcase}/).nil?
  end
end

#listObject



10
11
12
13
14
15
16
17
18
19
# File 'lib/flutterwave/bank.rb', line 10

def list
  response = post(
    Flutterwave::Utils::Constants::BANK[:list_url]
  )

  all_banks = response['data']
  all_banks.keys.inject([]) do |list, code|
    list << Bank.new(code, all_banks[code])
  end
end

#post(url, data = {}) ⇒ Object



33
34
35
# File 'lib/flutterwave/bank.rb', line 33

def post(url, data = {})
  Flutterwave::Utils::NetworkManager.post(url, data)
end