class Bell::Ami::Cli
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/bell/ami/cli.rb, line 6 def self.exit_on_failure? true end
Public Instance Methods
call( phonenumber )
click to toggle source
# File lib/bell/ami/cli.rb, line 36 def call( phonenumber ) logger=Logger.new(STDERR) my_ami=Bell::Ami::Stream.new(options[:host],options[:port] || 5038, options[:username], options[:password], logger) bell_caller=Bell::Ami::Caller.new(phonenumber,my_ami) logger.info "Connecting to #{options[:host]}" my_ami.async_run while !bell_caller.finished? if bell_caller.ready? logger.info "Calling #{phonenumber}" result=bell_caller.dial(options[:context],options[:extension]) else # wait for call to finish end sleep 1 end #terminal stream my_ami.terminate case bell_caller.status when 'succeeded' exit 0 when 'errored' exit 2 when 'failed' exit 3 when 'not_answered' exit 4 when 'busy' exit 5 when 'not_available' exit 6 end exit 1 end