Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 38 lines (30 sloc) 1.174 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
require "google_spreadsheet"
require "sinatra"
require "json"
require "smsified"

post '/' do
   response = JSON.parse(request.env["rack.input"].read)
                             
   message = response["inboundSMSMessageNotification"]["inboundSMSMessage"]["message"]
   callerID = response["inboundSMSMessageNotification"]["inboundSMSMessage"]["senderAddress"]
   trigger = message[0..1]
   datetime = message[3..message.length]
   
   if trigger == "Go"
    
    smsified = Smsified::OneAPI.new(:username => 'sms_user', :password => 'sms_pass')
    oneapi.send_sms :sender_address => '13215550100', :address => ['14075550100', '19545550100', '13055550100'], :message => "Can you make it to the game on #{datetime}?"

   else
    session = GoogleSpreadsheet.login("goog_user", "goog_pass")
    ws = session.spreadsheet_by_key("YOUR_SPREADSHEET_KEY").worksheets[0]

    if callerID == "tel:+14075550100"
      ws[2, 1] = message
      ws.save()
    elsif callerID == "tel:+19545550100"
      ws[2, 2] = message
      ws.save()
    elsif callerID == "tel:+13055550100"
      ws[2, 3] = message
      ws.save()
    else
      p "Not on the list"
    end
    
  end
  
end
Something went wrong with that request. Please try again.