Last active
August 29, 2015 14:23
-
-
Save mediocretes/ef8bfdee4e58fe1eb8b8 to your computer and use it in GitHub Desktop.
Delegating webhook events to other methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EVENTS_ABOUT_WHICH_WE_CARE = ["payment_success", "billing_date_change"] | |
def handle_event | |
event = params["event"] | |
payload = params["payload"] | |
return head(:unprocessable_entity) unless if event.blank? || payload.blank? | |
return head(:ok) unless EVENTS_ABOUT_WHICH_WE_CARE.include?(event) | |
self.send(event, payload) | |
end | |
private | |
def payment_success(payload) | |
# do things | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment