Sha256: 5760886fb28aeeb048d0e015f8bc18283e92156f4df04c3dd75e820413234a1c

Contents?: true

Size: 1.16 KB

Versions: 3

Compression:

Stored size: 1.16 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.resource
    end

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

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
punchblock-console-0.1.5 lib/punchblock/console/commands.rb
punchblock-console-0.1.4 lib/punchblock/console/commands.rb
punchblock-console-0.1.3 lib/punchblock/console/commands.rb