Module: Auth::Concerns::NotificationResponseConcern::ClassMethods

Defined in:
app/models/auth/concerns/notification_response_concern.rb

Instance Method Summary collapse

Instance Method Details

#find_and_update_notification_response(webhook_identifier, params, &block) ⇒ Object

&block, optional block. return the notification_response object, after adding the response to it and saving it, if it was found yields the provided block after calling save. check the notification_response to see if it was successfully saved. return nil otherwise, and logs a rails error.

Parameters:

  • webhook_identifier (String)

    : an identifier by which to search for a notification response object

  • params (String)

    : a JSON string of whatever was received from the webhook request.



55
56
57
58
59
60
61
62
63
64
65
66
# File 'app/models/auth/concerns/notification_response_concern.rb', line 55

def find_and_update_notification_response(webhook_identifier,params,&block)
	puts "webhook identifier is: #{webhook_identifier}"
	if notification_response = Auth.configuration.notification_response_class.constantize.where(:webhook_identifier => webhook_identifier)
 		notification_response = notification_response.first
 		notification_response.add_response(params)
 		notification_response.save
 		yield(notification_response) if block_given?
 		notification_response
 	else
 		Rails.logger.error("webhook identifier not found: #{webhook_identifier}")
 	end
end