Sha256: 50434ce96c1994f0ee613543a1dfb6c60590b96062ce41edc519030e52d578f9

Contents?: true

Size: 1.14 KB

Versions: 2

Compression:

Stored size: 1.14 KB

Contents

module PunchblockConsole
  class Commands
    def initialize(client, call_id, queue) # :nodoc:
      @client, @call_id, @queue = client, call_id, queue
    end

    def accept # :nodoc:
      write Command::Accept.new
    end

    def answer # :nodoc:
      write Command::Answer.new
    end

    def hangup # :nodoc:
      write Command::Hangup.new
    end

    def reject(reason = nil) # :nodoc:
      write Command::Reject.new(:reason => reason)
    end

    def redirect(dest) # :nodoc:
      write Command::Redirect.new(:to => dest)
    end

    def record(options = {})
      write Component::Record.new(options)
    end

    def say(string)
      output string, :text
    end

    def output(string, type = :text) # :nodoc:
      component = Component::Output.new(type => string)
      write component
      component.complete_event
    end

    def agi(command, params = {})
      component = Component::Asterisk::AGI::Command.new :name => command, :params => params
      write component
      component.complete_event
    end

    def write(command) # :nodoc:
      @client.execute_command command, :call_id => @call_id, :async => false
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
punchblock-console-0.1.7 lib/punchblock/console/commands.rb
punchblock-console-0.1.6 lib/punchblock/console/commands.rb