shopify_api 14.5.0 → 14.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -1
  3. data/Gemfile.lock +20 -11
  4. data/docs/usage/oauth.md +14 -0
  5. data/docs/usage/webhooks.md +11 -0
  6. data/lib/shopify_api/admin_versions.rb +2 -1
  7. data/lib/shopify_api/context.rb +2 -2
  8. data/lib/shopify_api/rest/resources/2022_04/shop.rb +2 -2
  9. data/lib/shopify_api/rest/resources/2022_07/shop.rb +2 -2
  10. data/lib/shopify_api/rest/resources/2022_10/shop.rb +2 -2
  11. data/lib/shopify_api/rest/resources/2023_01/shop.rb +2 -2
  12. data/lib/shopify_api/rest/resources/2023_04/shop.rb +2 -2
  13. data/lib/shopify_api/rest/resources/2023_07/shop.rb +2 -2
  14. data/lib/shopify_api/rest/resources/2023_10/shop.rb +2 -2
  15. data/lib/shopify_api/rest/resources/2024_01/shop.rb +2 -2
  16. data/lib/shopify_api/rest/resources/2024_04/shop.rb +2 -2
  17. data/lib/shopify_api/rest/resources/2024_07/shop.rb +2 -2
  18. data/lib/shopify_api/rest/resources/2024_07/webhook.rb +1 -0
  19. data/lib/shopify_api/rest/resources/2024_10/abandoned_checkout.rb +194 -0
  20. data/lib/shopify_api/rest/resources/2024_10/access_scope.rb +62 -0
  21. data/lib/shopify_api/rest/resources/2024_10/apple_pay_certificate.rb +109 -0
  22. data/lib/shopify_api/rest/resources/2024_10/application_charge.rb +113 -0
  23. data/lib/shopify_api/rest/resources/2024_10/application_credit.rb +95 -0
  24. data/lib/shopify_api/rest/resources/2024_10/article.rb +269 -0
  25. data/lib/shopify_api/rest/resources/2024_10/asset.rb +122 -0
  26. data/lib/shopify_api/rest/resources/2024_10/assigned_fulfillment_order.rb +92 -0
  27. data/lib/shopify_api/rest/resources/2024_10/balance.rb +58 -0
  28. data/lib/shopify_api/rest/resources/2024_10/blog.rb +166 -0
  29. data/lib/shopify_api/rest/resources/2024_10/cancellation_request.rb +87 -0
  30. data/lib/shopify_api/rest/resources/2024_10/carrier_service.rb +120 -0
  31. data/lib/shopify_api/rest/resources/2024_10/checkout.rb +213 -0
  32. data/lib/shopify_api/rest/resources/2024_10/collect.rb +146 -0
  33. data/lib/shopify_api/rest/resources/2024_10/collection.rb +114 -0
  34. data/lib/shopify_api/rest/resources/2024_10/collection_listing.rb +159 -0
  35. data/lib/shopify_api/rest/resources/2024_10/comment.rb +287 -0
  36. data/lib/shopify_api/rest/resources/2024_10/country.rb +141 -0
  37. data/lib/shopify_api/rest/resources/2024_10/currency.rb +61 -0
  38. data/lib/shopify_api/rest/resources/2024_10/custom_collection.rb +191 -0
  39. data/lib/shopify_api/rest/resources/2024_10/customer.rb +335 -0
  40. data/lib/shopify_api/rest/resources/2024_10/customer_address.rb +215 -0
  41. data/lib/shopify_api/rest/resources/2024_10/deprecated_api_call.rb +61 -0
  42. data/lib/shopify_api/rest/resources/2024_10/discount_code.rb +226 -0
  43. data/lib/shopify_api/rest/resources/2024_10/dispute.rb +115 -0
  44. data/lib/shopify_api/rest/resources/2024_10/dispute_evidence.rb +121 -0
  45. data/lib/shopify_api/rest/resources/2024_10/dispute_file_upload.rb +85 -0
  46. data/lib/shopify_api/rest/resources/2024_10/draft_order.rb +279 -0
  47. data/lib/shopify_api/rest/resources/2024_10/event.rb +152 -0
  48. data/lib/shopify_api/rest/resources/2024_10/fulfillment.rb +235 -0
  49. data/lib/shopify_api/rest/resources/2024_10/fulfillment_event.rb +167 -0
  50. data/lib/shopify_api/rest/resources/2024_10/fulfillment_order.rb +326 -0
  51. data/lib/shopify_api/rest/resources/2024_10/fulfillment_request.rb +101 -0
  52. data/lib/shopify_api/rest/resources/2024_10/fulfillment_service.rb +134 -0
  53. data/lib/shopify_api/rest/resources/2024_10/gift_card.rb +222 -0
  54. data/lib/shopify_api/rest/resources/2024_10/gift_card_adjustment.rb +122 -0
  55. data/lib/shopify_api/rest/resources/2024_10/image.rb +161 -0
  56. data/lib/shopify_api/rest/resources/2024_10/inventory_item.rb +112 -0
  57. data/lib/shopify_api/rest/resources/2024_10/inventory_level.rb +183 -0
  58. data/lib/shopify_api/rest/resources/2024_10/location.rb +171 -0
  59. data/lib/shopify_api/rest/resources/2024_10/locations_for_move.rb +60 -0
  60. data/lib/shopify_api/rest/resources/2024_10/marketing_event.rb +213 -0
  61. data/lib/shopify_api/rest/resources/2024_10/metafield.rb +348 -0
  62. data/lib/shopify_api/rest/resources/2024_10/mobile_platform_application.rb +114 -0
  63. data/lib/shopify_api/rest/resources/2024_10/order.rb +490 -0
  64. data/lib/shopify_api/rest/resources/2024_10/order_risk.rb +148 -0
  65. data/lib/shopify_api/rest/resources/2024_10/page.rb +198 -0
  66. data/lib/shopify_api/rest/resources/2024_10/payment.rb +144 -0
  67. data/lib/shopify_api/rest/resources/2024_10/payment_gateway.rb +147 -0
  68. data/lib/shopify_api/rest/resources/2024_10/payment_transaction.rb +114 -0
  69. data/lib/shopify_api/rest/resources/2024_10/payout.rb +101 -0
  70. data/lib/shopify_api/rest/resources/2024_10/policy.rb +73 -0
  71. data/lib/shopify_api/rest/resources/2024_10/price_rule.rb +227 -0
  72. data/lib/shopify_api/rest/resources/2024_10/product.rb +227 -0
  73. data/lib/shopify_api/rest/resources/2024_10/product_listing.rb +200 -0
  74. data/lib/shopify_api/rest/resources/2024_10/product_resource_feedback.rb +92 -0
  75. data/lib/shopify_api/rest/resources/2024_10/province.rb +136 -0
  76. data/lib/shopify_api/rest/resources/2024_10/recurring_application_charge.rb +184 -0
  77. data/lib/shopify_api/rest/resources/2024_10/redirect.rb +143 -0
  78. data/lib/shopify_api/rest/resources/2024_10/refund.rb +155 -0
  79. data/lib/shopify_api/rest/resources/2024_10/resource_feedback.rb +77 -0
  80. data/lib/shopify_api/rest/resources/2024_10/script_tag.rb +159 -0
  81. data/lib/shopify_api/rest/resources/2024_10/shipping_zone.rb +87 -0
  82. data/lib/shopify_api/rest/resources/2024_10/shop.rb +232 -0
  83. data/lib/shopify_api/rest/resources/2024_10/smart_collection.rb +220 -0
  84. data/lib/shopify_api/rest/resources/2024_10/storefront_access_token.rb +91 -0
  85. data/lib/shopify_api/rest/resources/2024_10/tender_transaction.rb +97 -0
  86. data/lib/shopify_api/rest/resources/2024_10/theme.rb +127 -0
  87. data/lib/shopify_api/rest/resources/2024_10/transaction.rb +189 -0
  88. data/lib/shopify_api/rest/resources/2024_10/usage_charge.rb +106 -0
  89. data/lib/shopify_api/rest/resources/2024_10/user.rb +142 -0
  90. data/lib/shopify_api/rest/resources/2024_10/variant.rb +212 -0
  91. data/lib/shopify_api/rest/resources/2024_10/webhook.rb +173 -0
  92. data/lib/shopify_api/version.rb +1 -1
  93. data/lib/shopify_api/webhooks/registration.rb +17 -3
  94. data/lib/shopify_api/webhooks/registrations/event_bridge.rb +22 -3
  95. data/lib/shopify_api/webhooks/registrations/http.rb +22 -3
  96. data/lib/shopify_api/webhooks/registrations/pub_sub.rb +23 -4
  97. data/lib/shopify_api/webhooks/registry.rb +15 -5
  98. metadata +76 -3
