Class: SipgateIo::XmlResponse
- Inherits:
-
Object
- Object
- SipgateIo::XmlResponse
- Defined in:
- lib/sipgate_io/xml_response.rb
Class Method Summary collapse
- .dial(options = {}) ⇒ Object
- .gather(options = {}) ⇒ Object
- .hangup(options = {}) ⇒ Object
- .on_answer ⇒ Object
- .on_hangup ⇒ Object
- .play(options = {}) ⇒ Object
- .reject(options = {}) ⇒ Object
Class Method Details
.dial(options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/sipgate_io/xml_response.rb', line 7 def dial( = {}) anonymous = [:clip] == :anonymous ? Hash[ anonymous: true ] : nil caller_id = !!/\d+/.match([:clip]) ? Hash[ callerId: [:clip] ] : nil builder() do |b| b.Dial(anonymous, caller_id) do |b| [:target] == :voicemail ? b.Voicemail : b.Number([:target]) end end end |
.gather(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/sipgate_io/xml_response.rb', line 24 def gather( = {}) on_data = Hash[ onData: SipgateIo.configuration.callback_url ] max_digits = parse_option(, :max_digits, :maxDigits) timeout = parse_option(, :timeout) play_url = .key?(:soundfile_url) ? [:soundfile_url] : nil builder() do |b| b.Gather(on_data, max_digits, timeout) do |b| unless play_url.nil? b.Play { |b| b.Url(play_url) } end end end end |
.hangup(options = {}) ⇒ Object
47 48 49 |
# File 'lib/sipgate_io/xml_response.rb', line 47 def hangup( = {}) builder() { |b| b.Hangup } end |
.on_answer ⇒ Object
51 52 53 |
# File 'lib/sipgate_io/xml_response.rb', line 51 def on_answer builder(Hash[ callback: :on_answer ]) end |
.on_hangup ⇒ Object
55 56 57 |
# File 'lib/sipgate_io/xml_response.rb', line 55 def on_hangup builder(Hash[ callback: :on_hangup ]) end |
.play(options = {}) ⇒ Object
18 19 20 21 22 |
# File 'lib/sipgate_io/xml_response.rb', line 18 def play( = {}) url = [:soundfile_url] builder() { |b| b.Play { |b| b.Url(url) } } end |
.reject(options = {}) ⇒ Object
41 42 43 44 45 |
# File 'lib/sipgate_io/xml_response.rb', line 41 def reject( = {}) reason = parse_option(, :reason) builder() { |b| b.Reject(reason) } end |