class ShopifyGraphql::Webhook

Constants

ALL_WEBHOOKS_QUERY
CREATE_WEBHOOK_MUTATION
DELETE_WEBHOOK_MUTATION

Public Class Methods

all() click to toggle source
# File lib/shopify_graphql/resources/webhook.rb, line 50
def all
  response = execute(ALL_WEBHOOKS_QUERY)
  response.data.webhookSubscriptions.edges.map do |edge|
    edge.node
  end
end
create(topic:, address:, include_fields:) click to toggle source
# File lib/shopify_graphql/resources/webhook.rb, line 57
def create(topic:, address:, include_fields:)
  response = execute(CREATE_WEBHOOK_MUTATION,
    topic: topic,
    webhookSubscription: {
      callbackUrl: address,
      format: 'JSON',
      includeFields: include_fields,
    },
  )
  response = response.data.webhookSubscriptionCreate
  handle_user_errors(response)
end
delete(id) click to toggle source
# File lib/shopify_graphql/resources/webhook.rb, line 70
def delete(id)
  response = execute(DELETE_WEBHOOK_MUTATION, id: id)
  response = response.data.webhookSubscriptionDelete
  handle_user_errors(response)
end