Class: ShopifyAPI::Webhooks::Registrations::EventBridge
Constant Summary
ShopifyAPI::Webhooks::Registration::FIELDS_DELIMITER
Instance Attribute Summary
#fields, #handler, #topic
Instance Method Summary
collapse
#build_register_query, #initialize
Instance Method Details
#build_check_query ⇒ Object
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/shopify_api/webhooks/registrations/event_bridge.rb', line 26
def build_check_query
<<~QUERY
{
webhookSubscriptions(first: 1, topics: #{@topic}) {
edges {
node {
id
endpoint {
__typename
... on WebhookEventBridgeEndpoint {
arn
}
}
}
}
}
}
QUERY
end
|
#callback_address ⇒ Object
11
12
13
|
# File 'lib/shopify_api/webhooks/registrations/event_bridge.rb', line 11
def callback_address
@path
end
|
#mutation_name(webhook_id) ⇒ Object
21
22
23
|
# File 'lib/shopify_api/webhooks/registrations/event_bridge.rb', line 21
def mutation_name(webhook_id)
webhook_id ? "eventBridgeWebhookSubscriptionUpdate" : "eventBridgeWebhookSubscriptionCreate"
end
|
#parse_check_result(body) ⇒ Object
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/shopify_api/webhooks/registrations/event_bridge.rb', line 47
def parse_check_result(body)
edges = body.dig("data", "webhookSubscriptions", "edges") || {}
webhook_id = nil
current_address = nil
unless edges.empty?
node = edges[0]["node"]
webhook_id = node["id"].to_s
current_address = node["endpoint"]["arn"].to_s
end
{ webhook_id: webhook_id, current_address: current_address }
end
|
#subscription_args ⇒ Object
16
17
18
|
# File 'lib/shopify_api/webhooks/registrations/event_bridge.rb', line 16
def subscription_args
{ arn: callback_address, includeFields: fields }.compact
end
|