@@ -138,11 +138,10 @@ def unregister(topic:, session:)
138138 }
139139 MUTATION
140140
141- delete_response = client . query ( query : delete_mutation )
141+ delete_response = client . query ( query : delete_mutation , response_as_struct : false )
142142 raise Errors ::WebhookRegistrationError ,
143143 "Failed to delete webhook from Shopify" unless delete_response . ok?
144- result = T . cast ( ShopifyAPI ::Utils ::OstructHashUtils . ensure_hash ( delete_response . body ) ,
145- T ::Hash [ String , T . untyped ] )
144+ result = T . cast ( delete_response . body , T ::Hash [ String , T . untyped ] )
146145 errors = result [ "errors" ] || { }
147146 raise Errors ::WebhookRegistrationError ,
148147 "Failed to delete webhook from Shopify: #{ errors [ 0 ] [ "message" ] } " unless errors . empty?
@@ -171,11 +170,10 @@ def get_webhook_id(topic:, client:)
171170 }
172171 QUERY
173172
174- fetch_id_response = client . query ( query : fetch_id_query )
173+ fetch_id_response = client . query ( query : fetch_id_query , response_as_struct : false )
175174 raise Errors ::WebhookRegistrationError ,
176175 "Failed to fetch webhook from Shopify" unless fetch_id_response . ok?
177- body = T . cast ( ShopifyAPI ::Utils ::OstructHashUtils . ensure_hash ( fetch_id_response . body ) ,
178- T ::Hash [ String , T . untyped ] )
176+ body = T . cast ( fetch_id_response . body , T ::Hash [ String , T . untyped ] )
179177 errors = body [ "errors" ] || { }
180178 raise Errors ::WebhookRegistrationError ,
181179 "Failed to fetch webhook from Shopify: #{ errors [ 0 ] [ "message" ] } " unless errors . empty?
@@ -218,13 +216,10 @@ def process(request)
218216 ) . returns ( T ::Hash [ Symbol , T . untyped ] )
219217 end
220218 def webhook_registration_needed? ( client , registration )
221- check_response = client . query ( query : registration . build_check_query )
219+ check_response = client . query ( query : registration . build_check_query , response_as_struct : false )
222220 raise Errors ::WebhookRegistrationError ,
223221 "Failed to check if webhook was already registered" unless check_response . ok?
224-
225- response_body = ShopifyAPI ::Utils ::OstructHashUtils . ensure_hash ( check_response . body )
226-
227- parsed_check_result = registration . parse_check_result ( T . cast ( response_body , T ::Hash [ String , T . untyped ] ) )
222+ parsed_check_result = registration . parse_check_result ( T . cast ( check_response . body , T ::Hash [ String , T . untyped ] ) )
228223 must_register = parsed_check_result [ :current_address ] != registration . callback_address
229224
230225 { webhook_id : parsed_check_result [ :webhook_id ] , must_register : must_register }
@@ -238,12 +233,12 @@ def webhook_registration_needed?(client, registration)
238233 ) . returns ( T ::Hash [ String , T . untyped ] )
239234 end
240235 def send_register_request ( client , registration , webhook_id )
241- register_response = client . query ( query : registration . build_register_query ( webhook_id : webhook_id ) )
236+ register_response = client . query ( query : registration . build_register_query ( webhook_id : webhook_id ) ,
237+ response_as_struct : false )
242238
243239 raise Errors ::WebhookRegistrationError , "Failed to register webhook with Shopify" unless register_response . ok?
244240
245- response_body = ShopifyAPI ::Utils ::OstructHashUtils . ensure_hash ( register_response . body )
246- T . cast ( response_body , T ::Hash [ String , T . untyped ] )
241+ T . cast ( register_response . body , T ::Hash [ String , T . untyped ] )
247242 end
248243
249244 sig { params ( body : T ::Hash [ String , T . untyped ] , mutation_name : String ) . returns ( T ::Boolean ) }
0 commit comments