Class: Transbank::Webpay::Oneclick::MallInscription

Inherits:
Common::BaseTransaction show all
Defined in:
lib/transbank/sdk/webpay/oneclick/mall_inscription.rb

Constant Summary collapse

RESOURCES_URL =
::Transbank::Common::ApiConstants::ONECLICK_ENDPOINT
START_ENDPOINT =
(RESOURCES_URL + '/inscriptions').freeze
FINISH_ENDPOINT =
(RESOURCES_URL + '/inscriptions/%{token}').freeze
DELETE_ENDPOINT =
(RESOURCES_URL + '/inscriptions').freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ MallInscription

Returns a new instance of MallInscription.



11
12
13
# File 'lib/transbank/sdk/webpay/oneclick/mall_inscription.rb', line 11

def initialize(options)
  super
end

Class Method Details

.build_for_integration(commerce_code, api_key) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/transbank/sdk/webpay/oneclick/mall_inscription.rb', line 19

def self.build_for_integration(commerce_code, api_key)
  options = Options.new(
    commerce_code,
    api_key,
    :integration
  )
  
  new(options)
end

.build_for_production(commerce_code, api_key) ⇒ Object



29
30
31
32
33
34
35
36
# File 'lib/transbank/sdk/webpay/oneclick/mall_inscription.rb', line 29

def self.build_for_production(commerce_code, api_key)
  options = Options.new(
    commerce_code,
    api_key,
    :production
  )
  new(options)
end

.new(options) ⇒ Object



15
16
17
# File 'lib/transbank/sdk/webpay/oneclick/mall_inscription.rb', line 15

def self.new(options)
  super(options)
end

Instance Method Details

#delete(tbk_user, username) ⇒ Object



61
62
63
64
65
66
67
68
69
70
# File 'lib/transbank/sdk/webpay/oneclick/mall_inscription.rb', line 61

def delete(tbk_user, username)

  Transbank::Common::Validation.has_text_with_max_length(tbk_user, Transbank::Common::ApiConstants::TBK_USER_LENGTH, "tbk_user")
  Transbank::Common::Validation.has_text_with_max_length(username, Transbank::Common::ApiConstants::USER_NAME_LENGTH, "username")

  request_service = ::Transbank::Shared::RequestService.new(
    @environment, DELETE_ENDPOINT, @commerce_code, @api_key, @timeout
  )
  request_service.delete({tbk_user: tbk_user, username: username})
end

#finish(token) ⇒ Object



51
52
53
54
55
56
57
58
59
# File 'lib/transbank/sdk/webpay/oneclick/mall_inscription.rb', line 51

def finish(token)

  Transbank::Common::Validation.has_text_with_max_length(token, Transbank::Common::ApiConstants::TOKEN_LENGTH, "token")

  request_service = ::Transbank::Shared::RequestService.new(
    @environment, format(FINISH_ENDPOINT, token: token), @commerce_code, @api_key, @timeout
  )
  request_service.put({})
end

#start(username, email, response_url) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/transbank/sdk/webpay/oneclick/mall_inscription.rb', line 38

def start(username, email, response_url)
  Transbank::Common::Validation.has_text_with_max_length(username, Transbank::Common::ApiConstants::USER_NAME_LENGTH, "username")
  Transbank::Common::Validation.has_text_with_max_length(email, Transbank::Common::ApiConstants::EMAIL_LENGTH, "email")
  Transbank::Common::Validation.has_text_with_max_length(response_url, Transbank::Common::ApiConstants::RETURN_URL_LENGTH, "response_url")

  request_service = ::Transbank::Shared::RequestService.new(
    @environment, START_ENDPOINT, @commerce_code, @api_key, @timeout
  )
  request_service.post({
    username: username, email: email, response_url: response_url
                       })
end