freeswitcher 0.5.10 → 0.5.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,7 +19,7 @@ module FSR
19
19
 
20
20
  # This method builds the API command to send to the freeswitch event socket
21
21
  def raw
22
- orig_command = "sched_hangup +#{@when} #{@uuid} #{@cause.dump}"
22
+ "sched_hangup +#{@when} #{@uuid} #{@cause.dump}"
23
23
  end
24
24
  end
25
25
 
@@ -0,0 +1,29 @@
1
+ require "fsr/app"
2
+ module FSR
3
+ module Cmd
4
+ class SchedTransfer < Command
5
+ DEFAULTS = {when: 1, context: "default", dialplan: 'xml'}
6
+ def initialize(fs_socket = nil, args = {})
7
+ @fs_socket = fs_socket # FSR::CommandSocket obj
8
+ args = DEFAULTS.merge(args)
9
+ @when, @uuid, @to, @context, @dialplan = args.values_at(:when, :uuid, :to, :context, :dialplan)
10
+ raise(ArgumentError, "No uuid given") unless @uuid
11
+ raise(ArgumentError, "No to: extension given") unless @to
12
+ end
13
+
14
+ # Send the command to the event socket, using bgapi by default.
15
+ def run(api_method = :api)
16
+ orig_command = "%s %s" % [api_method, raw]
17
+ Log.debug "saying #{orig_command}"
18
+ @fs_socket.say(orig_command)
19
+ end
20
+
21
+ # This method builds the API command to send to the freeswitch event socket
22
+ def raw
23
+ "sched_transfer +#{@when} #{@uuid} #{@to} #{@dialplan} #{@context}"
24
+ end
25
+ end
26
+
27
+ register(:sched_transfer, SchedTransfer)
28
+ end
29
+ end
@@ -0,0 +1,30 @@
1
+ require "fsr/app"
2
+ module FSR
3
+ module Cmd
4
+ class UuidTransfer < Command
5
+ DEFAULTS = {both: false, context: "default", dialplan: 'xml'}
6
+ def initialize(fs_socket = nil, args = {})
7
+ @fs_socket = fs_socket # FSR::CommandSocket obj
8
+ args = DEFAULTS.merge(args)
9
+ both, @uuid, @to, @context, @dialplan = args.values_at(:both, :uuid, :to, :context, :dialplan)
10
+ @leg = both ? '-both' : '-bleg'
11
+ raise(ArgumentError, "No uuid given") unless @uuid
12
+ raise(ArgumentError, "No to: extension given") unless @to
13
+ end
14
+
15
+ # Send the command to the event socket, using bgapi by default.
16
+ def run(api_method = :api)
17
+ orig_command = "%s %s" % [api_method, raw]
18
+ Log.debug "saying #{orig_command}"
19
+ @fs_socket.say(orig_command)
20
+ end
21
+
22
+ # This method builds the API command to send to the freeswitch event socket
23
+ def raw
24
+ "uuid_transfer #{@uuid} #{@leg} #{@to} #{@dialplan} #{@context}"
25
+ end
26
+ end
27
+
28
+ register(:uuid_transfer, UuidTransfer)
29
+ end
30
+ end
data/lib/fsr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module FSR
2
- VERSION = "0.5.10"
2
+ VERSION = "0.5.11"
3
3
  end
@@ -2,7 +2,7 @@ require './spec/helper'
2
2
  require "fsr/cmd"
3
3
  FSR::Cmd.load_command("sched_hangup")
4
4
 
5
- describe "Testing FSR::Cmd::Callcenter" do
5
+ describe "Testing FSR::Cmd::SchedHangup" do
6
6
  ## Scheduled Hangup ##
7
7
  it "FSR::Cmd::SchedHangup should schedule a hangup with default " do
8
8
  cmd = FSR::Cmd::SchedHangup.new nil, uuid: 1234
@@ -29,7 +29,7 @@ describe "Testing FSR::Cmd::Callcenter" do
29
29
  cmd.raw.should == 'sched_hangup +1 1234 "Say \"WHAT?\""'
30
30
  end
31
31
 
32
- it "FSR::Cmd::SchedHangup should raise " do
32
+ it "FSR::Cmd::SchedHangup should raise when it doesn't get a uuid" do
33
33
  lambda { cmd = FSR::Cmd::SchedHangup.new nil, cause: "No Reason" }.should.raise ArgumentError
34
34
  end
35
35
  end
