Class: Transbank::Webpay::Oneclick::MallInscription
- Inherits:
-
Object
- Object
- Transbank::Webpay::Oneclick::MallInscription
show all
- Extended by:
- Utils::NetHelper
- Defined in:
- lib/transbank/sdk/oneclick/mall/mall_inscription.rb
Constant Summary
collapse
- INSCRIPTION_START_ENDPOINT =
'rswebpaytransaction/api/oneclick/v1.0/inscriptions'.freeze
- INSCRIPTION_FINISH_ENDPOINT =
'rswebpaytransaction/api/oneclick/v1.0/inscriptions/:token'.freeze
- INSCRIPTION_DELETE_ENDPOINT =
'rswebpaytransaction/api/oneclick/v1.0/inscriptions'.freeze
Class Method Summary
collapse
http_delete, http_get, http_post, http_put, keys_to_camel_case, patpass_comercio_headers, snake_to_camel_case, webpay_headers
Class Method Details
.default_integration_params ⇒ Object
.delete(tbk_user:, user_name:, options: nil) ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/transbank/sdk/oneclick/mall/mall_inscription.rb', line 46
def delete(tbk_user:, user_name:, options: nil)
api_key = options&.api_key || default_integration_params[:api_key]
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
integration_type = options&.integration_type || default_integration_params[:integration_type]
base_url = integration_type.nil? ? Oneclick::Base::integration_type[:TEST] : Oneclick::Base.integration_type_url(integration_type)
url = base_url + INSCRIPTION_DELETE_ENDPOINT
= (commerce_code: commerce_code, api_key: api_key)
body = {tbk_user: tbk_user, username: user_name}
resp = http_delete(uri_string: url, body: body, headers: )
code = resp.code
return ::Transbank::Webpay::Oneclick::MallInscriptionDeleteResponse.new(code) if resp.kind_of? Net::HTTPSuccess
raise Oneclick::Errors::MallInscriptionDeleteError.new(body['error_message'], resp.code)
end
|
.finish(token:, options: nil) ⇒ Object
.start(user_name:, email:, response_url:, options: nil) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/transbank/sdk/oneclick/mall/mall_inscription.rb', line 11
def start(user_name:, email:, response_url:, options: nil)
api_key = options&.api_key || default_integration_params[:api_key]
commerce_code = options&.commerce_code || default_integration_params[:commerce_code]
integration_type = options&.integration_type || default_integration_params[:integration_type]
base_url = integration_type.nil? ? Oneclick::Base::integration_type[:TEST] : Oneclick::Base.integration_type_url(integration_type)
url = base_url + INSCRIPTION_START_ENDPOINT
= (commerce_code: commerce_code, api_key: api_key)
body = {
username: user_name,
email: email,
response_url: response_url
}
resp = http_post(uri_string: url, body: body, headers: , camel_case_keys: false)
body = JSON.parse(resp.body)
return ::Transbank::Webpay::Oneclick::MallInscriptionStartResponse.new(body) if resp.kind_of? Net::HTTPSuccess
raise Oneclick::Errors::MallInscriptionStartError.new(body['error_message'], resp.code)
end
|