Module: Auth::Mailgun

Included in:
OtpJob
Defined in:
lib/auth/mailgun.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.set_webhook_identifier(notification_response, last_response) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/auth/mailgun.rb', line 10

def self.set_webhook_identifier(notification_response,last_response)
	
	puts "last response is:"
	puts last_response


	last_response = JSON.parse(last_response).deep_symbolize_keys
	notification_response.webhook_identifier = last_response[:webhook_identifier] if not last_response[:webhook_identifier].nil?
end

Instance Method Details

#add_webhook_identifier_to_email(email) ⇒ Object

returns the email after adding a webhook identifier variable.



4
5
6
7
8
# File 'lib/auth/mailgun.rb', line 4

def add_webhook_identifier_to_email(email)
	email.message.mailgun_variables = {}
      	email.message.mailgun_variables["webhook_identifier"] = BSON::ObjectId.new.to_s
      	email
end

#email_webhook(params) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/auth/mailgun.rb', line 21

def email_webhook(params)	
	
	Auth.configuration.notification_response_class.constantize.find_and_update_notification_response(params[:webhook_identifier], JSON.generate(params)) do |notification_response|

		#puts "found email notification response:"
		#puts notification_response.attributes.to_s

	end
end