class Multisafepay::Client

Attributes

adapter[R]
api_key[R]
env[R]

Public Class Methods

new(api_key: nil, env: :live, adapter: Faraday.default_adapter) click to toggle source
# 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

Public Instance Methods

accounts() click to toggle source
# File lib/multisafepay/client.rb, line 11
def accounts
  AccountsResource.new(self)
end
capture() click to toggle source
# File lib/multisafepay/client.rb, line 15
def capture
  CaptureResource.new(self)
end
connection() click to toggle source
# 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
gateways() click to toggle source
# File lib/multisafepay/client.rb, line 19
def gateways
  GatewaysResource.new(self)
end
orders() click to toggle source
# File lib/multisafepay/client.rb, line 23
def orders
  OrdersResource.new(self)
end
tokens() click to toggle source
# File lib/multisafepay/client.rb, line 27
def tokens
  TokensResource.new(self)
end
transactions() click to toggle source
# File lib/multisafepay/client.rb, line 31
def transactions
  TransactionsResource.new(self)
end

Private Instance Methods

base_url() click to toggle source
# File lib/multisafepay/client.rb, line 48
def base_url
  case env
  when :live
    "https://api.multisafepay.com/v1/json"
  when :test
    "https://testapi.multisafepay.com/v1/json"
  end
end