Class: Bootpay::RestClient

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

Constant Summary collapse

API =
{
  development: 'https://dev-api.bootpay.co.kr/v2',
  stage:       'https://stage-api.bootpay.co.kr/v2',
  production:  'https://api.bootpay.co.kr/v2'
}
SDK_VERSION =
'5.3.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of RestClient.

Raises:

  • (ArgumentError)


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/bootpay/bootpay-rest-client.rb', line 24

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

Instance Attribute Details

#api_versionObject

Returns the value of attribute api_version.



13
14
15
# File 'lib/bootpay/bootpay-rest-client.rb', line 13

def api_version
  @api_version
end

#application_idObject

Returns the value of attribute application_id.



13
14
15
# File 'lib/bootpay/bootpay-rest-client.rb', line 13

def application_id
  @application_id
end

#client_keyObject

Returns the value of attribute client_key.



13
14
15
# File 'lib/bootpay/bootpay-rest-client.rb', line 13

def client_key
  @client_key
end

#modeObject

Returns the value of attribute mode.



13
14
15
# File 'lib/bootpay/bootpay-rest-client.rb', line 13

def mode
  @mode
end

#private_keyObject

Returns the value of attribute private_key.



13
14
15
# File 'lib/bootpay/bootpay-rest-client.rb', line 13

def private_key
  @private_key
end

#secret_keyObject

Returns the value of attribute secret_key.



13
14
15
# File 'lib/bootpay/bootpay-rest-client.rb', line 13

def secret_key
  @secret_key
end

#tokenObject

Returns the value of attribute token.



13
14
15
# File 'lib/bootpay/bootpay-rest-client.rb', line 13

def token
  @token
end

#use_client_keyObject

Returns the value of attribute use_client_key.



13
14
15
# File 'lib/bootpay/bootpay-rest-client.rb', line 13

def use_client_key
  @use_client_key
end

Instance Method Details

#set_api_url(url) ⇒ Object

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



39
40
41
# File 'lib/bootpay/bootpay-rest-client.rb', line 39

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)


46
47
48
49
# File 'lib/bootpay/bootpay-rest-client.rb', line 46

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