Class: Transbank::Patpass::PatpassComercio::Inscription
- Inherits:
-
Object
- Object
- Transbank::Patpass::PatpassComercio::Inscription
- Extended by:
- Utils::NetHelper
- Defined in:
- lib/transbank/sdk/patpass/patpass_comercio/inscription.rb
Constant Summary collapse
- START_INSCRIPTION_ENDPOINT =
'restpatpass/v1/services/patInscription'.freeze
- INSCRIPTION_STATUS_ENDPOINT =
'restpatpass/v1/services/status'.freeze
- FIELDS =
%i( url name first_last_name second_last_name rut service_id final_url max_amount phone_number mobile_number patpass_name person_email commerce_email address city )
Class Method Summary collapse
- .default_integration_params ⇒ Object
- .start(url:, name:, first_last_name:, second_last_name:, rut:, service_id:, final_url:, max_amount:, phone_number:, mobile_number:, patpass_name:, person_email:, commerce_email:, address:, city:, options: nil) ⇒ Object
- .status(token:, options: nil) ⇒ Object
Methods included from Utils::NetHelper
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
67 68 69 70 71 72 73 74 |
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 67 def default_integration_params { api_key: Patpass::PatpassComercio::Base.api_key, commerce_code: Patpass::PatpassComercio::Base.commerce_code, integration_type: Patpass::PatpassComercio::Base::integration_type, base_url: Patpass::PatpassComercio::Base::current_integration_type_url } end |
.start(url:, name:, first_last_name:, second_last_name:, rut:, service_id:, final_url:, max_amount:, phone_number:, mobile_number:, patpass_name:, person_email:, commerce_email:, address:, city:, options: nil) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 17 def start(url:, name:, first_last_name:, second_last_name:, rut:, service_id:, final_url:, max_amount:, phone_number:, mobile_number:, patpass_name:, person_email:, commerce_email:, address:, city:, options: nil) api_key = &.api_key || default_integration_params[:api_key] commerce_code = &.commerce_code || default_integration_params[:commerce_code] integration_type = &.integration_type || default_integration_params[:integration_type] base_url = integration_type.nil? ? PatpassComercio::Base::integration_types[:TEST] : PatpassComercio::Base.integration_type_url(integration_type) body = { url: url, nombre: name, pApellido: first_last_name, sApellido: second_last_name, rut: rut, serviceId: service_id, finalUrl: final_url, commerceCode: commerce_code, montoMaximo: max_amount, telefonoFijo: phone_number, telefonoCelular: mobile_number, nombrePatPass: patpass_name, correoPersona: person_email, correoComercio: commerce_email, direccion: address, ciudad: city } url = base_url + START_INSCRIPTION_ENDPOINT headers = patpass_comercio_headers(commerce_code: commerce_code, api_key: api_key) resp = http_post(uri_string: url, body: body, headers: headers, camel_case_keys: false) resp_body = JSON.parse(resp.body) return ::Transbank::Patpass::PatpassComercio::InscriptionStartResponse.new(resp_body) if resp.kind_of? Net::HTTPSuccess raise Errors::InscriptionStartError.new(resp_body['description'], resp.code) end |
.status(token:, options: nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/transbank/sdk/patpass/patpass_comercio/inscription.rb', line 50 def status(token: ,options: nil) api_key = &.api_key || default_integration_params[:api_key] commerce_code = &.commerce_code || default_integration_params[:commerce_code] integration_type = &.integration_type || default_integration_params[:integration_type] base_url = integration_type.nil? ? PatpassComercio::Base::integration_types[:TEST] : PatpassComercio::Base.integration_type_url(integration_type) body = { token: token } url = base_url + INSCRIPTION_STATUS_ENDPOINT headers = patpass_comercio_headers(commerce_code: commerce_code, api_key: api_key) resp = http_post(uri_string: url, body: body, headers: headers, camel_case_keys: false) resp_body = JSON.parse(resp.body) return ::Transbank::Patpass::PatpassComercio::InscriptionStatusResponse.new(resp_body) if resp.kind_of? Net::HTTPSuccess raise Errors::InscriptionStatusError.new(resp_body['description'], resp.code) end |