Class: ShopifyWebhook::Endpoint

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify_webhook/endpoint.rb

Instance Method Summary collapse

Constructor Details

#initialize(secret) ⇒ Endpoint

Returns a new instance of Endpoint.



4
5
6
# File 'lib/shopify_webhook/endpoint.rb', line 4

def initialize(secret)
  @secret = secret
end

Instance Method Details

#call(env) ⇒ Object



8
9
10
11
12
13
14
15
16
17
# File 'lib/shopify_webhook/endpoint.rb', line 8

def call(env)
  request = Rack::Request.new env

  if ShopifyWebhook::Verifier.new(request, secret).call
    instrument 'notification.shopify.webhook', json: json(request)
    [200, {}, ['']]
  else
    [400, {}, ['']]
  end
end