14
14
require "shopify_api"
15
15
require_relative "../../test_helper"
16
16
17
- class Webhook202410Test < Test ::Unit ::TestCase
17
+ class Webhook202501Test < Test ::Unit ::TestCase
18
18
def setup
19
19
super
20
20
21
21
test_session = ShopifyAPI ::Auth ::Session . new ( id : "id" , shop : "test-shop.myshopify.io" , access_token : "this_is_a_test_token" )
22
22
ShopifyAPI ::Context . activate_session ( test_session )
23
- modify_context ( api_version : "2024-10 " )
23
+ modify_context ( api_version : "2025-01 " )
24
24
end
25
25
26
26
def teardown
@@ -33,16 +33,16 @@ def teardown
33
33
void
34
34
end
35
35
def test_1 ( )
36
- stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json" )
36
+ stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json" )
37
37
. with (
38
38
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" } ,
39
39
body : { }
40
40
)
41
- . to_return ( status : 200 , body : JSON . generate ( { "webhooks" => [ { "id" => 4759306 , "address" => "https://apple.com" , "topic" => "orders/create" , "created_at" => "2024-10-02T08:59:11-05:00" , "updated_at" => "2024-10-02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } , { "id" => 892403750 , "address" => "https://example.org/fully_loaded_1" , "topic" => "orders/cancelled" , "created_at" => "2021-12-01T05:23:43-05:00" , "updated_at" => "2021-12-01T05:23:43-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } , { "id" => 901431826 , "address" => "https://apple.com/uninstall" , "topic" => "app/uninstalled" , "created_at" => "2024-10-02T08:59:11-05:00" , "updated_at" => "2024-10-02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } , { "id" => 1014196360 , "address" => "https://example.org/app_uninstalled" , "topic" => "app/uninstalled" , "created_at" => "2024-10-02T08:59:11-05:00" , "updated_at" => "2024-10-02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } ] } ) , headers : { } )
41
+ . to_return ( status : 200 , body : JSON . generate ( { "webhooks" => [ { "id" => 4759306 , "address" => "https://apple.com" , "topic" => "orders/create" , "created_at" => "2025-01-02T08:59:11-05:00" , "updated_at" => "2025-01-02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } , { "id" => 892403750 , "address" => "https://example.org/fully_loaded_1" , "topic" => "orders/cancelled" , "created_at" => "2021-12-01T05:23:43-05:00" , "updated_at" => "2021-12-01T05:23:43-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } , { "id" => 901431826 , "address" => "https://apple.com/uninstall" , "topic" => "app/uninstalled" , "created_at" => "2025-01-02T08:59:11-05:00" , "updated_at" => "2025-01-02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } , { "id" => 1014196360 , "address" => "https://example.org/app_uninstalled" , "topic" => "app/uninstalled" , "created_at" => "2025-01-02T08:59:11-05:00" , "updated_at" => "2025-01-02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } ] } ) , headers : { } )
42
42
43
43
response = ShopifyAPI ::Webhook . all
44
44
45
- assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json" )
45
+ assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json" )
46
46
47
47
response = response . first if response . respond_to? ( :first )
48
48
@@ -63,18 +63,18 @@ def test_1()
63
63
void
64
64
end
65
65
def test_2 ( )
66
- stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json?since_id=901431826" )
66
+ stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json?since_id=901431826" )
67
67
. with (
68
68
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" } ,
69
69
body : { }
70
70
)
71
- . to_return ( status : 200 , body : JSON . generate ( { "webhooks" => [ { "id" => 1014196360 , "address" => "https://example.org/app_uninstalled" , "topic" => "app/uninstalled" , "created_at" => "2024-10 -02T08:59:11-05:00" , "updated_at" => "2024-10 -02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } ] } ) , headers : { } )
71
+ . to_return ( status : 200 , body : JSON . generate ( { "webhooks" => [ { "id" => 1014196360 , "address" => "https://example.org/app_uninstalled" , "topic" => "app/uninstalled" , "created_at" => "2025-01 -02T08:59:11-05:00" , "updated_at" => "2025-01 -02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } ] } ) , headers : { } )
72
72
73
73
response = ShopifyAPI ::Webhook . all (
74
74
since_id : "901431826" ,
75
75
)
76
76
77
- assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json?since_id=901431826" )
77
+ assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json?since_id=901431826" )
78
78
79
79
response = response . first if response . respond_to? ( :first )
80
80
@@ -95,20 +95,20 @@ def test_2()
95
95
void
96
96
end
97
97
def test_3 ( )
98
- stub_request ( :post , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json" )
98
+ stub_request ( :post , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json" )
99
99
. with (
100
100
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" , "Content-Type" => "application/json" } ,
101
101
body : { "webhook" => hash_including ( { "address" => "pubsub://projectName:topicName" , "topic" => "customers/update" , "format" => "json" } ) }
102
102
)
103
- . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 6883828544 , "address" => "pubsub://projectName:topicName" , "topic" => "customers/update" , "created_at" => "2024-10 -02T09:06:06-05:00" , "updated_at" => "2024-10 -02T09:06:06-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
103
+ . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 6883828544 , "address" => "pubsub://projectName:topicName" , "topic" => "customers/update" , "created_at" => "2025-01 -02T09:06:06-05:00" , "updated_at" => "2025-01 -02T09:06:06-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
104
104
105
105
response = webhook = ShopifyAPI ::Webhook . new
106
106
webhook . address = "pubsub://projectName:topicName"
107
107
webhook . topic = "customers/update"
108
108
webhook . format = "json"
109
109
webhook . save
110
110
111
- assert_requested ( :post , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json" )
111
+ assert_requested ( :post , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json" )
112
112
113
113
response = response . first if response . respond_to? ( :first )
114
114
@@ -129,20 +129,20 @@ def test_3()
129
129
void
130
130
end
131
131
def test_4 ( )
132
- stub_request ( :post , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json" )
132
+ stub_request ( :post , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json" )
133
133
. with (
134
134
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" , "Content-Type" => "application/json" } ,
135
135
body : { "webhook" => hash_including ( { "address" => "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source" , "topic" => "customers/update" , "format" => "json" } ) }
136
136
)
137
- . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 6883828534 , "address" => "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source" , "topic" => "customers/update" , "created_at" => "2024-10 -02T09:05:41-05:00" , "updated_at" => "2024-10 -02T09:05:41-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
137
+ . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 6883828534 , "address" => "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source" , "topic" => "customers/update" , "created_at" => "2025-01 -02T09:05:41-05:00" , "updated_at" => "2025-01 -02T09:05:41-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
138
138
139
139
response = webhook = ShopifyAPI ::Webhook . new
140
140
webhook . address = "arn:aws:events:us-east-1::event-source/aws.partner/shopify.com/755357713/example-event-source"
141
141
webhook . topic = "customers/update"
142
142
webhook . format = "json"
143
143
webhook . save
144
144
145
- assert_requested ( :post , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json" )
145
+ assert_requested ( :post , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json" )
146
146
147
147
response = response . first if response . respond_to? ( :first )
148
148
@@ -163,12 +163,12 @@ def test_4()
163
163
void
164
164
end
165
165
def test_5 ( )
166
- stub_request ( :post , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json" )
166
+ stub_request ( :post , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json" )
167
167
. with (
168
168
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" , "Content-Type" => "application/json" } ,
169
169
body : { "webhook" => hash_including ( { "topic" => "orders/create" , "address" => "https://example.hostname.com/" , "format" => "json" , "fields" => [ "id" , "note" ] } ) }
170
170
)
171
- . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 6883828554 , "address" => "https://example.hostname.com/" , "topic" => "orders/create" , "created_at" => "2024-10 -02T09:06:30-05:00" , "updated_at" => "2024-10 -02T09:06:30-05:00" , "format" => "json" , "fields" => [ "id" , "note" ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
171
+ . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 6883828554 , "address" => "https://example.hostname.com/" , "topic" => "orders/create" , "created_at" => "2025-01 -02T09:06:30-05:00" , "updated_at" => "2025-01 -02T09:06:30-05:00" , "format" => "json" , "fields" => [ "id" , "note" ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
172
172
173
173
response = webhook = ShopifyAPI ::Webhook . new
174
174
webhook . topic = "orders/create"
@@ -180,7 +180,7 @@ def test_5()
180
180
]
181
181
webhook . save
182
182
183
- assert_requested ( :post , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks.json" )
183
+ assert_requested ( :post , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks.json" )
184
184
185
185
response = response . first if response . respond_to? ( :first )
186
186
@@ -201,7 +201,7 @@ def test_5()
201
201
void
202
202
end
203
203
def test_6 ( )
204
- stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/count.json?topic=orders%2Fcreate" )
204
+ stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/count.json?topic=orders%2Fcreate" )
205
205
. with (
206
206
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" } ,
207
207
body : { }
@@ -212,7 +212,7 @@ def test_6()
212
212
topic : "orders/create" ,
213
213
)
214
214
215
- assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/count.json?topic=orders%2Fcreate" )
215
+ assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/count.json?topic=orders%2Fcreate" )
216
216
217
217
response = response . first if response . respond_to? ( :first )
218
218
@@ -233,7 +233,7 @@ def test_6()
233
233
void
234
234
end
235
235
def test_7 ( )
236
- stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/count.json" )
236
+ stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/count.json" )
237
237
. with (
238
238
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" } ,
239
239
body : { }
@@ -242,7 +242,7 @@ def test_7()
242
242
243
243
response = ShopifyAPI ::Webhook . count
244
244
245
- assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/count.json" )
245
+ assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/count.json" )
246
246
247
247
response = response . first if response . respond_to? ( :first )
248
248
@@ -263,18 +263,18 @@ def test_7()
263
263
void
264
264
end
265
265
def test_8 ( )
266
- stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/4759306.json" )
266
+ stub_request ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/4759306.json" )
267
267
. with (
268
268
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" } ,
269
269
body : { }
270
270
)
271
- . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 4759306 , "address" => "https://apple.com" , "topic" => "orders/create" , "created_at" => "2024-10 -02T08:59:11-05:00" , "updated_at" => "2024-10 -02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
271
+ . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 4759306 , "address" => "https://apple.com" , "topic" => "orders/create" , "created_at" => "2025-01 -02T08:59:11-05:00" , "updated_at" => "2025-01 -02T08:59:11-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
272
272
273
273
response = ShopifyAPI ::Webhook . find (
274
274
id : 4759306 ,
275
275
)
276
276
277
- assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/4759306.json" )
277
+ assert_requested ( :get , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/4759306.json" )
278
278
279
279
response = response . first if response . respond_to? ( :first )
280
280
@@ -295,19 +295,19 @@ def test_8()
295
295
void
296
296
end
297
297
def test_9 ( )
298
- stub_request ( :put , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/4759306.json" )
298
+ stub_request ( :put , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/4759306.json" )
299
299
. with (
300
300
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" , "Content-Type" => "application/json" } ,
301
301
body : { "webhook" => hash_including ( { "address" => "https://somewhere-else.com/" } ) }
302
302
)
303
- . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 4759306 , "address" => "https://somewhere-else.com/" , "topic" => "orders/create" , "created_at" => "2024-10 -02T08:59:11-05:00" , "updated_at" => "2024-10 -02T09:08:15-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
303
+ . to_return ( status : 200 , body : JSON . generate ( { "webhook" => { "id" => 4759306 , "address" => "https://somewhere-else.com/" , "topic" => "orders/create" , "created_at" => "2025-01 -02T08:59:11-05:00" , "updated_at" => "2025-01 -02T09:08:15-05:00" , "format" => "json" , "fields" => [ ] , "metafield_namespaces" => [ ] , "api_version" => "unstable" , "private_metafield_namespaces" => [ ] } } ) , headers : { } )
304
304
305
305
response = webhook = ShopifyAPI ::Webhook . new
306
306
webhook . id = 4759306
307
307
webhook . address = "https://somewhere-else.com/"
308
308
webhook . save
309
309
310
- assert_requested ( :put , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/4759306.json" )
310
+ assert_requested ( :put , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/4759306.json" )
311
311
312
312
response = response . first if response . respond_to? ( :first )
313
313
@@ -328,7 +328,7 @@ def test_9()
328
328
void
329
329
end
330
330
def test_10 ( )
331
- stub_request ( :delete , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/4759306.json" )
331
+ stub_request ( :delete , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/4759306.json" )
332
332
. with (
333
333
headers : { "X-Shopify-Access-Token" => "this_is_a_test_token" , "Accept" => "application/json" } ,
334
334
body : { }
@@ -339,7 +339,7 @@ def test_10()
339
339
id : 4759306 ,
340
340
)
341
341
342
- assert_requested ( :delete , "https://test-shop.myshopify.io/admin/api/2024-10 /webhooks/4759306.json" )
342
+ assert_requested ( :delete , "https://test-shop.myshopify.io/admin/api/2025-01 /webhooks/4759306.json" )
343
343
344
344
response = response . first if response . respond_to? ( :first )
345
345
0 commit comments