sipgate_io 0.1.6 → 0.2.0
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.
- checksums.yaml +4 -4
- data/lib/sipgate_io/version.rb +1 -1
- data/lib/sipgate_io/xml_response.rb +34 -50
- data/test/dummy/app/models/event_processor.rb +0 -4
- data/test/dummy/db/schema.rb +0 -0
- data/test/dummy/log/test.log +9093 -0
- data/test/lib/sipgate_io/xml_response_test.rb +140 -7
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b13b762011c328c801c9a905c793b6eaea62c4cc
|
4
|
+
data.tar.gz: b3bc9206cacb88eeed3064a00b547fad894cd61e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fecd57fcc0d9a2e27bbc258befdc98ee974f39420d2061786b412db19179c333d3ed6cbeeddd723ed19cd1509e56db5b16c2a6cf91038ab1612f71c6895e70b3
|
7
|
+
data.tar.gz: 9db396cfca44e8710670c2024ff91c9ab2c84664d1f44b3f3479a6d1daf68c21b43fd34fe6e64b9f5cfd1b747c17b619ad01ca68cacbce77afbe336125402809
|
data/lib/sipgate_io/version.rb
CHANGED
@@ -3,65 +3,63 @@ require 'builder'
|
|
3
3
|
module SipgateIo
|
4
4
|
class XmlResponse
|
5
5
|
|
6
|
-
def self.dial(
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
b.
|
12
|
-
elsif !options[:anonymous].nil?
|
13
|
-
b.Dial(anonymous: true) { |b| b.Number(target) }
|
14
|
-
elsif !options[:caller_id].nil?
|
15
|
-
b.Dial(callerId: options[:caller_id]) { |b| b.Number(target) }
|
6
|
+
def self.dial(options = {})
|
7
|
+
anonymous = options[:clip] == :anonymous ? Hash[ anonymous: true ] : nil
|
8
|
+
caller_id = !!/\d+/.match(options[:clip]) ? Hash[ callerId: options[:clip] ] : nil
|
9
|
+
self.builder.Response(set_callback(options)) do |b|
|
10
|
+
b.Dial(anonymous, caller_id) do |b|
|
11
|
+
options[:target] == :voicemail ? b.Voicemail : b.Number(options[:target])
|
16
12
|
end
|
17
13
|
end
|
18
14
|
end
|
19
15
|
|
20
|
-
def self.play(
|
21
|
-
|
16
|
+
def self.play(options = {})
|
17
|
+
url = options[:soundfile_url]
|
18
|
+
self.builder.Response(set_callback(options)) { |b| b.Play { |b| b.Url(url) } }
|
22
19
|
end
|
23
20
|
|
24
|
-
def self.gather(options =
|
25
|
-
|
26
|
-
options[:
|
27
|
-
options[:
|
28
|
-
options[:
|
29
|
-
|
30
|
-
self.builder.Response do |b|
|
31
|
-
b.Gather(
|
32
|
-
|
33
|
-
timeout
|
34
|
-
unless
|
35
|
-
b.Play { |b| b.Url(
|
21
|
+
def self.gather(options = {})
|
22
|
+
on_data = Hash[ onData: SipgateIo.configuration.callback_url ]
|
23
|
+
max_digits = options.key?(:max_digits) ? Hash[ maxDigits: options[:max_digits] ] : nil
|
24
|
+
timeout = options.key?(:timeout) ? Hash[ timeout: options[:timeout] ] : nil
|
25
|
+
play_url = options.key?(:soundfile_url) ? options[:soundfile_url] : nil
|
26
|
+
|
27
|
+
self.builder.Response(set_callback(options)) do |b|
|
28
|
+
b.Gather(on_data,
|
29
|
+
max_digits,
|
30
|
+
timeout) do |b|
|
31
|
+
unless play_url.nil?
|
32
|
+
b.Play { |b| b.Url(play_url) }
|
36
33
|
end
|
37
34
|
end
|
38
35
|
end
|
39
36
|
end
|
40
37
|
|
41
|
-
def self.reject(
|
42
|
-
|
43
|
-
|
44
|
-
b.Reject
|
45
|
-
else
|
46
|
-
b.Reject(reason: reason)
|
47
|
-
end
|
48
|
-
end
|
38
|
+
def self.reject(options = {})
|
39
|
+
reason = options.key?(:reason) ? Hash[ reason: options[:reason] ] : nil
|
40
|
+
self.builder.Response(set_callback(options)) { |b| b.Reject(reason) }
|
49
41
|
end
|
50
42
|
|
51
|
-
def self.hangup
|
52
|
-
self.builder.Response
|
43
|
+
def self.hangup(options = {})
|
44
|
+
self.builder.Response(set_callback(options)){ |b| b.Hangup }
|
53
45
|
end
|
54
46
|
|
55
47
|
def self.on_answer
|
56
|
-
self.builder.Response(
|
48
|
+
self.builder.Response(set_callback(Hash[ callback: :on_answer ]) )
|
57
49
|
end
|
58
50
|
|
59
51
|
def self.on_hangup
|
60
|
-
self.builder.Response(
|
52
|
+
self.builder.Response(set_callback(Hash[ callback: :on_hangup ]) )
|
61
53
|
end
|
62
54
|
|
63
55
|
private
|
64
56
|
|
57
|
+
def self.set_callback(options)
|
58
|
+
return nil unless options.key?(:callback)
|
59
|
+
type = (options[:callback] == :on_answer) ? :onAnswer : :onHangup
|
60
|
+
Hash[ type => SipgateIo.configuration.callback_url ]
|
61
|
+
end
|
62
|
+
|
65
63
|
def self.builder
|
66
64
|
b = Builder::XmlMarkup.new(indent: 2)
|
67
65
|
b.instruct!
|
@@ -70,17 +68,3 @@ module SipgateIo
|
|
70
68
|
|
71
69
|
end
|
72
70
|
end
|
73
|
-
|
74
|
-
# puts SipgateIo::XmlResponse.gather()
|
75
|
-
# puts SipgateIo::XmlResponse.gather(play_url: "http://google.de")
|
76
|
-
|
77
|
-
# puts SipgateIo::XmlResponse.play("http://google.de")
|
78
|
-
# puts SipgateIo::XmlResponse.dial(:voicemail)
|
79
|
-
# puts SipgateIo::XmlResponse.dial("491234567")
|
80
|
-
# puts SipgateIo::XmlResponse.dial("491234567", anonymous: true)
|
81
|
-
# puts SipgateIo::XmlResponse.dial("491234567", caller_id: "555")
|
82
|
-
|
83
|
-
# puts SipgateIo::XmlResponse.reject
|
84
|
-
# puts SipgateIo::XmlResponse.reject(:busy)
|
85
|
-
# puts SipgateIo::XmlResponse.reject(:rejected)
|
86
|
-
# puts SipgateIo::XmlResponse.hangup
|
File without changes
|