class ShopifyAPI::Webhooks::Registration
Constants
- FIELDS_DELIMITER
Attributes
Public Class Methods
Source
# File lib/shopify_api/webhooks/registration.rb, line 34 def initialize(topic:, path:, handler: nil, fields: nil, metafield_namespaces: nil, filter: 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])) @filter = filter end
Public Instance Methods
Source
# File lib/shopify_api/webhooks/registration.rb, line 54 def build_check_query; end
Source
# File lib/shopify_api/webhooks/registration.rb, line 68 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
Source
# File lib/shopify_api/webhooks/registration.rb, line 45 def callback_address; end
Source
# File lib/shopify_api/webhooks/registration.rb, line 51 def mutation_name(webhook_id); end
Source
# File lib/shopify_api/webhooks/registration.rb, line 65 def parse_check_result(body); end
Source
# File lib/shopify_api/webhooks/registration.rb, line 48 def subscription_args; end
Private Instance Methods
Source
# File lib/shopify_api/webhooks/registration.rb, line 93 def subscription_response_attributes attributes = ["id"] attributes << "includeFields" if @fields attributes << "metafieldNamespaces" if @metafield_namespaces attributes << "filter" if @filter attributes end