Class: LucidShopify::DeleteAllWebhooks

Inherits:
Object
  • Object
show all
Defined in:
lib/lucid_shopify/delete_all_webhooks.rb

Instance Method Summary collapse

Constructor Details

#initialize(client: Container[:client], delete_webhook: Container[:delete_webhook]) ⇒ DeleteAllWebhooks

Returns a new instance of DeleteAllWebhooks.

Parameters:

  • client (#get) (defaults to: Container[:client])
  • delete_webhook (#call) (defaults to: Container[:delete_webhook])


11
12
13
14
15
# File 'lib/lucid_shopify/delete_all_webhooks.rb', line 11

def initialize(client: Container[:client],
               delete_webhook: Container[:delete_webhook])
  @client = client
  @delete_webhook = delete_webhook
end

Instance Method Details

#call(credentials) ⇒ Array<Hash>

Delete any existing webhooks.

Parameters:

Returns:

  • (Array<Hash>)

    response data



24
25
26
27
28
29
30
# File 'lib/lucid_shopify/delete_all_webhooks.rb', line 24

def call(credentials)
  webhooks = @client.get(credentials, 'webhooks')['webhooks']

  webhooks.map do |webhook|
    Thread.new { @delete_webhook.(credentials, webhook['id']) }
  end.map(&:value)
end