Class: BasisTheory::Client

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

Constant Summary collapse

BASE_URL =
'https://api.basistheory.com/'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key:, adapter: Faraday.default_adapter) ⇒ Client

Returns a new instance of Client.



11
12
13
14
# File 'lib/basis_theory/client.rb', line 11

def initialize(api_key:, adapter: Faraday.default_adapter)
  @api_key = api_key
  @adapter = adapter
end

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



9
10
11
# File 'lib/basis_theory/client.rb', line 9

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



9
10
11
# File 'lib/basis_theory/client.rb', line 9

def api_key
  @api_key
end

Instance Method Details

#applicationsObject



16
17
18
# File 'lib/basis_theory/client.rb', line 16

def applications
  ApplicationResource.new(self)
end

#atomic_banksObject



20
21
22
# File 'lib/basis_theory/client.rb', line 20

def atomic_banks
  AtomicBankResource.new(self)
end

#connectionObject



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/basis_theory/client.rb', line 28

def connection
  @connection ||= Faraday.new(BASE_URL) do |conn|
    # conn.response :logger, ::Logger.new(STDOUT), body: true, bodies: { request: true, response: true }
    conn.headers['X-API-KEY'] = api_key
    conn.headers['Content-Type'] = 'application/json'

    conn.response :json, content_type: 'application/json'

    conn.adapter adapter
  end
end

#tokensObject



24
25
26
# File 'lib/basis_theory/client.rb', line 24

def tokens
  TokenResource.new(self)
end