Class: FSR::Cmd::SchedTransfer

Inherits:
Command
  • Object
show all
Defined in:
lib/fsr/cmd/sched_transfer.rb

Constant Summary collapse

DEFAULTS =
{when: 1, context: "default", dialplan: 'xml'}

Constants inherited from Command

Command::DEFAULT_OPTIONS

Instance Method Summary collapse

Constructor Details

#initialize(fs_socket = nil, args = {}) ⇒ SchedTransfer

Returns a new instance of SchedTransfer.

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
# File 'lib/fsr/cmd/sched_transfer.rb', line 6

def initialize(fs_socket = nil, args = {})
  @fs_socket = fs_socket # FSR::CommandSocket obj
  args = DEFAULTS.merge(args)
  @when, @uuid, @to, @context, @dialplan = args.values_at(:when, :uuid, :to, :context, :dialplan)
  raise(ArgumentError, "No uuid given") unless @uuid
  raise(ArgumentError, "No to: extension given") unless @to
end

Instance Method Details

#rawObject

This method builds the API command to send to the freeswitch event socket



22
23
24
# File 'lib/fsr/cmd/sched_transfer.rb', line 22

def raw
  "sched_transfer +#{@when} #{@uuid} #{@to} #{@dialplan} #{@context}"
end

#run(api_method = :api) ⇒ Object

Send the command to the event socket, using bgapi by default.



15
16
17
18
19
# File 'lib/fsr/cmd/sched_transfer.rb', line 15

def run(api_method = :api)
  orig_command = "%s %s" % [api_method, raw]
  Log.debug "saying #{orig_command}"
  @fs_socket.say(orig_command)
end