Class: ShopifyClient::CreateAllWebhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/shopify-client/create_all_webhooks.rb

Instance Method Summary collapse

Instance Method Details

#call(client) ⇒ Array<Hash>

Create all registered webhooks for a shop.

Parameters:

Returns:

  • (Array<Hash>)

    response data



10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/shopify-client/create_all_webhooks.rb', line 10

def call(client)
  create_webhook = CreateWebhook.new

  ShopifyClient.webhooks.map do |topic, options|
    Thread.new do
      webhook = {}.tap do |webhook|
        webhook[:topic] = topic
        webhook[:fields] = options[:fields] unless options[:fields].empty?
      end

      create_webhook.(client, webhook)
    end
  end.map(&:value)
end