Skip to content

Commit 185438b

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

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
44

55
## Unreleased
66

7+
- [#1183](https://github.com/Shopify/shopify-api-ruby/pull/1189) Added string array support for fields parameter in Webhook::Registry
8+
79
## 13.1.0
810

911
- [#1183](https://github.com/Shopify/shopify-api-ruby/pull/1183) Added support for API version 2023-07

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)