Class: Flutterwave::BankAPI
- Inherits:
-
Object
- Object
- Flutterwave::BankAPI
- Defined in:
- lib/flutterwave/bank.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
Instance Method Summary collapse
- #find_by_code(code) ⇒ Object
- #find_by_name(name_match) ⇒ Object
-
#initialize(client) ⇒ BankAPI
constructor
A new instance of BankAPI.
- #list ⇒ Object
- #post(url, data = {}) ⇒ Object
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
#client ⇒ Object
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 |
#list ⇒ Object
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 |