Class: Flutterwave::BIN

Inherits:
Object
  • Object
show all
Includes:
Helpers
Defined in:
lib/flutterwave/bin.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#encrypt_data, #post

Constructor Details

#initialize(client) ⇒ BIN

Returns a new instance of BIN.



6
7
8
# File 'lib/flutterwave/bin.rb', line 6

def initialize(client)
  @client = client
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/flutterwave/bin.rb', line 4

def client
  @client
end

#optionsObject

Returns the value of attribute options.



4
5
6
# File 'lib/flutterwave/bin.rb', line 4

def options
  @options
end

Instance Method Details

#check(options = {}) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/flutterwave/bin.rb', line 11

def check(options = {})
  @options = options

  request_params = {
    card6: encrypt(:card6)
  }

  response = post(
    Flutterwave::Utils::Constants::BIN[:check_url],
    request_params
  )

  Flutterwave::Response.new(response)
end

#encrypt(key) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/flutterwave/bin.rb', line 26

def encrypt(key)
  plain_text = options[key].to_s
  raise Flutterwave::Utils::MissingKeyError.new(
    "#{key.capitalize} key required!"
  ) if plain_text.empty?

  encrypt_data(plain_text, client.api_key)
end