Class: BtcPay::Client::Config

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

Constant Summary collapse

AUTH_TOKEN_TYPE =
'token'
BASIC_TOKEN_TYPE =
'Basic'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**kwargs) ⇒ Config

Returns a new instance of Config.



11
12
13
14
15
16
17
18
# File 'lib/btcpay/client/config.rb', line 11

def initialize(**kwargs)
  @base_url = load_url(kwargs[:base_url])
  @user_agent = kwargs[:user_agent] || "btcpay_ruby/#{BtcPay::VERSION}"
  @store_id = kwargs[:store_id]

  load_auth_token(kwargs)
  set_authorization
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



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

def auth_token
  @auth_token
end

#authorizationObject (readonly)

Returns the value of attribute authorization.



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

def authorization
  @authorization
end

#base_urlObject (readonly)

Returns the value of attribute base_url.



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

def base_url
  @base_url
end

#basic_auth_tokenObject (readonly)

Returns the value of attribute basic_auth_token.



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

def basic_auth_token
  @basic_auth_token
end

#store_idObject (readonly)

Returns the value of attribute store_id.



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

def store_id
  @store_id
end

#user_agentObject (readonly)

Returns the value of attribute user_agent.



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

def user_agent
  @user_agent
end

Instance Method Details

#to_hObject



20
21
22
23
24
25
26
27
28
# File 'lib/btcpay/client/config.rb', line 20

def to_h
  {
    auth_token: auth_token,
    basic_auth_token: basic_auth_token,
    base_url: base_url,
    user_agent: user_agent,
    store_id: store_id
  }.compact
end