Class: SipgateIo::XmlResponse

Inherits:
Object
  • Object
show all
Defined in:
lib/sipgate_io/xml_response.rb

Class Method Summary collapse

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(options = {})
  anonymous = options[:clip] == :anonymous ? Hash[ anonymous: true ] : nil
  caller_id = !!/\d+/.match(options[:clip]) ? Hash[ callerId: options[:clip] ] : nil

  builder(options) do |b|
    b.Dial(anonymous, caller_id) do |b|
      options[:target] == :voicemail ? b.Voicemail : b.Number(options[: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(options = {})
  on_data = Hash[ onData: SipgateIo.configuration.callback_url ]
  max_digits = parse_option(options, :max_digits, :maxDigits)
  timeout = parse_option(options, :timeout)
  play_url = options.key?(:soundfile_url) ? options[:soundfile_url] : nil

  builder(options) 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(options = {})
  builder(options) { |b| b.Hangup }
end

.on_answerObject



51
52
53
# File 'lib/sipgate_io/xml_response.rb', line 51

def on_answer
  builder(Hash[ callback: :on_answer ])
end

.on_hangupObject



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(options = {})
  url = options[:soundfile_url]

  builder(options) { |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(options = {})
  reason = parse_option(options, :reason)

  builder(options) { |b| b.Reject(reason) }
end