Class: ShopifyClient::CreateWebhook

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

Instance Method Summary collapse

Instance Method Details

#call(client, webhook) ⇒ Hash

Returns response data.

Parameters:

  • client (Client)
  • webhook (Hash)

Options Hash (webhook):

  • :topic (String)
  • :fields (Array<String>)

Returns:

  • (Hash)

    response data



11
12
13
14
15
16
17
18
19
# File 'lib/shopify-client/create_webhook.rb', line 11

def call(client, webhook)
  client.post('webhooks', webhook: webhook.merge(
    address: ShopifyClient.config.webhook_uri,
  ))
rescue Response::Error => e
  raise e unless e.response.errors.message?([
    /has already been taken/,
  ])
end