class Lucid::Shopify::CreateWebhook

Public Class Methods

new(client: Container[:client]) click to toggle source

@param client [#post_json]

# File lib/lucid/shopify/create_webhook.rb, line 9
def initialize(client: Container[:client])
  @client = client
end

Public Instance Methods

call(credentials, webhook) click to toggle source

@param credentials [Credentials] @param webhook [Hash]

@return [Hash] response data

# File lib/lucid/shopify/create_webhook.rb, line 17
def call(credentials, webhook)
  data = {**webhook, address: Shopify.config.webhook_uri}

  @client.post_json(credentials, 'webhooks', webhook: data)
rescue Response::Error => e
  raise e unless e.response.error_message?([
    /has already been taken/,
  ])
end