module Twilio module TwiML # Messaging TwiML Response class MessagingResponse < TwiML # Create a new def initialize super() self.name = 'Response' yield(self) if block_given? end # Create a element # # == Parameters: # body:: body of the message # to:: number to send to # from_:: number to send from # method:: action HTTP method # action:: action URL # status_callback:: callback URL # keyword_args:: additional attributes # # == Returns: # A element with a child element def message(body: nil, to: nil, from: nil, method: nil, action: nil, status_callback: nil, **keyword_args) message = Message.new( body: body, to: to, from: from, method: method, action: action, status_callback: status_callback, **keyword_args ) yield(message) if block_given? append(message) end # Create an element # # == Parameters: # url:: URL to redirect to # method:: HTTP method # keyword_args:: attributes # # == Returns: # A element with an child element def redirect(url, method: nil, **keyword_args) append(Redirect.new(url, method: method, **keyword_args)) end end # element class Message < TwiML # Create a element # # == Parameters: # body:: message body # keyword_args:: additional attributes # # == Returns: # A element def initialize(body: nil, **keyword_args) super(**keyword_args) @value = body unless body.nil? yield(self) if block_given? end # Create a element # # == Parameters: # body:: body of message # keyword_args:: additional attributes # # == Returns: # A element with a child element def body(body) append(Body.new(body)) end # Create a element # # == Parameters: # body:: body of message # keyword_args:: additional attributes # # == Returns: # A element with a child element def media(url) append(Media.new(url)) end end # element class Body < TwiML # Create a element # # == Parameters: # body:: message body # # == Returns: # A element def initialize(body) super() @value = body end end # element class Media < TwiML # Create a element # # == Parameters: # url:: media URL location # # == Returns: # A element def initialize(url) super() @value = url end end # element class Redirect < TwiML # Create a element # # == Parameters: # url:: redirect URL location # keyword_args:: additional attributes # # == Returns: # A element def initialize(url, **keyword_args) super(**keyword_args) @value = url end end end end