@@ -0,0 +1,26 @@
1
+ require './spec/helper'
2
+ require "fsr/cmd"
3
+ FSR::Cmd.load_command("sched_transfer")
4
+
5
+ describe "Testing FSR::Cmd::SchedTransfer" do
6
+ ## Scheduled Transfer ##
7
+ it "FSR::Cmd::SchedTransfer should schedule a Transfer with defaults" do
8
+ cmd = FSR::Cmd::SchedTransfer.new nil, uuid: 1234, to: "5555"
9
+ cmd.raw.should == 'sched_transfer +1 1234 5555 xml default'
10
+ end
11
+
12
+ it "FSR::Cmd::SchedTransfer should schedule a hangup with user-supplied time " do
13
+ cmd = FSR::Cmd::SchedTransfer.new nil, uuid: 1234, to: "5555", when: 60
14
+ cmd.raw.should == 'sched_transfer +60 1234 5555 xml default'
15
+ end
16
+
17
+ it "FSR::Cmd::SchedHangup should schedule a hangup with user-supplied context" do
18
+ cmd = FSR::Cmd::SchedTransfer.new nil, uuid: 1234, context: "my_context", to: "5555"
19
+ cmd.raw.should == 'sched_transfer +1 1234 5555 xml my_context'
20
+ end
21
+
22
+ it "FSR::Cmd::SchedTransfer should raise when not given uuid or to: extension" do
23
+ lambda { cmd = FSR::Cmd::SchedTransfer.new nil, to: '5555' }.should.raise ArgumentError
24
+ lambda { cmd = FSR::Cmd::SchedTransfer.new nil, uuid: 1234 }.should.raise ArgumentError
25
+ end
26
+ end
@@ -0,0 +1,27 @@
1
+ require './spec/helper'
2
+ require "fsr/cmd"
3
+ FSR::Cmd.load_command("uuid_transfer")
4
+
5
+ describe "Testing FSR::Cmd::UuidTransfer" do
6
+ ## UUID Transfer ##
7
+ #uuid_transfer <uuid> [-bleg|-both] <dest-exten> [<dialplan>] [<context>]
8
+ it "FSR::Cmd::UuidTransfer should Transfer with defaults" do
9
+ cmd = FSR::Cmd::UuidTransfer.new nil, uuid: 1234, to: "5555"
10
+ cmd.raw.should == 'uuid_transfer 1234 -bleg 5555 xml default'
11
+ end
12
+
13
+ it "FSR::Cmd::UuidTransfer should transfer with user-supplied context" do
14
+ cmd = FSR::Cmd::UuidTransfer.new nil, uuid: 1234, context: "my_context", to: "5555"
15
+ cmd.raw.should == 'uuid_transfer 1234 -bleg 5555 xml my_context'
16
+ end
17
+
18
+ it "FSR::Cmd::UuidTransfer should transfer both legs" do
19
+ cmd = FSR::Cmd::UuidTransfer.new nil, uuid: 1234, both: true, to: "5555"
20
+ cmd.raw.should == 'uuid_transfer 1234 -both 5555 xml default'
21
+ end
22
+
23
+ it "FSR::Cmd::UuidTransfer should raise when not given uuid or to: extension" do
24
+ lambda { cmd = FSR::Cmd::UuidTransfer.new nil, to: '5555' }.should.raise ArgumentError
25
+ lambda { cmd = FSR::Cmd::UuidTransfer.new nil, uuid: 1234 }.should.raise ArgumentError
26
+ end
27
+ end
data/spec/fsr/loading.rb CHANGED
@@ -16,7 +16,7 @@ describe "Testing FSR module loading methods" do
16
16
 
17
17
  # When you add commands you must modify the expected cmds_loaded behavior
18
18
  it "Loads all commands" do
19
- all_commands = [:uuid_dump, :originate, :sofia, :fsctl, :sofia_contact, :status, :calls, :call_center, :channels, :enum, :sched_hangup] # If you add a command add it to this set
19
+ all_commands = [:uuid_dump, :originate, :sofia, :fsctl, :sofia_contact, :status, :calls, :call_center, :channels, :enum, :sched_hangup, :sched_transfer, :uuid_transfer] # If you add a command add it to this set
20
20
  cmds_loaded = FSR.load_all_commands
21
21
  cmds_loaded.kind_of?(Array).should == true
22
22
  all_commands.each do |cmd|
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 5
8
- - 10
9
- version: 0.5.10
8
+ - 11
9
+ version: 0.5.11
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jayson Vaughn
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-02-17 00:00:00 -06:00
20
+ date: 2011-02-18 00:00:00 -06:00
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -86,12 +86,14 @@ files:
86
86
  - lib/fsr/cmd/fsctl.rb
87
87
  - lib/fsr/cmd/originate.rb
88
88
  - lib/fsr/cmd/sched_hangup.rb
89
+ - lib/fsr/cmd/sched_transfer.rb
89
90
  - lib/fsr/cmd/sofia.rb
90
91
  - lib/fsr/cmd/sofia/profile.rb
91
92
  - lib/fsr/cmd/sofia/status.rb
92
93
  - lib/fsr/cmd/sofia_contact.rb
93
94
  - lib/fsr/cmd/status.rb
94
95
  - lib/fsr/cmd/uuid_dump.rb
96
+ - lib/fsr/cmd/uuid_transfer.rb
95
97
  - lib/fsr/command_socket.rb
96
98
  - lib/fsr/database.rb
97
99
  - lib/fsr/database/call_limit.rb
@@ -155,9 +157,11 @@ files:
155
157
  - spec/fsr/cmd/enum.rb
156
158
  - spec/fsr/cmd/originate.rb
157
159
  - spec/fsr/cmd/sched_hangup.rb
160
+ - spec/fsr/cmd/sched_transfer.rb
158
161
  - spec/fsr/cmd/sofia.rb
159
162
  - spec/fsr/cmd/sofia/profile.rb
160
163
  - spec/fsr/cmd/uuid_dump.rb
164
+ - spec/fsr/cmd/uuid_transfer.rb
161
165
  - spec/fsr/file_methods.rb
162
166
  - spec/fsr/listener.rb
163
167
  - spec/fsr/listener/header_and_content_response.rb
@@ -401,9 +405,11 @@ test_files:
401
405
  - spec/fsr/cmd/enum.rb
402
406
  - spec/fsr/cmd/originate.rb
403
407
  - spec/fsr/cmd/sched_hangup.rb
408
+ - spec/fsr/cmd/sched_transfer.rb
404
409
  - spec/fsr/cmd/sofia.rb
405
410
  - spec/fsr/cmd/sofia/profile.rb
406
411
  - spec/fsr/cmd/uuid_dump.rb
412
+ - spec/fsr/cmd/uuid_transfer.rb
407
413
  - spec/fsr/file_methods.rb
408
414
  - spec/fsr/listener.rb
409
415
  - spec/fsr/listener/header_and_content_response.rb