Class: Remitano::Client::ActionConfirmations

Inherits:
Collection
  • Object
show all
Defined in:
lib/remitano/client/action_confirmations.rb

Instance Attribute Summary collapse

Attributes inherited from Collection

#path, #resource_name

Instance Method Summary collapse

Methods inherited from Collection

#all, #create, #get, #update

Constructor Details

#initialize(config:) ⇒ ActionConfirmations

Returns a new instance of ActionConfirmations.



7
8
9
# File 'lib/remitano/client/action_confirmations.rb', line 7

def initialize(config:)
  @config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



5
6
7
# File 'lib/remitano/client/action_confirmations.rb', line 5

def config
  @config
end

Instance Method Details

#confirm!(id) ⇒ Object



11
12
13
# File 'lib/remitano/client/action_confirmations.rb', line 11

def confirm!(id)
  config.net.post("/action_confirmations/#{id}/confirm", token: config.authenticator_token).execute
end

#confirm_by_hotp!(id, otp_counter) ⇒ Object



15
16
17
18
# File 'lib/remitano/client/action_confirmations.rb', line 15

def confirm_by_hotp!(id, otp_counter)
  otp = config.hotp(otp_counter)
  config.net.post("/action_confirmations/#{id}/confirm", token: otp).execute
end

#confirm_if_neccessary!(response) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/remitano/client/action_confirmations.rb', line 20

def confirm_if_neccessary!(response)
  if response.is_action_confirmation && response.status != "confirmed"
    puts "Submitting token"
    confirm!(response.id)
  else
    response
  end
end