@@ -0,0 +1,212 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ ########################################################################################################################
5
+ # This file is auto-generated. If you have an issue, please create a GitHub issue. #
6
+ ########################################################################################################################
7
+
8
+ module ShopifyAPI
9
+ class Variant < ShopifyAPI::Rest::Base
10
+ extend T::Sig
11
+
12
+ @prev_page_info = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
13
+ @next_page_info = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
14
+
15
+ @api_call_limit = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
16
+ @retry_request_after = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
17
+
18
+ sig { params(session: T.nilable(ShopifyAPI::Auth::Session), from_hash: T.nilable(T::Hash[T.untyped, T.untyped])).void }
19
+ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
20
+
21
+ @barcode = T.let(nil, T.nilable(String))
22
+ @compare_at_price = T.let(nil, T.nilable(String))
23
+ @created_at = T.let(nil, T.nilable(String))
24
+ @fulfillment_service = T.let(nil, T.nilable(String))
25
+ @grams = T.let(nil, T.nilable(Integer))
26
+ @id = T.let(nil, T.nilable(Integer))
27
+ @image_id = T.let(nil, T.nilable(Integer))
28
+ @inventory_item_id = T.let(nil, T.nilable(Integer))
29
+ @inventory_management = T.let(nil, T.nilable(String))
30
+ @inventory_policy = T.let(nil, T.nilable(String))
31
+ @inventory_quantity = T.let(nil, T.nilable(T.any(Integer, String)))
32
+ @old_inventory_quantity = T.let(nil, T.nilable(T.any(Integer, String)))
33
+ @option = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
34
+ @position = T.let(nil, T.nilable(Integer))
35
+ @presentment_prices = T.let(nil, T.nilable(T::Array[T.untyped]))
36
+ @price = T.let(nil, T.nilable(String))
37
+ @product_id = T.let(nil, T.nilable(Integer))
38
+ @requires_shipping = T.let(nil, T.nilable(T::Boolean))
39
+ @sku = T.let(nil, T.nilable(String))
40
+ @tax_code = T.let(nil, T.nilable(String))
41
+ @taxable = T.let(nil, T.nilable(T::Boolean))
42
+ @title = T.let(nil, T.nilable(String))
43
+ @updated_at = T.let(nil, T.nilable(String))
44
+ @weight = T.let(nil, T.nilable(Float))
45
+ @weight_unit = T.let(nil, T.nilable(String))
46
+
47
+ super(session: session, from_hash: from_hash)
48
+ end
49
+
50
+ @has_one = T.let({}, T::Hash[Symbol, Class])
51
+ @has_many = T.let({}, T::Hash[Symbol, Class])
52
+ @paths = T.let([
53
+ {http_method: :delete, operation: :delete, ids: [:product_id, :id], path: "products/<product_id>/variants/<id>.json"},
54
+ {http_method: :get, operation: :count, ids: [:product_id], path: "products/<product_id>/variants/count.json"},
55
+ {http_method: :get, operation: :get, ids: [:product_id], path: "products/<product_id>/variants.json"},
56
+ {http_method: :get, operation: :get, ids: [:id], path: "variants/<id>.json"},
57
+ {http_method: :post, operation: :post, ids: [:product_id], path: "products/<product_id>/variants.json"},
58
+ {http_method: :put, operation: :put, ids: [:id], path: "variants/<id>.json"}
59
+ ], T::Array[T::Hash[String, T.any(T::Array[Symbol], String, Symbol)]])
60
+ @read_only_attributes = T.let([
61
+ :inventory_quantity
62
+ ], T::Array[Symbol])
63
+
64
+ sig { returns(T.nilable(String)) }
65
+ attr_reader :barcode
66
+ sig { returns(T.nilable(String)) }
67
+ attr_reader :compare_at_price
68
+ sig { returns(T.nilable(String)) }
69
+ attr_reader :created_at
70
+ sig { returns(T.nilable(String)) }
71
+ attr_reader :fulfillment_service
72
+ sig { returns(T.nilable(Integer)) }
73
+ attr_reader :grams
74
+ sig { returns(T.nilable(Integer)) }
75
+ attr_reader :id
76
+ sig { returns(T.nilable(Integer)) }
77
+ attr_reader :image_id
78
+ sig { returns(T.nilable(Integer)) }
79
+ attr_reader :inventory_item_id
80
+ sig { returns(T.nilable(String)) }
81
+ attr_reader :inventory_management
82
+ sig { returns(T.nilable(String)) }
83
+ attr_reader :inventory_policy
84
+ sig { returns(T.nilable(T.any(Integer, String))) }
85
+ attr_reader :inventory_quantity
86
+ sig { returns(T.nilable(T.any(Integer, String))) }
87
+ attr_reader :old_inventory_quantity
88
+ sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
89
+ attr_reader :option
90
+ sig { returns(T.nilable(Integer)) }
91
+ attr_reader :position
92
+ sig { returns(T.nilable(T::Array[T::Hash[T.untyped, T.untyped]])) }
93
+ attr_reader :presentment_prices
94
+ sig { returns(T.nilable(String)) }
95
+ attr_reader :price
96
+ sig { returns(T.nilable(Integer)) }
97
+ attr_reader :product_id
98
+ sig { returns(T.nilable(T::Boolean)) }
99
+ attr_reader :requires_shipping
100
+ sig { returns(T.nilable(String)) }
101
+ attr_reader :sku
102
+ sig { returns(T.nilable(String)) }
103
+ attr_reader :tax_code
104
+ sig { returns(T.nilable(T::Boolean)) }
105
+ attr_reader :taxable
106
+ sig { returns(T.nilable(String)) }
107
+ attr_reader :title
108
+ sig { returns(T.nilable(String)) }
109
+ attr_reader :updated_at
110
+ sig { returns(T.nilable(Float)) }
111
+ attr_reader :weight
112
+ sig { returns(T.nilable(String)) }
113
+ attr_reader :weight_unit
114
+
115
+ class << self
116
+ sig do
117
+ params(
118
+ id: T.any(Integer, String),
119
+ fields: T.untyped,
120
+ session: Auth::Session
121
+ ).returns(T.nilable(Variant))
122
+ end
123
+ def find(
124
+ id:,
125
+ fields: nil,
126
+ session: ShopifyAPI::Context.active_session
127
+ )
128
+ result = base_find(
129
+ session: session,
130
+ ids: {id: id},
131
+ params: {fields: fields},
132
+ )
133
+ T.cast(result[0], T.nilable(Variant))
134
+ end
135
+
136
+ sig do
137
+ params(
138
+ id: T.any(Integer, String),
139
+ product_id: T.nilable(T.any(Integer, String)),
140
+ session: Auth::Session
141
+ ).returns(T.untyped)
142
+ end
143
+ def delete(
144
+ id:,
145
+ product_id: nil,
146
+ session: ShopifyAPI::Context.active_session
147
+ )
148
+ request(
149
+ http_method: :delete,
150
+ operation: :delete,
151
+ session: session,
152
+ ids: {id: id, product_id: product_id},
153
+ params: {},
154
+ )
155
+ end
156
+
157
+ sig do
158
+ params(
159
+ product_id: T.nilable(T.any(Integer, String)),
160
+ limit: T.untyped,
161
+ presentment_currencies: T.untyped,
162
+ since_id: T.untyped,
163
+ fields: T.untyped,
164
+ session: Auth::Session,
165
+ kwargs: T.untyped
166
+ ).returns(T::Array[Variant])
167
+ end
168
+ def all(
169
+ product_id: nil,
170
+ limit: nil,
171
+ presentment_currencies: nil,
172
+ since_id: nil,
173
+ fields: nil,
174
+ session: ShopifyAPI::Context.active_session,
175
+ **kwargs
176
+ )
177
+ response = base_find(
178
+ session: session,
179
+ ids: {product_id: product_id},
180
+ params: {limit: limit, presentment_currencies: presentment_currencies, since_id: since_id, fields: fields}.merge(kwargs).compact,
181
+ )
182
+
183
+ T.cast(response, T::Array[Variant])
184
+ end
185
+
186
+ sig do
187
+ params(
188
+ product_id: T.nilable(T.any(Integer, String)),
189
+ session: Auth::Session,
190
+ kwargs: T.untyped
191
+ ).returns(T.untyped)
192
+ end
193
+ def count(
194
+ product_id: nil,
195
+ session: ShopifyAPI::Context.active_session,
196
+ **kwargs
197
+ )
198
+ request(
199
+ http_method: :get,
200
+ operation: :count,
201
+ session: session,
202
+ ids: {product_id: product_id},
203
+ params: {}.merge(kwargs).compact,
204
+ body: {},
205
+ entity: nil,
206
+ )
207
+ end
208
+
209
+ end
210
+
211
+ end
212
+ end
@@ -0,0 +1,173 @@
1
+ # typed: false
2
+ # frozen_string_literal: true
3
+
4
+ ########################################################################################################################
5
+ # This file is auto-generated. If you have an issue, please create a GitHub issue. #
6
+ ########################################################################################################################
7
+
8
+ module ShopifyAPI
9
+ class Webhook < ShopifyAPI::Rest::Base
10
+ extend T::Sig
11
+
12
+ @prev_page_info = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
13
+ @next_page_info = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
14
+
15
+ @api_call_limit = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
16
+ @retry_request_after = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
17
+
18
+ sig { params(session: T.nilable(ShopifyAPI::Auth::Session), from_hash: T.nilable(T::Hash[T.untyped, T.untyped])).void }
19
+ def initialize(session: ShopifyAPI::Context.active_session, from_hash: nil)
20
+
21
+ @address = T.let(nil, T.nilable(String))
22
+ @topic = T.let(nil, T.nilable(String))
23
+ @api_version = T.let(nil, T.nilable(String))
24
+ @created_at = T.let(nil, T.nilable(String))
25
+ @fields = T.let(nil, T.nilable(T::Array[T.untyped]))
26
+ @filter = T.let(nil, T.nilable(String))
27
+ @format = T.let(nil, T.nilable(String))
28
+ @id = T.let(nil, T.nilable(Integer))
29
+ @metafield_namespaces = T.let(nil, T.nilable(T::Array[T.untyped]))
30
+ @private_metafield_namespaces = T.let(nil, T.nilable(T::Array[T.untyped]))
31
+ @updated_at = T.let(nil, T.nilable(String))
32
+
33
+ super(session: session, from_hash: from_hash)
34
+ end
35
+
36
+ @has_one = T.let({}, T::Hash[Symbol, Class])
37
+ @has_many = T.let({}, T::Hash[Symbol, Class])
38
+ @paths = T.let([
39
+ {http_method: :delete, operation: :delete, ids: [:id], path: "webhooks/<id>.json"},
40
+ {http_method: :get, operation: :count, ids: [], path: "webhooks/count.json"},
41
+ {http_method: :get, operation: :get, ids: [], path: "webhooks.json"},
42
+ {http_method: :get, operation: :get, ids: [:id], path: "webhooks/<id>.json"},
43
+ {http_method: :post, operation: :post, ids: [], path: "webhooks.json"},
44
+ {http_method: :put, operation: :put, ids: [:id], path: "webhooks/<id>.json"}
45
+ ], T::Array[T::Hash[String, T.any(T::Array[Symbol], String, Symbol)]])
46
+
47
+ sig { returns(T.nilable(String)) }
48
+ attr_reader :address
49
+ sig { returns(T.nilable(String)) }
50
+ attr_reader :topic
51
+ sig { returns(T.nilable(String)) }
52
+ attr_reader :api_version
53
+ sig { returns(T.nilable(String)) }
54
+ attr_reader :created_at
55
+ sig { returns(T.nilable(T::Array[String])) }
56
+ attr_reader :fields
57
+ sig { returns(T.nilable(String)) }
58
+ attr_reader :format
59
+ sig { returns(T.nilable(Integer)) }
60
+ attr_reader :id
61
+ sig { returns(T.nilable(T::Array[String])) }
62
+ attr_reader :metafield_namespaces
63
+ sig { returns(T.nilable(T::Array[String])) }
64
+ attr_reader :private_metafield_namespaces
65
+ sig { returns(T.nilable(String)) }
66
+ attr_reader :updated_at
67
+
68
+ class << self
69
+ sig do
70
+ params(
71
+ id: T.any(Integer, String),
72
+ fields: T.untyped,
73
+ session: Auth::Session
74
+ ).returns(T.nilable(Webhook))
75
+ end
76
+ def find(
77
+ id:,
78
+ fields: nil,
79
+ session: ShopifyAPI::Context.active_session
80
+ )
81
+ result = base_find(
82
+ session: session,
83
+ ids: {id: id},
84
+ params: {fields: fields},
85
+ )
86
+ T.cast(result[0], T.nilable(Webhook))
87
+ end
88
+
89
+ sig do
90
+ params(
91
+ id: T.any(Integer, String),
92
+ session: Auth::Session
93
+ ).returns(T.untyped)
94
+ end
95
+ def delete(
96
+ id:,
97
+ session: ShopifyAPI::Context.active_session
98
+ )
99
+ request(
100
+ http_method: :delete,
101
+ operation: :delete,
102
+ session: session,
103
+ ids: {id: id},
104
+ params: {},
105
+ )
106
+ end
107
+
108
+ sig do
109
+ params(
110
+ address: T.untyped,
111
+ created_at_max: T.untyped,
112
+ created_at_min: T.untyped,
113
+ fields: T.untyped,
114
+ limit: T.untyped,
115
+ since_id: T.untyped,
116
+ topic: T.untyped,
117
+ updated_at_min: T.untyped,
118
+ updated_at_max: T.untyped,
119
+ session: Auth::Session,
120
+ kwargs: T.untyped
121
+ ).returns(T::Array[Webhook])
122
+ end
123
+ def all(
124
+ address: nil,
125
+ created_at_max: nil,
126
+ created_at_min: nil,
127
+ fields: nil,
128
+ limit: nil,
129
+ since_id: nil,
130
+ topic: nil,
131
+ updated_at_min: nil,
132
+ updated_at_max: nil,
133
+ session: ShopifyAPI::Context.active_session,
134
+ **kwargs
135
+ )
136
+ response = base_find(
137
+ session: session,
138
+ ids: {},
139
+ params: {address: address, created_at_max: created_at_max, created_at_min: created_at_min, fields: fields, limit: limit, since_id: since_id, topic: topic, updated_at_min: updated_at_min, updated_at_max: updated_at_max}.merge(kwargs).compact,
140
+ )
141
+
142
+ T.cast(response, T::Array[Webhook])
143
+ end
144
+
145
+ sig do
146
+ params(
147
+ address: T.untyped,
148
+ topic: T.untyped,
149
+ session: Auth::Session,
150
+ kwargs: T.untyped
151
+ ).returns(T.untyped)
152
+ end
153
+ def count(
154
+ address: nil,
155
+ topic: nil,
156
+ session: ShopifyAPI::Context.active_session,
157
+ **kwargs
158
+ )
159
+ request(
160
+ http_method: :get,
161
+ operation: :count,
162
+ session: session,
163
+ ids: {},
164
+ params: {address: address, topic: topic}.merge(kwargs).compact,
165
+ body: {},
166
+ entity: nil,
167
+ )
168
+ end
169
+
170
+ end
171
+
172
+ end
173
+ end
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module ShopifyAPI
5
- VERSION = "14.5.0"
5
+ VERSION = "14.7.0"
6
6
  end
