lib/twilio-ruby/twiml/voice_response.rb in twilio-ruby-5.0.0.rc24 vs lib/twilio-ruby/twiml/voice_response.rb in twilio-ruby-5.0.0.rc25
- old
+ new
@@ -5,10 +5,11 @@
class VoiceResponse < TwiML
# Create a new <Response>
def initialize()
super()
self.name = 'Response'
+ yield(self) if block_given?
end
# Create a <Dial> element
#
# == Parameters:
@@ -26,37 +27,41 @@
# keyword_args:: additional attributes
#
# == Returns:
# A <Response> element with a <Dial> child element
def dial(
- number,
- action: nil,
- method: nil,
- timeout: nil,
- hangup_on_star: nil,
- time_limit: nil,
- caller_id: nil,
- record: nil,
- trim: nil,
- recording_status_callback: nil,
- recording_status_callback_method: nil,
- **keyword_args)
+ number,
+ action: nil,
+ method: nil,
+ timeout: nil,
+ hangup_on_star: nil,
+ time_limit: nil,
+ caller_id: nil,
+ record: nil,
+ trim: nil,
+ recording_status_callback: nil,
+ recording_status_callback_method: nil,
+ **keyword_args)
- self.append(Dial.new(
- number: number,
- action: action,
- method: method,
- timeout: timeout,
- hangup_on_star: hangup_on_star,
- time_limit: time_limit,
- caller_id: caller_id,
- record: record,
- trim: trim,
- recording_status_callback: recording_status_callback,
- recording_status_callback_method: recording_status_callback_method,
- **keyword_args
- ))
+ dial = Dial.new(
+ number: number,
+ action: action,
+ method: method,
+ timeout: timeout,
+ hangup_on_star: hangup_on_star,
+ time_limit: time_limit,
+ caller_id: caller_id,
+ record: record,
+ trim: trim,
+ recording_status_callback: recording_status_callback,
+ recording_status_callback_method: recording_status_callback_method,
+ **keyword_args
+ )
+
+ yield(dial) if block_given?
+
+ self.append(dial)
end
# Create an <Echo> element
#
# == Parameters:
@@ -88,19 +93,23 @@
wait_url: nil,
wait_url_method: nil,
workflow_sid: nil,
**keyword_args)
- self.append(Enqueue.new(
+ enqueue = Enqueue.new(
name,
action: action,
method: method,
wait_url: wait_url,
wait_url_method: wait_url_method,
workflow_sid: workflow_sid,
**keyword_args
- ))
+ )
+
+ yield(enqueue) if block_given?
+
+ self.append(enqueue)
end
# Create a <Gather> element
#
# == Parameters:
@@ -131,11 +140,11 @@
hints: nil,
barge_in: nil,
acknowledge_sound_url: nil,
**keyword_args)
- self.append(Gather.new(
+ gather = Gather.new(
action: action,
method: method,
timeout: timeout,
finish_on_key: finish_on_key,
num_digits: num_digits,
@@ -144,11 +153,15 @@
language: language,
hints: hints,
barge_in: barge_in,
acknowledge_sound_url: acknowledge_sound_url,
**keyword_args
- ))
+ )
+
+ yield(gather) if block_given?
+
+ self.append(gather)
end
# Create a <Hangup> element
#
# == Returns:
@@ -185,11 +198,16 @@
# keyword_args:: additional attributes
#
# == Returns:
# A <Response> element with a <Play> child element
def play(url: nil, loop: nil, digits: nil, **keyword_args)
- append(Play.new(url: url, loop: loop, digits: digits, **keyword_args))
+ self.append(Play.new(
+ url: url,
+ loop: loop,
+ digits: digits,
+ **keyword_args
+ ))
end
# Create a <Record> element
#
# == Parameters:
@@ -219,11 +237,10 @@
recording_status_callback: nil,
recording_status_callback_method: nil,
transcribe: nil,
transcribe_callback: nil,
**keyword_args)
-
self.append(Record.new(
action: action,
method: method,
timeout: timeout,
finish_on_key: finish_on_key,
@@ -303,11 +320,10 @@
from: nil,
method: nil,
action: nil,
status_callback: nil,
**keyword_args)
-
self.append(Sms.new(
body,
to: to,
from: from,
method: method,
@@ -331,10 +347,11 @@
def initialize(number: nil, **keyword_args)
super(**keyword_args)
if !(number.nil?)
@value = number
end
+ yield(self) if block_given?
end
# Create a <Client> element
#
# == Parameters:
@@ -354,11 +371,10 @@
url: nil,
status_callback_event: nil,
status_callback_method: nil,
status_callback: nil,
**keyword_args)
-
self.append(Client.new(
name,
method: method,
url: url,
status_callback_event: status_callback_event,
@@ -407,11 +423,10 @@
status_callback_event: nil,
status_callback_method: nil,
recording_status_callback: nil,
recording_status_callback_method: nil,
**keyword_args)
-
self.append(Conference.new(
name,
muted: muted,
start_conference_on_enter: start_conference_on_enter,
end_conference_on_exit: end_conference_on_exit,
@@ -452,11 +467,10 @@
method: nil,
status_callback: nil,
status_callback_event: nil,
status_callback_method: nil,
**keyword_args)
-
self.append(Number.new(
number,
send_digits: send_digits,
url: url,
method: method,
@@ -484,11 +498,10 @@
url: nil,
method: nil,
reservation_sid: nil,
post_work_activity_sid: nil,
**keyword_args)
-
self.append(Queue.new(
queue_name,
url: url,
method: method,
reservation_sid: reservation_sid,
@@ -504,11 +517,11 @@
# keyword_args:: additional attributes
#
# == Returns:
# A <Dial> element with a <Sim> child element
def sim(sid, **keyword_args)
- self.append(Sim.new(sid,**keyword_args))
+ self.append(Sim.new(sid, **keyword_args))
end
# Create a <Sip> element
#
# == Parameters:
@@ -532,11 +545,10 @@
method: nil,
status_callback: nil,
status_callback_event: nil,
status_callback_method: nil,
**keyword_args)
-
self.append(Sip.new(
uri,
username: username,
password: password,
url: url,
@@ -669,10 +681,11 @@
# == Returns:
# A <Enqueue> element
def initialize(name, **keyword_args)
super(**keyword_args)
@value = name
+ yield(self) if block_given?
end
# Create a <Task> element
#
# == Parameters:
@@ -715,10 +728,11 @@
#
# == Returns:
# A <Gather> element
def initialize(**keyword_args)
super(**keyword_args)
+ yield(self) if block_given?
end
# Create a <Say> element
#
# == Parameters:
@@ -735,11 +749,10 @@
body,
loop: nil,
language: nil,
voice: nil,
**keyword_args)
-
self.append(Say.new(
body,
loop: loop,
language: language,
voice: voice,
@@ -756,10 +769,15 @@
# keyword_args:: additional attributes
#
# == Returns:
# A <Gather> element with a <Play> child element
def play(url: nil, loop: nil, digits: nil, **keyword_args)
- append(Play.new(url: url, loop: loop, digits: digits, **keyword_args))
+ self.append(Play.new(
+ url: url,
+ loop: loop,
+ digits: digits,
+ **keyword_args
+ ))
end
# Create a <Pause> element
#
# == Parameters: