Sha256: e4eb2127e9190b90494948397315ffdde54840c6b6864854f42cf307dec0a80d

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

module Voicemail
  class MailboxSetPinController < ApplicationController
    def run
      section_menu
    end

    def section_menu
      menu config.set_pin.menu,
         timeout: config.menu_timeout, tries: config.menu_tries do
        match(1) { set_pin }
        match(9) { main_menu }

        timeout do
          play config.mailbox.menu_timeout_message
        end

        invalid do
          play config.mailbox.menu_invalid_message
        end

        failure do
          play config.mailbox.menu_failure_message
          hangup
        end
      end
    end

    def set_pin
      pin = ask config.set_pin.prompt, terminator: "#"
      repeat_pin = ask config.set_pin.repeat_prompt, terminator: "#"

      if pin.to_s.size < config.set_pin.pin_minimum_digits
        play config.set_pin.pin_error
        set_pin
      elsif pin.to_s != repeat_pin.to_s
        play config.set_pin.match_error
        set_pin
      else
        play config.set_pin.change_ok
        storage.change_pin_for_mailbox mailbox[:id], pin.to_s
        main_menu
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
voicemail-1.0.0 lib/voicemail/call_controllers/mailbox_set_pin_controller.rb
voicemail-1.0.0.beta lib/voicemail/call_controllers/mailbox_set_pin_controller.rb
voicemail-0.2.0 lib/voicemail/mailbox_set_pin_controller.rb
voicemail-0.1.0 lib/voicemail/mailbox_set_pin_controller.rb