Class: QPay::Client

Inherits:
Object
  • Object
show all
Includes:
Endpoints::Auth, Endpoints::Ebarimt, Endpoints::Invoices, Endpoints::Payments
Defined in:
lib/qpay/client.rb

Constant Summary collapse

TOKEN_BUFFER_SECONDS =
30

Instance Method Summary collapse

Methods included from Endpoints::Ebarimt

#cancel_ebarimt, #create_ebarimt

Methods included from Endpoints::Payments

#cancel_payment, #check_payment, #get_payment, #list_payments, #refund_payment

Methods included from Endpoints::Invoices

#cancel_invoice, #create_ebarimt_invoice, #create_invoice, #create_simple_invoice

Methods included from Endpoints::Auth

#get_token, #refresh_token

Constructor Details

#initialize(config:, faraday: nil) ⇒ Client

Creates a new QPay client.

Parameters:

  • config (QPay::Config) —

    the configuration object

  • faraday (Faraday::Connection, nil) (defaults to: nil) —

    optional custom Faraday connection



19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/qpay/client.rb', line 19

def initialize(config:, faraday: nil)
  @config = config
  @mutex = Mutex.new
  @access_token = nil
  @refresh_token = nil
  @expires_at = 0
  @refresh_expires_at = 0

  @http = faraday || Faraday.new do |f|
    f.options.timeout = 30
    f.options.open_timeout = 10
    f.adapter Faraday.default_adapter
  end
end