Skip to content

Commit

Permalink
make parse type untyped and possibly sort arrays when checking for eq…
Browse files Browse the repository at this point in the history
…uality
  • Loading branch information
andy-liuu committed Oct 30, 2024
1 parent 94e9c93 commit 53a6741
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/shopify_api/webhooks/registration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def mutation_name(webhook_id); end
sig { abstract.returns(String) }
def build_check_query; end

sig { abstract.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, String]) }
sig { abstract.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
def parse_check_result(body); end

sig { params(webhook_id: T.nilable(String)).returns(String) }
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/webhooks/registrations/event_bridge.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def build_check_query
QUERY
end

sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, String]) }
sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
def parse_check_result(body)
edges = body.dig("data", "webhookSubscriptions", "edges") || {}
webhook_id = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/webhooks/registrations/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def build_check_query
QUERY
end

sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, String]) }
sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
def parse_check_result(body)
edges = body.dig("data", "webhookSubscriptions", "edges") || {}
webhook_id = nil
Expand Down
2 changes: 1 addition & 1 deletion lib/shopify_api/webhooks/registrations/pub_sub.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def build_check_query
QUERY
end

sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, String]) }
sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
def parse_check_result(body)
edges = body.dig("data", "webhookSubscriptions", "edges") || {}
webhook_id = nil
Expand Down
4 changes: 2 additions & 2 deletions lib/shopify_api/webhooks/registry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ def webhook_registration_needed?(client, registration)
"Failed to check if webhook was already registered" unless check_response.ok?
parsed_check_result = registration.parse_check_result(T.cast(check_response.body, T::Hash[String, T.untyped]))
must_register = parsed_check_result[:current_address] != registration.callback_address ||
parsed_check_result[:fields] != registration.fields ||
parsed_check_result[:metafield_namespaces] != registration.metafield_namespaces
parsed_check_result[:fields]&.sort != registration.fields&.sort ||
parsed_check_result[:metafield_namespaces]&.sort != registration.metafield_namespaces&.sort

{ webhook_id: parsed_check_result[:webhook_id], must_register: must_register }
end
Expand Down

0 comments on commit 53a6741

Please sign in to comment.