Module: Type0

Defined in:
lib/type0.rb,
lib/type0/version.rb

Constant Summary collapse

VERSION =
"0.1.1.3"

Class Method Summary collapse

Class Method Details

.request_token(app_key) ⇒ Object



8
9
10
11
12
13
# File 'lib/type0.rb', line 8

def self.request_token(app_key)
  uri = URI("https://typezero.herokuapp.com/api/auth/#{app_key}")
  res = Net::HTTP.get_response(uri)
  #res = JSON.parse(res.body)
  #encrypted_value = res['request_token']
end

.send_mail(encrypted_value, app_key, from, to, body) ⇒ Object



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