Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@
# Ignore master key for decrypting credentials and more.
/config/master.key


/config/credentials/development.key
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ gem 'geocoder'
# Debugging
gem 'pry'

# SMS
gem 'twilio-ruby', '~> 5.74.0'

# Use Active Storage variants [https://guides.rubyonrails.org/active_storage_overview.html#transforming-images]
# gem "image_processing", "~> 1.2"

Expand Down
14 changes: 12 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ GEM
irb (>= 1.5.0)
reline (>= 0.3.1)
erubi (1.12.0)
faraday (2.7.2)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
geocoder (1.8.1)
globalid (1.0.0)
activesupport (>= 5.0)
Expand All @@ -86,7 +90,7 @@ GEM
io-console (0.6.0)
irb (1.6.2)
reline (>= 0.3.0)
jwt (2.6.0)
jwt (2.5.0)
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
Expand All @@ -98,7 +102,7 @@ GEM
marcel (1.0.2)
method_source (1.0.0)
mini_mime (1.1.2)
minitest (5.16.3)
minitest (5.17.0)
msgpack (1.6.0)
net-imap (0.3.4)
date
Expand Down Expand Up @@ -153,8 +157,13 @@ GEM
rake (13.0.6)
reline (0.3.2)
io-console (~> 0.5)
ruby2_keywords (0.0.5)
thor (1.2.1)
timeout (0.3.1)
twilio-ruby (5.74.0)
faraday (>= 0.9, < 3.0)
jwt (>= 1.5, <= 2.5)
nokogiri (>= 1.6, < 2.0)
tzinfo (2.0.5)
concurrent-ruby (~> 1.0)
websocket-driver (0.7.5)
Expand All @@ -176,6 +185,7 @@ DEPENDENCIES
puma (~> 5.0)
rack-cors
rails (~> 7.0.4)
twilio-ruby (~> 5.74.0)
tzinfo-data

RUBY VERSION
Expand Down
31 changes: 31 additions & 0 deletions app/controllers/sms_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class SmsController < ApplicationController
require "twilio-ruby"

def initialize
@client = Twilio::REST::Client.new account_sid, auth_token
end

def create
@client.messages.create(
from: phone_number,
to: params[:phone_number],
body: params[:body],
)
end

def messages
@client.messages.list(limit: 20)
end

def account_sid
Rails.application.credentials.twilio[:account_sid]
end

def auth_token
Rails.application.credentials.twilio[:auth_token]
end

def phone_number
Rails.application.credentials.twilio[:phone_number]
end
end
1 change: 1 addition & 0 deletions config/credentials/development.yml.enc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I7i1TvjGGlQpAZxmSMUegPfoa1lLg0gQKUsV7ciW349OpK16A5gjkhNRbnQsiny5N8JwSZMj6Y5fLnlFihoY6s4ZQAubfcQ5CWkev4MR7gxasoJICLE1ZU43pg0+mMPLzmN7PrtLOYhevl2IXMJjlhhr1yGX3+iKFlMh8pvraLbgUl5nKlv09yulKaIJhulD--jc/oxRKc+M8tvwYJ--yrPr2uifKIhdCrD3xI/HeA==
4 changes: 3 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@

delete "/trips/:id" => "trips#destroy"

post "/restaurants-lookup" => "restaurants_lookup#new"
post "/restaurants-lookup" => "restaurants_lookup#create"

post "/sms" => "sms#create"
end