Skip to content

Commit

Permalink
Merge pull request #1189 from Shopify/webhook-registry-support-fields…
Browse files Browse the repository at this point in the history
…-array

Add T::Array[String] support for webhook fields
  • Loading branch information
SheldonNunes authored Aug 10, 2023
2 parents 77ab36c + 185438b commit 30833ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api

## Unreleased

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

## 13.1.0

- [#1183](https://github.com/Shopify/shopify-api-ruby/pull/1183) Added support for API version 2023-07
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/webhooks/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class << self
delivery_method: Symbol,
path: String,
handler: T.nilable(Handler),
fields: T.nilable(String)).void
fields: T.nilable(T.any(String, T::Array[String]))).void
end
def add_registration(topic:, delivery_method:, path:, handler: nil, fields: nil)
@registry[topic] = case delivery_method
Expand Down
12 changes: 12 additions & 0 deletions test/webhooks/registry_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ def test_http_registration_with_fields_add_and_update
do_registration_test(:http, "test-webhooks", fields: "field1, field2")
end

def test_http_registration_with_fields_array_add_and_update
do_registration_test(:http, "test-webhooks", fields: ["field1", "field2"])
end

def test_raises_on_http_registration_check_error
do_registration_check_error_test(:http, "test-webhooks")
end
Expand All @@ -106,6 +110,10 @@ def test_pubsub_registration_with_fields_add_and_update
do_registration_test(:pub_sub, "pubsub://my-project-id:my-topic-id", fields: "field1, field2")
end

def test_pubsub_registration_with_fields_array_add_and_update
do_registration_test(:pub_sub, "pubsub://my-project-id:my-topic-id", fields: ["field1", "field2"])
end

def test_raises_on_pubsub_registration_check_error
do_registration_check_error_test(:pub_sub, "pubsub://my-project-id:my-topic-id")
end
Expand All @@ -118,6 +126,10 @@ def test_eventbridge_registration_with_fields_add_and_update
do_registration_test(:event_bridge, "test-webhooks", fields: "field1, field2")
end

def test_eventbridge_registration_with_fields_array_add_and_update
do_registration_test(:event_bridge, "test-webhooks", fields: ["field1", "field2"])
end

def test_raises_on_eventbridge_registration_check_error
do_registration_check_error_test(:event_bridge, "test-webhooks")
end
Expand Down

0 comments on commit 30833ce

Please sign in to comment.