-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.rb
26 lines (21 loc) · 772 Bytes
/
app.rb
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
require 'Telstra_Messaging'
require 'sendgrid-ruby'
include SendGrid
require 'sinatra'
class Application < Sinatra::Base
get '/' do
'hello world'
end
post '/' do
params = JSON.parse request.body.read
puts params['to']
from = Email.new(email: 'from email here')
to = Email.new(email: 'to email here')
subject = 'SMS from ' + params['from'] + ' sent to ' + params['to']
content = Content.new(type: 'text/plain', value: 'An sms from '+params['to'] + ' has been recieved with the following message > "' + params['body'] + '"')
mail = Mail.new(from, subject, to, content)
sg = SendGrid::API.new(api_key: 'sendgrid token in here')
response = sg.client.mail._('send').post(request_body: mail.to_json)
puts response
end
end