class ShopifyAPI::Webhooks::Registration
Constants
- FIELDS_DELIMITER
Attributes
fields[R]
handler[R]
metafield_namespaces[R]
topic[R]
Public Class Methods
new(topic:, path:, handler: nil, fields: nil, metafield_namespaces: nil)
click to toggle source
# File lib/shopify_api/webhooks/registration.rb, line 30 def initialize(topic:, path:, handler: nil, fields: nil, metafield_namespaces: nil) @topic = T.let(topic.gsub("/", "_").upcase, String) @path = path @handler = handler fields_array = fields.is_a?(String) ? fields.split(FIELDS_DELIMITER) : fields @fields = T.let(fields_array&.map(&:strip)&.compact, T.nilable(T::Array[String])) @metafield_namespaces = T.let(metafield_namespaces&.map(&:strip)&.compact, T.nilable(T::Array[String])) end
Public Instance Methods
build_check_query()
click to toggle source
# File lib/shopify_api/webhooks/registration.rb, line 49 def build_check_query; end
build_register_query(webhook_id: nil)
click to toggle source
# File lib/shopify_api/webhooks/registration.rb, line 55 def build_register_query(webhook_id: nil) identifier = webhook_id ? "id: \"#{webhook_id}\"" : "topic: #{@topic}" subscription_args_string = subscription_args.map do |k, v| "#{k}: #{[:includeFields, :metafieldNamespaces].include?(k) ? v : %("#{v}")}" end.join(", ") <<~QUERY mutation webhookSubscription { #{mutation_name(webhook_id)}(#{identifier}, webhookSubscription: {#{subscription_args_string}}) { userErrors { field message } webhookSubscription { #{subscription_response_attributes.join("\n ")} } } } QUERY end
callback_address()
click to toggle source
# File lib/shopify_api/webhooks/registration.rb, line 40 def callback_address; end
mutation_name(webhook_id)
click to toggle source
# File lib/shopify_api/webhooks/registration.rb, line 46 def mutation_name(webhook_id); end
parse_check_result(body)
click to toggle source
# File lib/shopify_api/webhooks/registration.rb, line 52 def parse_check_result(body); end
subscription_args()
click to toggle source
# File lib/shopify_api/webhooks/registration.rb, line 43 def subscription_args; end
Private Instance Methods
subscription_response_attributes()
click to toggle source
# File lib/shopify_api/webhooks/registration.rb, line 80 def subscription_response_attributes attributes = ["id"] attributes << "includeFields" if @fields attributes << "metafieldNamespaces" if @metafield_namespaces attributes end