Class: Multisafepay::Client

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Client.



5
6
7
8
9
# File 'lib/multisafepay/client.rb', line 5

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

Instance Attribute Details

#adapterObject (readonly)

Returns the value of attribute adapter.



3
4
5
# File 'lib/multisafepay/client.rb', line 3

def adapter
  @adapter
end

#api_keyObject (readonly)

Returns the value of attribute api_key.



3
4
5
# File 'lib/multisafepay/client.rb', line 3

def api_key
  @api_key
end

#envObject (readonly)

Returns the value of attribute env.



3
4
5
# File 'lib/multisafepay/client.rb', line 3

def env
  @env
end

Instance Method Details

#accountsObject



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

def accounts
  AccountsResource.new(self)
end

#captureObject



15
16
17
# File 'lib/multisafepay/client.rb', line 15

def capture
  CaptureResource.new(self)
end

#connectionObject



35
36
37
38
39
40
41
42
43
44
# File 'lib/multisafepay/client.rb', line 35

def connection
  @connection ||= Faraday.new(base_url) do |conn|
    conn.headers["api_key"] = api_key
    conn.request :json

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

    conn.adapter adapter
  end
end

#gatewaysObject



19
20
21
# File 'lib/multisafepay/client.rb', line 19

def gateways
  GatewaysResource.new(self)
end

#ordersObject



23
24
25
# File 'lib/multisafepay/client.rb', line 23

def orders
  OrdersResource.new(self)
end

#tokensObject



27
28
29
# File 'lib/multisafepay/client.rb', line 27

def tokens
  TokensResource.new(self)
end

#transactionsObject



31
32
33
# File 'lib/multisafepay/client.rb', line 31

def transactions
  TransactionsResource.new(self)
end