Class: Lucid::Shopify::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])


10
11
12
13
14
# File 'lib/lucid/shopify/delete_all_webhooks.rb', line 10

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



21
22
23
24
25
26
27
# File 'lib/lucid/shopify/delete_all_webhooks.rb', line 21

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

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