Class: Kount::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/kount/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Client

Returns a new instance of Client.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/kount/client.rb', line 12

def initialize(opts)
  @api_key               = opts[:api_key]
  @client                = opts[:client]
  @auth_url              = opts[:auth_url]
  @host                  = opts[:host]
  @token_storage_adapter = opts[:token_storage_adapter]
  @bearer_token          = nil
  @token_expiry          = nil

  if token_storage_adapter &&
     !(token_storage_adapter.respond_to?(:get_token) && token_storage_adapter.respond_to?(:store_token))
    raise ArgumentError, "Token storage adapter must implement get_token and store_token methods"
  end
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/kount/client.rb', line 5

def api_key
  @api_key
end

#auth_urlObject

Returns the value of attribute auth_url.



5
6
7
# File 'lib/kount/client.rb', line 5

def auth_url
  @auth_url
end

#bearer_tokenObject

Returns the value of attribute bearer_token.



5
6
7
# File 'lib/kount/client.rb', line 5

def bearer_token
  @bearer_token
end

#clientObject

Returns the value of attribute client.



5
6
7
# File 'lib/kount/client.rb', line 5

def client
  @client
end

#hostObject

Returns the value of attribute host.



5
6
7
# File 'lib/kount/client.rb', line 5

def host
  @host
end

#token_storage_adapterObject

Returns the value of attribute token_storage_adapter.



5
6
7
# File 'lib/kount/client.rb', line 5

def token_storage_adapter
  @token_storage_adapter
end

Instance Method Details

#create_order(order, risk_inquiry: true) ⇒ Object



27
28
29
30
31
# File 'lib/kount/client.rb', line 27

def create_order(order, risk_inquiry: true)
  response_handler do
    post_order(order, risk_inquiry)
  end
end

#update_order(order_id, order) ⇒ Object



33
34
35
36
37
# File 'lib/kount/client.rb', line 33

def update_order(order_id, order)
  response_handler do
    patch_order(order_id, order)
  end
end