class SquareEvent::Webhook

Public Class Methods

construct_event(payload, signature, secret, notification_url, environment, timestamp) click to toggle source

Initializes an webook Event object from a JSON payload.

TODO: raise JSON::ParserError if the payload is not valid JSON, or SignatureVerificationError if the signature verification fails.

# File lib/square_event/webhook.rb, line 8
def self.construct_event(payload, signature, secret, notification_url, environment, timestamp)

  Signature.verify_header(payload, signature, secret, notification_url)

  data = JSON.parse(payload, symbolize_names: true)
  Event.construct_from(data, environment, timestamp)
end