Skip to content

Commit

Permalink
Update examples to use instance methods (#21)
Browse files Browse the repository at this point in the history
We forgot to update our examples to use instance methods, instead of
class methods.

Co-authored-by: Stanislav (Stas) Katkov <[email protected]>
  • Loading branch information
Stanislav (Stas) Katkov and Stanislav (Stas) Katkov authored Nov 27, 2024
1 parent 7444b67 commit 096ded8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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

0 comments on commit 096ded8

Please sign in to comment.