Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update examples to use instance methods #21

Merged
merged 1 commit into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions handler-examples/revolut_business_v1_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def valid?(_)
true
end

def self.process(webhook)
def process(webhook)
parsed_payload = JSON.parse(webhook.body)
topic = parsed_payload.fetch("Topic")
case topic
Expand All @@ -18,7 +18,7 @@ def self.process(webhook)
end
end

def self.extract_event_id_from_request(action_dispatch_request)
def extract_event_id_from_request(action_dispatch_request)
# Since b-tree indices generally divide from the start of the string, place the highest
# entropy component at the start (the EventId)
key_components = %w[EventId Topic Version]
Expand Down
4 changes: 2 additions & 2 deletions handler-examples/revolut_business_v2_handler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ def valid?(request)
matches.any?
end

def self.process(webhook)
def process(webhook)
Rails.logger.info { "Processing Revolut webhook #{webhook.body.inspect}" }
end

def self.extract_event_id_from_request(action_dispatch_request)
def extract_event_id_from_request(action_dispatch_request)
# The event ID is only available when you retrieve the failed webhooks, which is sad.
# We can divinate a synthetic ID though by taking a hash of the entire payload though.
Digest::SHA256.hexdigest(action_dispatch_request.body.read)
Expand Down