Class: WalletPay::Configuration

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

Constant Summary collapse

DEFAULT_URI_BASE =
"https://pay.wallet.tg/wpay/store-api/"
DEFAULT_REQUEST_TIMEOUT =
20
DEFAULT_API_VERSION =
"v1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



15
16
17
18
19
20
21
22
# File 'lib/wallet_pay.rb', line 15

def initialize
  @token = nil
  @extra_headers = nil
  @url = DEFAULT_URI_BASE
  @api_version = DEFAULT_API_VERSION
  @request_timeout = DEFAULT_REQUEST_TIMEOUT
  @connection_open_timeout = DEFAULT_REQUEST_TIMEOUT
end

Instance Attribute Details

#api_versionObject

Returns the value of attribute api_version.



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

def api_version
  @api_version
end

#connection_open_timeoutObject

Returns the value of attribute connection_open_timeout.



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

def connection_open_timeout
  @connection_open_timeout
end

#extra_headersObject

Returns the value of attribute extra_headers.



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

def extra_headers
  @extra_headers
end

#request_timeoutObject

Returns the value of attribute request_timeout.



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

def request_timeout
  @request_timeout
end

#tokenObject

Raises:



24
25
26
27
28
29
# File 'lib/wallet_pay.rb', line 24

def token
  return @token if @token

  error_text = "WalletPay api token missing!"
  raise ConfigurationError, error_text
end

#urlObject

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#headersObject



31
32
33
34
35
36
37
# File 'lib/wallet_pay.rb', line 31

def headers
  {
    "Content-Type" => "application/json",
    "Wpay-Store-Api-Key" => token,
    "Accept" => "application/json"
  }.merge(extra_headers || {})
end