Sha256: 326d80a52ef9d7e9cd786efda757e2e9f5fad629b487a883ab2e9ae8e5837059

Contents?: true

Size: 1.38 KB

Versions: 2

Compression:

Stored size: 1.38 KB

Contents

module Voicemail
  class MailboxMainMenuController < ApplicationController
    def run
      main_menu
    end

    def main_menu
      menu config.mailbox.menu_greeting,
         timeout: config.menu_timeout, tries: config.menu_tries do
        match(1) { listen_to_new_messages }
        match(2) { listen_to_saved_messages }
        match(3) { set_greeting }
        match(4) { set_pin }
        match(7) { clear_new_messages }
        match(9) { clear_saved_messages }

        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_greeting
      invoke MailboxSetGreetingController, mailbox: mailbox[:id]
    end

    def set_pin
      invoke MailboxSetPinController, mailbox: mailbox[:id]
    end

    def listen_to_new_messages
      invoke MailboxMessagesController, mailbox: mailbox[:id]
    end

    def listen_to_saved_messages
      invoke MailboxMessagesController, mailbox: mailbox[:id], new_or_saved: :saved
    end

    def clear_new_messages
      invoke MailboxCleanerController, mailbox: mailbox[:id], new_or_saved: :new
    end

    def clear_saved_messages
      invoke MailboxCleanerController, mailbox: mailbox[:id], new_or_saved: :saved
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
voicemail-1.1.1 lib/voicemail/call_controllers/mailbox_main_menu_controller.rb
voicemail-1.1.0 lib/voicemail/call_controllers/mailbox_main_menu_controller.rb