Sha256: 7eaf4ee29c894dbae040130c496a79200a84491b9c7041ffd1029178d2e8c204

Contents?: true

Size: 931 Bytes

Versions: 3

Compression:

Stored size: 931 Bytes

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, type = :text) # :nodoc:
      component = Component::Tropo::Say.new(type => string)
      write component
      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.2 lib/punchblock/console/commands.rb
punchblock-console-0.1.1 lib/punchblock/console/commands.rb
punchblock-console-0.1.0 lib/punchblock/console/commands.rb