@@ -22,18 +22,23 @@ module ShopifyAPI
22
22
  sig { returns(T.nilable(T::Array[String])) }
23
23
  attr_reader :metafield_namespaces
24
24
 
25
+ sig { returns(T.nilable(String)) }
26
+ attr_reader :filter
27
+
25
28
  sig do
26
29
  params(topic: String, path: String, handler: T.nilable(T.any(Handler, WebhookHandler)),
27
30
  fields: T.nilable(T.any(String, T::Array[String])),
28
- metafield_namespaces: T.nilable(T::Array[String])).void
31
+ metafield_namespaces: T.nilable(T::Array[String]),
32
+ filter: T.nilable(String)).void
29
33
  end
30
- def initialize(topic:, path:, handler: nil, fields: nil, metafield_namespaces: nil)
34
+ def initialize(topic:, path:, handler: nil, fields: nil, metafield_namespaces: nil, filter: nil)
31
35
  @topic = T.let(topic.gsub("/", "_").upcase, String)
32
36
  @path = path
33
37
  @handler = handler
34
38
  fields_array = fields.is_a?(String) ? fields.split(FIELDS_DELIMITER) : fields
35
39
  @fields = T.let(fields_array&.map(&:strip)&.compact, T.nilable(T::Array[String]))
36
40
  @metafield_namespaces = T.let(metafield_namespaces&.map(&:strip)&.compact, T.nilable(T::Array[String]))
41
+ @filter = filter
37
42
  end
38
43
 
39
44
  sig { abstract.returns(String) }
@@ -48,7 +53,15 @@ module ShopifyAPI
48
53
  sig { abstract.returns(String) }
49
54
  def build_check_query; end
50
55
 
51
- sig { abstract.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, String]) }
56
+ sig do
57
+ abstract.params(body: T::Hash[String, T.untyped]).returns({
58
+ webhook_id: T.nilable(String),
59
+ current_address: T.nilable(String),
60
+ fields: T::Array[String],
61
+ metafield_namespaces: T::Array[String],
62
+ filter: T.nilable(String),
63
+ })
64
+ end
52
65
  def parse_check_result(body); end
53
66
 
54
67
  sig { params(webhook_id: T.nilable(String)).returns(String) }
@@ -81,6 +94,7 @@ module ShopifyAPI
81
94
  attributes = ["id"]
82
95
  attributes << "includeFields" if @fields
83
96
  attributes << "metafieldNamespaces" if @metafield_namespaces
97
+ attributes << "filter" if @filter
84
98
  attributes
85
99
  end
86
100
  end
@@ -14,7 +14,8 @@ module ShopifyAPI
14
14
 
15
15
  sig { override.returns(T::Hash[Symbol, String]) }
16
16
  def subscription_args
17
- { arn: callback_address, includeFields: fields, metafieldNamespaces: metafield_namespaces }.compact
17
+ { arn: callback_address, includeFields: fields,
18
+ metafieldNamespaces: metafield_namespaces, filter: filter, }.compact
18
19
  end
19
20
 
20
21
  sig { override.params(webhook_id: T.nilable(String)).returns(String) }
@@ -30,6 +31,9 @@ module ShopifyAPI
30
31
  edges {
31
32
  node {
32
33
  id
34
+ includeFields
35
+ metafieldNamespaces
36
+ filter
33
37
  endpoint {
34
38
  __typename
35
39
  ... on WebhookEventBridgeEndpoint {
@@ -43,17 +47,32 @@ module ShopifyAPI
43
47
  QUERY
44
48
  end
45
49
 
46
- sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, String]) }
50
+ sig do
51
+ override.params(body: T::Hash[String, T.untyped]).returns({
52
+ webhook_id: T.nilable(String),
53
+ current_address: T.nilable(String),
54
+ fields: T::Array[String],
55
+ metafield_namespaces: T::Array[String],
56
+ filter: T.nilable(String),
57
+ })
58
+ end
47
59
  def parse_check_result(body)
48
60
  edges = body.dig("data", "webhookSubscriptions", "edges") || {}
49
61
  webhook_id = nil
62
+ fields = []
63
+ metafield_namespaces = []
64
+ filter = nil
50
65
  current_address = nil
51
66
  unless edges.empty?
52
67
  node = edges[0]["node"]
53
68
  webhook_id = node["id"].to_s
54
69
  current_address = node["endpoint"]["arn"].to_s
70
+ fields = node["includeFields"] || []
71
+ metafield_namespaces = node["metafieldNamespaces"] || []
72
+ filter = node["filter"].to_s
55
73
  end
56
- { webhook_id: webhook_id, current_address: current_address }
74
+ { webhook_id: webhook_id, current_address: current_address, fields: fields,
75
+ metafield_namespaces: metafield_namespaces, filter: filter, }
57
76
  end
58
77
  end
59
78
  end
@@ -20,7 +20,8 @@ module ShopifyAPI
20
20
 
21
21
  sig { override.returns(T::Hash[Symbol, String]) }
22
22
  def subscription_args
23
- { callbackUrl: callback_address, includeFields: fields, metafieldNamespaces: metafield_namespaces }.compact
23
+ { callbackUrl: callback_address, includeFields: fields,
24
+ metafieldNamespaces: metafield_namespaces, filter: filter, }.compact
24
25
  end
25
26
 
26
27
  sig { override.params(webhook_id: T.nilable(String)).returns(String) }
@@ -36,6 +37,9 @@ module ShopifyAPI
36
37
  edges {
37
38
  node {
38
39
  id
40
+ includeFields
41
+ metafieldNamespaces
42
+ filter
39
43
  endpoint {
40
44
  __typename
41
45
  ... on WebhookHttpEndpoint {
@@ -49,10 +53,21 @@ module ShopifyAPI
49
53
  QUERY
50
54
  end
51
55
 
52
- sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, String]) }
56
+ sig do
57
+ override.params(body: T::Hash[String, T.untyped]).returns({
58
+ webhook_id: T.nilable(String),
59
+ current_address: T.nilable(String),
60
+ fields: T::Array[String],
61
+ metafield_namespaces: T::Array[String],
62
+ filter: T.nilable(String),
63
+ })
64
+ end
53
65
  def parse_check_result(body)
54
66
  edges = body.dig("data", "webhookSubscriptions", "edges") || {}
55
67
  webhook_id = nil
68
+ fields = []
69
+ metafield_namespaces = []
70
+ filter = nil
56
71
  current_address = nil
57
72
  unless edges.empty?
58
73
  node = edges[0]["node"]
@@ -63,8 +78,12 @@ module ShopifyAPI
63
78
  else
64
79
  node["callbackUrl"].to_s
65
80
  end
81
+ fields = node["includeFields"] || []
82
+ metafield_namespaces = node["metafieldNamespaces"] || []
83
+ filter = node["filter"].to_s
66
84
  end
67
- { webhook_id: webhook_id, current_address: current_address }
85
+ { webhook_id: webhook_id, current_address: current_address, fields: fields,
86
+ metafield_namespaces: metafield_namespaces, filter: filter, }
68
87
  end
69
88
  end
70
89
  end
@@ -18,7 +18,7 @@ module ShopifyAPI
18
18
  project = project_topic_pair[0]
19
19
  topic = project_topic_pair[1]
20
20
  { pubSubProject: project, pubSubTopic: topic, includeFields: fields,
21
- metafieldNamespaces: metafield_namespaces, }.compact
21
+ metafieldNamespaces: metafield_namespaces, filter: filter, }.compact
22
22
  end
23
23
 
24
24
  sig { override.params(webhook_id: T.nilable(String)).returns(String) }
@@ -34,6 +34,9 @@ module ShopifyAPI
34
34
  edges {
35
35
  node {
36
36
  id
37
+ includeFields
38
+ metafieldNamespaces
39
+ filter
37
40
  endpoint {
38
41
  __typename
39
42
  ... on WebhookPubSubEndpoint {
@@ -48,17 +51,33 @@ module ShopifyAPI
48
51
  QUERY
49
52
  end
50
53
 
51
- sig { override.params(body: T::Hash[String, T.untyped]).returns(T::Hash[Symbol, String]) }
54
+ sig do
55
+ override.params(body: T::Hash[String, T.untyped]).returns({
56
+ webhook_id: T.nilable(String),
57
+ current_address: T.nilable(String),
58
+ fields: T::Array[String],
59
+ metafield_namespaces: T::Array[String],
60
+ filter: T.nilable(String),
61
+ })
62
+ end
52
63
  def parse_check_result(body)
53
64
  edges = body.dig("data", "webhookSubscriptions", "edges") || {}
54
65
  webhook_id = nil
66
+ fields = []
67
+ metafield_namespaces = []
68
+ filter = nil
55
69
  current_address = nil
56
70
  unless edges.empty?
57
71
  node = edges[0]["node"]
58
72
  webhook_id = node["id"].to_s
59
- current_address = "pubsub://#{node["endpoint"]["pubSubProject"]}:#{node["endpoint"]["pubSubTopic"]}"
73
+ current_address =
74
+ "pubsub://#{node["endpoint"]["pubSubProject"]}:#{node["endpoint"]["pubSubTopic"]}"
75
+ fields = node["includeFields"] || []
76
+ metafield_namespaces = node["metafieldNamespaces"] || []
77
+ filter = node["filter"].to_s
60
78
  end
61
- { webhook_id: webhook_id, current_address: current_address }
79
+ { webhook_id: webhook_id, current_address: current_address, fields: fields,
80
+ metafield_namespaces: metafield_namespaces, filter: filter, }
62
81
  end
63
82
  end
64
83
  end
@@ -19,23 +19,25 @@ module ShopifyAPI
19
19
  path: String,
20
20
  handler: T.nilable(T.any(Handler, WebhookHandler)),
21
21
  fields: T.nilable(T.any(String, T::Array[String])),
22
+ filter: T.nilable(String),
22
23
  metafield_namespaces: T.nilable(T::Array[String])).void
23
24
  end
24
- def add_registration(topic:, delivery_method:, path:, handler: nil, fields: nil, metafield_namespaces: nil)
25
+ def add_registration(topic:, delivery_method:, path:, handler: nil, fields: nil, filter: nil,
26
+ metafield_namespaces: nil)
25
27
  @registry[topic] = case delivery_method
26
28
  when :pub_sub
27
29
  Registrations::PubSub.new(topic: topic, path: path, fields: fields,
28
- metafield_namespaces: metafield_namespaces)
30
+ metafield_namespaces: metafield_namespaces, filter: filter)
29
31
  when :event_bridge
30
32
  Registrations::EventBridge.new(topic: topic, path: path, fields: fields,
31
- metafield_namespaces: metafield_namespaces)
33
+ metafield_namespaces: metafield_namespaces, filter: filter)
32
34
  when :http
33
35
  unless handler
34
36
  raise Errors::InvalidWebhookRegistrationError, "Cannot create an Http registration without a handler."
35
37
  end
36
38
 
37
39
  Registrations::Http.new(topic: topic, path: path, handler: handler,
38
- fields: fields, metafield_namespaces: metafield_namespaces)
40
+ fields: fields, metafield_namespaces: metafield_namespaces, filter: filter)
39
41
  else
40
42
  raise Errors::InvalidWebhookRegistrationError,
41
43
  "Unsupported delivery method #{delivery_method}. Allowed values: {:http, :pub_sub, :event_bridge}."
@@ -219,8 +221,16 @@ module ShopifyAPI
219
221
  check_response = client.query(query: registration.build_check_query, response_as_struct: false)
220
222
  raise Errors::WebhookRegistrationError,
221
223
  "Failed to check if webhook was already registered" unless check_response.ok?
224
+
222
225
  parsed_check_result = registration.parse_check_result(T.cast(check_response.body, T::Hash[String, T.untyped]))
223
- must_register = parsed_check_result[:current_address] != registration.callback_address
226
+ registration_fields = registration.fields || []
227
+ registration_metafield_namespaces = registration.metafield_namespaces || []
228
+ registration_filter = registration.filter
229
+
230
+ must_register = parsed_check_result[:current_address] != registration.callback_address ||
231
+ parsed_check_result[:fields].sort != registration_fields.sort ||
232
+ parsed_check_result[:metafield_namespaces].sort != registration_metafield_namespaces.sort ||
233
+ parsed_check_result[:filter] != registration_filter
224
234
 
225
235
  { webhook_id: parsed_check_result[:webhook_id], must_register: must_register }
226
236
  end