15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/type0.rb', line 15
def self.send_mail(encrypted_value, app_key, from, to, body)
decrypted_value = AESCrypt.decrypt(encrypted_value, app_key)
uri = URI("https://typezero.herokuapp.com/api/authenticate/#{decrypted_value}/#{app_key}")
res = Net::HTTP.get_response(uri)
res = JSON.parse(res.body)
status = res['status']
if status == 1
uri = URI('https://typezero.herokuapp.com/api/send_mail')
res = Net::HTTP.post_form(uri, { "from" => from, "to" => to , "body" => body })
puts res.body
else
render :text => "Unsuccessfull authentication"
end
end
|