Skip to content

Commit 52914f0

Browse files
committed
Add T::Array[String] support for webhook fields
1 parent 77ab36c commit 52914f0

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/shopify_api/webhooks/registry.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class << self
1313
delivery_method: Symbol,
1414
path: String,
1515
handler: T.nilable(Handler),
16-
fields: T.nilable(String)).void
16+
fields: T.nilable(T.any(String, T::Array[String]))).void
1717
end
1818
def add_registration(topic:, delivery_method:, path:, handler: nil, fields: nil)
1919
@registry[topic] = case delivery_method

test/webhooks/registry_test.rb

+12
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,10 @@ def test_http_registration_with_fields_add_and_update
9494
do_registration_test(:http, "test-webhooks", fields: "field1, field2")
9595
end
9696

97+
def test_http_registration_with_fields_array_add_and_update
98+
do_registration_test(:http, "test-webhooks", fields: ["field1", "field2"])
99+
end
100+
97101
def test_raises_on_http_registration_check_error
98102
do_registration_check_error_test(:http, "test-webhooks")
99103
end
@@ -106,6 +110,10 @@ def test_pubsub_registration_with_fields_add_and_update
106110
do_registration_test(:pub_sub, "pubsub://my-project-id:my-topic-id", fields: "field1, field2")
107111
end
108112

113+
def test_pubsub_registration_with_fields_array_add_and_update
114+
do_registration_test(:pub_sub, "pubsub://my-project-id:my-topic-id", fields: ["field1"], ["field2"])
115+
end
116+
109117
def test_raises_on_pubsub_registration_check_error
110118
do_registration_check_error_test(:pub_sub, "pubsub://my-project-id:my-topic-id")
111119
end
@@ -118,6 +126,10 @@ def test_eventbridge_registration_with_fields_add_and_update
118126
do_registration_test(:event_bridge, "test-webhooks", fields: "field1, field2")
119127
end
120128

129+
def test_eventbridge_registration_with_fields_array_add_and_update
130+
do_registration_test(:event_bridge, "test-webhooks", fields: ["field1"], ["field2"])
131+
end
132+
121133
def test_raises_on_eventbridge_registration_check_error
122134
do_registration_check_error_test(:event_bridge, "test-webhooks")
123135
end

0 commit comments

Comments
 (0)