ifbyphone_response 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NWJhYWFhOWFjNzY1OTBjODVlNTc0MDE1YTNmMmExMzczNDQwNTIyOQ==
5
+ data.tar.gz: !binary |-
6
+ MGViNzQ3MDM5MmFhNWEyNjU2ZjZhZjZlODZlYzQ3NzRlNDMxMDM2Mg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ YTRmYmY2OWRmZjkwM2Y5YTkxNGI1NzIxM2RkMjQ2Y2Q0NDZjNmY2NmNiNDhk
10
+ ZmQ4MjRkZTNkYTIxNWE4MzhkZGRhMTE0NjRhN2JiNDY1NzYyNzUzOGJiMjgx
11
+ N2Y3NjQ3OTcxOWViNzE4NGVmZGQ2NDg5NzM2NDY0OWVjOWZhMDE=
12
+ data.tar.gz: !binary |-
13
+ MjRmMTU3ZDQ0YjgwMzJlZTJiMDk3OTBhZmZmN2NiNTM3YjI2NDFlOTNjOWNh
14
+ NTY1NzVjOTI2OWE1NjYxYjEyZmQwNGVjYzQxMmNjYTVkODE1YTVjNTAzYTlm
15
+ MjVmMTEzM2MzNzY3ZmFjNzQyZDIxYjhkYjVlZDQ2N2ZhNGU1ZDg=
@@ -0,0 +1,39 @@
1
+ Ifbyphone XML Generator
2
+ =======================
3
+
4
+ [![Build Status](https://travis-ci.org/Opus1no2/Ifbyphone-Responses-Gem.png)](https://travis-ci.org/Opus1no2/Ifbyphone-Responses-Gem)
5
+
6
+ A simple interface for creating valid Ifbyphone XML structures
7
+
8
+ Installation
9
+ ------------
10
+
11
+ ```sh
12
+ gem install ifbypone_response
13
+ ```
14
+
15
+ Usage
16
+ -----
17
+
18
+ Using the gem is easy:
19
+
20
+ ```ruby
21
+
22
+ require 'ifbyphone_response'
23
+
24
+ route = Route.new
25
+
26
+ # Performa a blind transfer
27
+ route.transfer(952457****)
28
+
29
+ # Route to an IVR
30
+ route.survo(1234)
31
+
32
+ # Gracefully end a call
33
+ route.hangup
34
+
35
+ ```
36
+
37
+ License
38
+ --------
39
+ MIT
@@ -0,0 +1,108 @@
1
+ require 'rexml/document'
2
+
3
+ class Route
4
+ include REXML
5
+
6
+ # Initialize new dom doc and global elements
7
+ def initialize
8
+ @doc = Document.new
9
+ @action = @doc.add_element('action')
10
+ @param = Element.new('parameter')
11
+ end
12
+
13
+ # Performa a blind transfer
14
+ #
15
+ # @param [int] num | transfer number
16
+ # @return [string]
17
+ def transfer(num)
18
+ @action.add_element('app').text = 'transfer'
19
+ @action.add_element(@param)
20
+ @param.add_element('destination').text = num
21
+ return @doc.to_s
22
+ end
23
+
24
+ # Route a caller to an IVR app
25
+ #
26
+ # @param [int] id | IVR ID
27
+ # @param [hash] usr_param | customer user parameters
28
+ # @pt [string] | user defined string
29
+ # @return [string]
30
+ def survo(id, usr_param={}, pt='')
31
+ self.helper('survo', id)
32
+
33
+ if usr_param.any?
34
+ params = @param.add_element('user_params')
35
+ usr_param.each do |k,v|
36
+ params.add_element(k).text = v
37
+ end
38
+ end
39
+
40
+ unless pt.nil?
41
+ @param.add_element('pt').text = pt
42
+ end
43
+ return @doc.to_s
44
+ end
45
+
46
+ # Route caller to a findme (hunt group) app
47
+ #
48
+ # @param [int] id | findme ID
49
+ # @return [string]
50
+ def findme(id)
51
+ self.helper('findme',id)
52
+ return @doc.to_s
53
+ end
54
+
55
+ # Dynamically create a hunt group
56
+ #
57
+ # @param [array] list | list of transfer numbers
58
+ # @param [hash] config | additional options
59
+ # @return [string]
60
+ def findme_list(list, config={})
61
+ @action.add_element('app').text = 'findme'
62
+ @action.add_element(@param)
63
+ @param.add_element('phone_list').text = list.join('|')
64
+
65
+ if config.any?
66
+ config.each do |k,v|
67
+ @param.add_element(k).text = v
68
+ end
69
+ end
70
+ return @doc.to_s
71
+ end
72
+
73
+ # Route caller to a virtual receptionist
74
+ #
75
+ # @param [int] id | VR ID
76
+ # @return [string]
77
+ def virtual_receptionist(id)
78
+ self.helper('vr',id)
79
+ return @doc.to_s
80
+ end
81
+
82
+ # Route caller to a voicemail app
83
+ #
84
+ # @param [int] int | VM ID
85
+ # @return [string]
86
+ def voicemail(id)
87
+ self.helper('voicemail',id)
88
+ return @doc.to_s
89
+ end
90
+
91
+ # Gracefully hangu up a call
92
+ #
93
+ # @return [string]
94
+ def hangup
95
+ @action.add_element('app').text = 'hangup'
96
+ return @doc.to_s
97
+ end
98
+
99
+ # Convenience method
100
+ #
101
+ # @param [string] app
102
+ # @param [int] id
103
+ def helper(app, id)
104
+ @action.add_element('app').text = app
105
+ @action.add_element(@param)
106
+ @param.add_element('id').text = id
107
+ end
108
+ end
@@ -0,0 +1,66 @@
1
+ # encoding: utf-8
2
+
3
+ require File.join(File.dirname(__FILE__), '..', 'lib', 'ifbyphone_response')
4
+
5
+ describe Route do
6
+
7
+ before(:each) do
8
+ @route = Route.new
9
+ end
10
+
11
+ describe "#hangup" do
12
+ it 'Should respond with valid xml' do
13
+ result = @route.hangup
14
+ result.should eql '<action><app>hangup</app></action>'
15
+ end
16
+ end
17
+
18
+ describe "#transfer" do
19
+ it 'should respond with valid xml' do
20
+ result = @route.voicemail(1234)
21
+ result.should == '<action><app>voicemail</app><parameter><id>1234</id></parameter></action>'
22
+ end
23
+ end
24
+
25
+ describe "#trasnfer" do
26
+ it 'should respond with valid xml' do
27
+ result = @route.transfer(1112223333)
28
+ result.should == '<action><app>transfer</app><parameter><destination>1112223333</destination></parameter></action>'
29
+ end
30
+ end
31
+
32
+ describe "#survo" do
33
+ it 'should respond with valid xml' do
34
+ result = @route.survo(1234, {'foo' => 'bar'}, 'passthrough')
35
+ result.should == '<action><app>survo</app><parameter><id>1234</id><user_params><foo>bar</foo></user_params><pt>passthrough</pt></parameter></action>'
36
+ end
37
+ end
38
+
39
+ describe "#findme" do
40
+ it 'should respond with valid xml' do
41
+ result = @route.findme(1234)
42
+ result.should == '<action><app>findme</app><parameter><id>1234</id></parameter></action>'
43
+ end
44
+ end
45
+
46
+ describe "#findme_list" do
47
+ it 'should respond with valid xml' do
48
+ result = @route.findme_list([1112223333, 2223334444], {'nextactionitem' => 7})
49
+ result.should == '<action><app>findme</app><parameter><phone_list>1112223333|2223334444</phone_list><nextactionitem>7</nextactionitem></parameter></action>'
50
+ end
51
+ end
52
+
53
+ describe "#virtual_receptionist" do
54
+ it 'should resond with valid xml' do
55
+ result = @route.virtual_receptionist(1234)
56
+ result.should == '<action><app>vr</app><parameter><id>1234</id></parameter></action>'
57
+ end
58
+ end
59
+
60
+ describe "#voicemail" do
61
+ it 'should respond wiht valid xml' do
62
+ result = @route.voicemail(1234)
63
+ result.should == '<action><app>voicemail</app><parameter><id>1234</id></parameter></action>'
64
+ end
65
+ end
66
+ end
metadata ADDED
@@ -0,0 +1,50 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ifbyphone_response
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Travis Tillotson
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-07-27 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Convenience class that provides an interface for creating valid Ifbyphone
14
+ XML responses
15
+ email:
16
+ - tillotson.travis@gmail.com
17
+ executables: []
18
+ extensions: []
19
+ extra_rdoc_files:
20
+ - README.md
21
+ files:
22
+ - lib/ifbyphone_response.rb
23
+ - README.md
24
+ - spec/ifbyphone_response_spec.rb
25
+ homepage: https://github.com/Opus1no2/Ifbyphone-response-Gem
26
+ licenses:
27
+ - MIT
28
+ metadata: {}
29
+ post_install_message:
30
+ rdoc_options: []
31
+ require_paths:
32
+ - lib
33
+ required_ruby_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ required_rubygems_version: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ! '>='
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ requirements: []
44
+ rubyforge_project:
45
+ rubygems_version: 2.0.4
46
+ signing_key:
47
+ specification_version: 4
48
+ summary: Interface for creating valid XML responses
49
+ test_files:
50
+ - spec/ifbyphone_response_spec.rb