Skip to content

Instantly share code, notes, and snippets.

@mecampbellsoup
Created March 31, 2015 19:21
Show Gist options
  • Select an option

  • Save mecampbellsoup/c6cfba58a58a4bd4ab05 to your computer and use it in GitHub Desktop.

Select an option

Save mecampbellsoup/c6cfba58a58a4bd4ab05 to your computer and use it in GitHub Desktop.
module SMSWallet
class TwimlBuilder
def initialize(user)
@user = user
@response = Twilio::TwiML::Response.new do |r|
r.Gather method: method, action: action, numDigits: 4 do |g|
r.Say message
end
r.Say "We didn't receive any input. Goodbye!"
end
end
def text
response.text
end
private
attr_reader :response, :user
def message
message = I18n.t("twiml.hello", name: user.name)
message += if user.active?
I18n.t("twiml.active_user_pin")
else
I18n.t("twiml.new_user_pin")
end
end
def method
"POST"
end
def action
"/sms_transactions"
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment