Better way to write responses #6

Closed
wants to merge 2 commits into from

2 participants

@andrehjr

I'm building response blocks in the project I'm working on like these, It's fairly simple and way more readable for me.

I think this would be a nice addition to twilio, what do you guys think?

@andrewmbenton

we just released a new version of the twilio ruby library called twilio-ruby. it includes a utility for building twiml responses that uses builder for xml. the class is here:

https://github.com/twilio/twilio-ruby/blob/master/lib/twilio-ruby/twiml/response.rb

and here's how you'd use it:

response = Twilio::TwiML::Response.new do |r|
  r.Say 'hello there'
end

puts response.text #=> "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Response><Say>hello there</Say></Response>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment