Class: SmoothCodeAuth
- Inherits:
-
Object
- Object
- SmoothCodeAuth
- Defined in:
- lib/smoothcode/auth.rb
Instance Method Summary collapse
- #dashboard_request?(shop) ⇒ Boolean
-
#initialize(request_hmac, client_secret) ⇒ SmoothCodeAuth
constructor
A new instance of SmoothCodeAuth.
- #webhook_request?(webhook_data) ⇒ Boolean
Constructor Details
#initialize(request_hmac, client_secret) ⇒ SmoothCodeAuth
Returns a new instance of SmoothCodeAuth.
4 5 6 7 |
# File 'lib/smoothcode/auth.rb', line 4 def initialize(request_hmac, client_secret) @request_hmac = request_hmac @client_secret = client_secret end |
Instance Method Details
#dashboard_request?(shop) ⇒ Boolean
9 10 11 |
# File 'lib/smoothcode/auth.rb', line 9 def dashboard_request?(shop) generate_hmac(@client_secret, shop) == @request_hmac end |
#webhook_request?(webhook_data) ⇒ Boolean
13 14 15 16 17 18 |
# File 'lib/smoothcode/auth.rb', line 13 def webhook_request?(webhook_data) webhook_data = webhook_data.transform_keys(&:to_sym) webhook_id = webhook_data[:id] generate_hmac(@client_secret, webhook_id.to_s) == @request_hmac end |