Sha256: ebbe40eada026d0b041bcaba87b6e02eff7c61046d58f1a7167c608f711078a1

Contents?: true

Size: 1012 Bytes

Versions: 23

Compression:

Stored size: 1012 Bytes

Contents

require "fsr/app"
module FSR
  module Cmd
    class SchedTransfer < Command
      DEFAULTS = {when: 1, context: "default", dialplan: 'xml'}
      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

      # Send the command to the event socket, using bgapi by default.
      def run(api_method = :api)
        orig_command = "%s %s" % [api_method, raw]
        Log.debug "saying #{orig_command}"
        @fs_socket.say(orig_command)
      end

      # This method builds the API command to send to the freeswitch event socket
      def raw
        "sched_transfer +#{@when} #{@uuid} #{@to} #{@dialplan} #{@context}"
      end
    end

    register(:sched_transfer, SchedTransfer)
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
freeswitcher-0.6.1 lib/fsr/cmd/sched_transfer.rb
freeswitcher-0.6.0 lib/fsr/cmd/sched_transfer.rb
freeswitcher-0.5.11 lib/fsr/cmd/sched_transfer.rb