Class: BootpayStore::RestClient

Inherits:
Object
  • Object
show all
Includes:
Concern
Defined in:
lib/bootpay_store/bootpay-store-rest-client.rb

Constant Summary collapse

API =
{
  development: 'https://dev-api.bootapi.com/v1',
  stage:       'https://stage-api.bootapi.com/v1',
  production:  'https://api.bootapi.com/v1'
}
SDK_VERSION =
'5.0.0'

Instance Method Summary collapse

Constructor Details

#initialize(client_key: nil, private_key: nil, server_key: nil, secret_key: nil, mode: 'production') ⇒ RestClient

Returns a new instance of RestClient.

Raises:

  • (ArgumentError)


23
24
25
26
27
28
29
30
# File 'lib/bootpay_store/bootpay-store-rest-client.rb', line 23

def initialize(client_key: nil, private_key: nil, server_key: nil, secret_key: nil, mode: 'production')
  @client_key  = server_key.presence || client_key
  @secret_key  = private_key.presence || secret_key
  @mode        = mode.presence || 'production'
  @token       = nil
  @api_version = SDK_VERSION
  raise ArgumentError, "개발환경 mode는 development, stage, production 중에서 선택이 가능합니다." if API[@mode.to_sym].blank?
end

Instance Method Details

#set_api_url(url) ⇒ Object

API URL을 변경 Comment by GOSOMI @date: 2023-05-26



35
36
37
# File 'lib/bootpay_store/bootpay-store-rest-client.rb', line 35

def set_api_url(url)
  API[@mode.to_sym] = url
end

#set_api_version(version) ⇒ Object

API 버전을 설정한다 Comment by Gosomi Date: 2022-07-29

Raises:

  • (ArgumentError)


42
43
44
45
# File 'lib/bootpay_store/bootpay-store-rest-client.rb', line 42

def set_api_version(version)
  raise ArgumentError, 'API Version은 4.0.0 이상만 설정이 가능합니다.' if version < '4.0.0'
  @api_version = version
end