shopify_api 12.5.0 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (141) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -0
  3. data/CHANGELOG.md +7 -0
  4. data/Gemfile.lock +2 -2
  5. data/lib/shopify_api/auth/oauth.rb +0 -2
  6. data/lib/shopify_api/clients/http_client.rb +13 -9
  7. data/lib/shopify_api/context.rb +4 -20
  8. data/lib/shopify_api/rest/base.rb +48 -14
  9. data/lib/shopify_api/rest/resources/2022_04/abandoned_checkout.rb +190 -0
  10. data/lib/shopify_api/rest/resources/2022_04/access_scope.rb +58 -0
  11. data/lib/shopify_api/rest/resources/2022_04/android_pay_key.rb +77 -0
  12. data/lib/shopify_api/rest/resources/2022_04/apple_pay_certificate.rb +105 -0
  13. data/lib/shopify_api/rest/resources/2022_04/application_charge.rb +109 -0
  14. data/lib/shopify_api/rest/resources/2022_04/application_credit.rb +92 -0
  15. data/lib/shopify_api/rest/resources/2022_04/article.rb +265 -0
  16. data/lib/shopify_api/rest/resources/2022_04/asset.rb +118 -0
  17. data/lib/shopify_api/rest/resources/2022_04/assigned_fulfillment_order.rb +86 -0
  18. data/lib/shopify_api/rest/resources/2022_04/balance.rb +50 -0
  19. data/lib/shopify_api/rest/resources/2022_04/blog.rb +162 -0
  20. data/lib/shopify_api/rest/resources/2022_04/cancellation_request.rb +83 -0
  21. data/lib/shopify_api/rest/resources/2022_04/carrier_service.rb +116 -0
  22. data/lib/shopify_api/rest/resources/2022_04/checkout.rb +209 -0
  23. data/lib/shopify_api/rest/resources/2022_04/collect.rb +142 -0
  24. data/lib/shopify_api/rest/resources/2022_04/collection.rb +110 -0
  25. data/lib/shopify_api/rest/resources/2022_04/collection_listing.rb +155 -0
  26. data/lib/shopify_api/rest/resources/2022_04/comment.rb +283 -0
  27. data/lib/shopify_api/rest/resources/2022_04/country.rb +137 -0
  28. data/lib/shopify_api/rest/resources/2022_04/currency.rb +57 -0
  29. data/lib/shopify_api/rest/resources/2022_04/custom_collection.rb +187 -0
  30. data/lib/shopify_api/rest/resources/2022_04/customer.rb +329 -0
  31. data/lib/shopify_api/rest/resources/2022_04/customer_address.rb +201 -0
  32. data/lib/shopify_api/rest/resources/2022_04/customer_saved_search.rb +169 -0
  33. data/lib/shopify_api/rest/resources/2022_04/deprecated_api_call.rb +57 -0
  34. data/lib/shopify_api/rest/resources/2022_04/discount_code.rb +222 -0
  35. data/lib/shopify_api/rest/resources/2022_04/dispute.rb +111 -0
  36. data/lib/shopify_api/rest/resources/2022_04/draft_order.rb +275 -0
  37. data/lib/shopify_api/rest/resources/2022_04/event.rb +148 -0
  38. data/lib/shopify_api/rest/resources/2022_04/fulfillment.rb +278 -0
  39. data/lib/shopify_api/rest/resources/2022_04/fulfillment_event.rb +166 -0
  40. data/lib/shopify_api/rest/resources/2022_04/fulfillment_order.rb +284 -0
  41. data/lib/shopify_api/rest/resources/2022_04/fulfillment_request.rb +87 -0
  42. data/lib/shopify_api/rest/resources/2022_04/fulfillment_service.rb +130 -0
  43. data/lib/shopify_api/rest/resources/2022_04/gift_card.rb +218 -0
  44. data/lib/shopify_api/rest/resources/2022_04/gift_card_adjustment.rb +118 -0
  45. data/lib/shopify_api/rest/resources/2022_04/image.rb +157 -0
  46. data/lib/shopify_api/rest/resources/2022_04/inventory_item.rb +108 -0
  47. data/lib/shopify_api/rest/resources/2022_04/inventory_level.rb +179 -0
  48. data/lib/shopify_api/rest/resources/2022_04/location.rb +167 -0
  49. data/lib/shopify_api/rest/resources/2022_04/locations_for_move.rb +56 -0
  50. data/lib/shopify_api/rest/resources/2022_04/marketing_event.rb +209 -0
  51. data/lib/shopify_api/rest/resources/2022_04/metafield.rb +344 -0
  52. data/lib/shopify_api/rest/resources/2022_04/mobile_platform_application.rb +110 -0
  53. data/lib/shopify_api/rest/resources/2022_04/order.rb +473 -0
  54. data/lib/shopify_api/rest/resources/2022_04/order_risk.rb +142 -0
  55. data/lib/shopify_api/rest/resources/2022_04/page.rb +194 -0
  56. data/lib/shopify_api/rest/resources/2022_04/payment.rb +140 -0
  57. data/lib/shopify_api/rest/resources/2022_04/payment_gateway.rb +143 -0
  58. data/lib/shopify_api/rest/resources/2022_04/payment_transaction.rb +107 -0
  59. data/lib/shopify_api/rest/resources/2022_04/payout.rb +97 -0
  60. data/lib/shopify_api/rest/resources/2022_04/policy.rb +69 -0
  61. data/lib/shopify_api/rest/resources/2022_04/price_rule.rb +223 -0
  62. data/lib/shopify_api/rest/resources/2022_04/product.rb +223 -0
  63. data/lib/shopify_api/rest/resources/2022_04/product_listing.rb +196 -0
  64. data/lib/shopify_api/rest/resources/2022_04/product_resource_feedback.rb +88 -0
  65. data/lib/shopify_api/rest/resources/2022_04/province.rb +132 -0
  66. data/lib/shopify_api/rest/resources/2022_04/recurring_application_charge.rb +172 -0
  67. data/lib/shopify_api/rest/resources/2022_04/redirect.rb +139 -0
  68. data/lib/shopify_api/rest/resources/2022_04/refund.rb +151 -0
  69. data/lib/shopify_api/rest/resources/2022_04/report.rb +121 -0
  70. data/lib/shopify_api/rest/resources/2022_04/resource_feedback.rb +73 -0
  71. data/lib/shopify_api/rest/resources/2022_04/script_tag.rb +155 -0
  72. data/lib/shopify_api/rest/resources/2022_04/shipping_zone.rb +83 -0
  73. data/lib/shopify_api/rest/resources/2022_04/shop.rb +218 -0
  74. data/lib/shopify_api/rest/resources/2022_04/smart_collection.rb +216 -0
  75. data/lib/shopify_api/rest/resources/2022_04/storefront_access_token.rb +87 -0
  76. data/lib/shopify_api/rest/resources/2022_04/tender_transaction.rb +93 -0
  77. data/lib/shopify_api/rest/resources/2022_04/theme.rb +123 -0
  78. data/lib/shopify_api/rest/resources/2022_04/transaction.rb +181 -0
  79. data/lib/shopify_api/rest/resources/2022_04/usage_charge.rb +102 -0
  80. data/lib/shopify_api/rest/resources/2022_04/user.rb +138 -0
  81. data/lib/shopify_api/rest/resources/2022_04/variant.rb +212 -0
  82. data/lib/shopify_api/rest/resources/2022_04/webhook.rb +168 -0
  83. data/lib/shopify_api/rest/resources/2022_07/application_credit.rb +2 -2
  84. data/lib/shopify_api/rest/resources/2022_07/carrier_service.rb +3 -0
  85. data/lib/shopify_api/rest/resources/2022_07/discount_code.rb +3 -0
  86. data/lib/shopify_api/rest/resources/2022_07/dispute.rb +2 -2
  87. data/lib/shopify_api/rest/resources/2022_07/draft_order.rb +2 -2
  88. data/lib/shopify_api/rest/resources/2022_07/event.rb +2 -2
  89. data/lib/shopify_api/rest/resources/2022_07/fulfillment.rb +6 -0
  90. data/lib/shopify_api/rest/resources/2022_07/gift_card.rb +8 -5
  91. data/lib/shopify_api/rest/resources/2022_07/order_risk.rb +9 -2
  92. data/lib/shopify_api/rest/resources/2022_07/shipping_zone.rb +2 -2
  93. data/lib/shopify_api/rest/resources/2022_07/shop.rb +2 -2
  94. data/lib/shopify_api/rest/resources/2022_07/theme.rb +3 -0
  95. data/lib/shopify_api/rest/resources/2022_07/usage_charge.rb +2 -2
  96. data/lib/shopify_api/rest/resources/2022_10/application_credit.rb +2 -2
  97. data/lib/shopify_api/rest/resources/2022_10/carrier_service.rb +3 -0
  98. data/lib/shopify_api/rest/resources/2022_10/discount_code.rb +3 -0
  99. data/lib/shopify_api/rest/resources/2022_10/dispute.rb +2 -2
  100. data/lib/shopify_api/rest/resources/2022_10/draft_order.rb +2 -2
  101. data/lib/shopify_api/rest/resources/2022_10/event.rb +2 -2
  102. data/lib/shopify_api/rest/resources/2022_10/fulfillment.rb +6 -0
  103. data/lib/shopify_api/rest/resources/2022_10/gift_card.rb +8 -5
  104. data/lib/shopify_api/rest/resources/2022_10/order_risk.rb +9 -2
  105. data/lib/shopify_api/rest/resources/2022_10/shipping_zone.rb +2 -2
  106. data/lib/shopify_api/rest/resources/2022_10/shop.rb +2 -2
  107. data/lib/shopify_api/rest/resources/2022_10/theme.rb +3 -0
  108. data/lib/shopify_api/rest/resources/2022_10/usage_charge.rb +2 -2
  109. data/lib/shopify_api/rest/resources/2023_01/application_credit.rb +2 -2
  110. data/lib/shopify_api/rest/resources/2023_01/carrier_service.rb +3 -0
  111. data/lib/shopify_api/rest/resources/2023_01/discount_code.rb +3 -0
  112. data/lib/shopify_api/rest/resources/2023_01/dispute.rb +2 -2
  113. data/lib/shopify_api/rest/resources/2023_01/draft_order.rb +2 -2
  114. data/lib/shopify_api/rest/resources/2023_01/event.rb +2 -2
  115. data/lib/shopify_api/rest/resources/2023_01/fulfillment.rb +6 -0
  116. data/lib/shopify_api/rest/resources/2023_01/gift_card.rb +8 -5
  117. data/lib/shopify_api/rest/resources/2023_01/order_risk.rb +9 -2
  118. data/lib/shopify_api/rest/resources/2023_01/shipping_zone.rb +2 -2
  119. data/lib/shopify_api/rest/resources/2023_01/shop.rb +2 -2
  120. data/lib/shopify_api/rest/resources/2023_01/theme.rb +3 -0
  121. data/lib/shopify_api/rest/resources/2023_01/usage_charge.rb +2 -2
  122. data/lib/shopify_api/rest/resources/2023_04/application_credit.rb +2 -2
  123. data/lib/shopify_api/rest/resources/2023_04/carrier_service.rb +3 -0
  124. data/lib/shopify_api/rest/resources/2023_04/discount_code.rb +3 -0
  125. data/lib/shopify_api/rest/resources/2023_04/dispute.rb +2 -2
  126. data/lib/shopify_api/rest/resources/2023_04/draft_order.rb +2 -2
  127. data/lib/shopify_api/rest/resources/2023_04/event.rb +2 -2
  128. data/lib/shopify_api/rest/resources/2023_04/fulfillment.rb +6 -0
  129. data/lib/shopify_api/rest/resources/2023_04/gift_card.rb +8 -5
  130. data/lib/shopify_api/rest/resources/2023_04/order_risk.rb +9 -2
  131. data/lib/shopify_api/rest/resources/2023_04/shipping_zone.rb +2 -2
  132. data/lib/shopify_api/rest/resources/2023_04/shop.rb +2 -2
  133. data/lib/shopify_api/rest/resources/2023_04/theme.rb +3 -0
  134. data/lib/shopify_api/rest/resources/2023_04/usage_charge.rb +2 -2
  135. data/lib/shopify_api/utils/graphql_proxy.rb +3 -6
  136. data/lib/shopify_api/utils/session_utils.rb +0 -84
  137. data/lib/shopify_api/version.rb +1 -1
  138. data/lib/shopify_api/webhooks/registry.rb +1 -1
  139. metadata +77 -5
  140. data/lib/shopify_api/auth/file_session_storage.rb +0 -72
  141. data/lib/shopify_api/auth/session_storage.rb +0 -30
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7fee0ac74bfc70897541951eb87b46e750e0ed650c11b77d3a1c582451c3f4c0
4
- data.tar.gz: 2e935108619f59022b9101a838582311bb5824a268fe2c1034b629339613dce3
3
+ metadata.gz: d36c6512c91e12fdcc4d3f9ee1049241498e41b0406448d19cafb94d97d7c815
4
+ data.tar.gz: 9633547697ee1493db17837b28ea7e0b1e539d6d062e5066bd3f983fdaf4090f
5
5
  SHA512:
6
- metadata.gz: f5830157e403f197fedd154dbd5b69653026fc8ec9cce3d4427764b8e1e189ff303e1104b82faf124e7093f92979003b33be5061db81d825e2219fd7a70e8bef
7
- data.tar.gz: e8fac7416a292ade97b591fa86e91034ae04a50e1d0f870b1f5289dcf40df0b1ccada6210b4255aae8c4e1d57e263bd38a8d0b990da0fa3e3383ef83a1333c60
6
+ metadata.gz: 8964e99218d49f9e0a9bd5e277ead941ad8252d59c59e97a2eba9234f7a7396d92a52628ac7268599f454c2c60cbb8f696d0501ea1e75c5c531b74d4708a28c0
7
+ data.tar.gz: 1d38649055c009278cabec33441525df0086a5fc078e2974da48d845d6f98014409d12068791cefa99c3ef5bc4a79f2012d60a514aeeba5db1a87e8ed1739070
data/.rubocop.yml CHANGED
@@ -57,3 +57,6 @@ Layout/EmptyLineAfterGuardClause:
57
57
  Enabled: true
58
58
  Style/GlobalStdStream:
59
59
  Enabled: true
60
+ Layout/LineLength:
61
+ Exclude:
62
+ - "test/clients/*"
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
4
4
 
5
5
  ## Unreleased
6
6
 
7
+ ## 13.0.0
8
+
9
+ - [#1140](https://github.com/Shopify/shopify-api-ruby/pull/1140) ⚠️ [Breaking] Reformat Http error messages to be JSON parsable.
10
+ - [#1142](https://github.com/Shopify/shopify-api-ruby/issues/1142) Restore API version 2022-04, in alignment with [this](https://shopify.dev/changelog/action-required-support-for-api-version-2022-04-extended-to-june-30-2023) changelog notice.
11
+ - [#1155](https://github.com/Shopify/shopify-api-ruby/pull/1155) ⚠️ [Breaking] Remove session storage that was deprecated with [#1055](https://github.com/Shopify/shopify-api-ruby/pull/1055). ⚠️ [Breaking] GraphQL Proxy now requires `session` to be passed as an argument.
12
+ - [#1150](https://github.com/Shopify/shopify-api-ruby/pull/1150) [Patch] Add support for Event topic names.
13
+
7
14
  ## 12.5.0
8
15
 
9
16
  - [#1113](https://github.com/Shopify/shopify-api-ruby/pull/1113) Handle JSON::ParserError when http response is HTML and raise ShopifyAPI::Errors::HttpResponseError
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_api (12.5.0)
4
+ shopify_api (13.0.0)
5
5
  activesupport
6
6
  concurrent-ruby
7
7
  hash_diff
@@ -36,7 +36,7 @@ GEM
36
36
  httparty (0.21.0)
37
37
  mini_mime (>= 1.0.0)
38
38
  multi_xml (>= 0.5.2)
39
- i18n (1.12.0)
39
+ i18n (1.13.0)
40
40
  concurrent-ruby (~> 1.0)
41
41
  json (2.6.2)
42
42
  jwt (2.7.0)
@@ -93,8 +93,6 @@ module ShopifyAPI
93
93
  )
94
94
  end
95
95
 
96
- Context.session_storage&.store_session(session)
97
-
98
96
  { session: session, cookie: cookie }
99
97
  end
100
98
 
@@ -65,15 +65,7 @@ module ShopifyAPI
65
65
 
66
66
  break if response.ok?
67
67
 
68
- error_messages = []
69
- error_messages << response.body["errors"] if response.body["errors"]
70
-
71
- if response.headers["x-request-id"]
72
- id = T.must(response.headers["x-request-id"])[0]
73
- error_messages << "If you report this error, please include this id: #{id}."
74
- end
75
-
76
- error_message = error_messages.join("\n")
68
+ error_message = serialized_error(response)
77
69
 
78
70
  unless [429, 500].include?(response.code)
79
71
  raise ShopifyAPI::Errors::HttpResponseError.new(response: response), error_message
@@ -102,6 +94,18 @@ module ShopifyAPI
102
94
  def request_url(request)
103
95
  "#{@base_uri_and_path}/#{request.path}"
104
96
  end
97
+
98
+ sig { params(response: HttpResponse).returns(String) }
99
+ def serialized_error(response)
100
+ body = {}
101
+ body["errors"] = response.body["errors"] if response.body["errors"]
102
+
103
+ if response.headers["x-request-id"]
104
+ id = T.must(response.headers["x-request-id"])[0]
105
+ body["error_reference"] = "If you report this error, please include this id: #{id}."
106
+ end
107
+ body.to_json
108
+ end
105
109
  end
106
110
  end
107
111
  end
@@ -15,8 +15,7 @@ module ShopifyAPI
15
15
  @logger = T.let(::Logger.new($stdout), ::Logger)
16
16
  @log_level = T.let(:info, Symbol)
17
17
  @notified_missing_resources_folder = T.let({}, T::Hash[String, T::Boolean])
18
- @active_session = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
19
- @session_storage = T.let(nil, T.nilable(ShopifyAPI::Auth::SessionStorage))
18
+ @active_session = T.let(Concurrent::ThreadLocalVar.new { nil }, T.nilable(Concurrent::ThreadLocalVar))
20
19
  @user_agent_prefix = T.let(nil, T.nilable(String))
21
20
  @old_api_secret_key = T.let(nil, T.nilable(String))
22
21
 
@@ -35,7 +34,6 @@ module ShopifyAPI
35
34
  is_embedded: T::Boolean,
36
35
  log_level: T.any(String, Symbol),
37
36
  logger: ::Logger,
38
- session_storage: T.nilable(ShopifyAPI::Auth::SessionStorage),
39
37
  host_name: T.nilable(String),
40
38
  host: T.nilable(String),
41
39
  private_shop: T.nilable(String),
@@ -52,7 +50,6 @@ module ShopifyAPI
52
50
  is_embedded:,
53
51
  log_level: :info,
54
52
  logger: ::Logger.new($stdout),
55
- session_storage: nil,
56
53
  host_name: nil,
57
54
  host: ENV["HOST"] || "https://#{host_name}",
58
55
  private_shop: nil,
@@ -71,7 +68,6 @@ module ShopifyAPI
71
68
  @is_private = is_private
72
69
  @scope = Auth::AuthScopes.new(scope)
73
70
  @is_embedded = is_embedded
74
- @session_storage = session_storage
75
71
  @logger = logger
76
72
  @private_shop = private_shop
77
73
  @user_agent_prefix = user_agent_prefix
@@ -82,13 +78,6 @@ module ShopifyAPI
82
78
  :info
83
79
  end
84
80
 
85
- if @session_storage
86
- ::ShopifyAPI::Logger.deprecated("The use of SessionStorage in the API library has been deprecated. " \
87
- "The ShopifyAPI will no longer have responsibility for session persistence. " \
88
- "Upgrading to `shopify_app` 21.3 will allow you to remove session_storage" \
89
- " from the API library Context configuration.", "13.0.0")
90
- end
91
-
92
81
  load_rest_resources(api_version: api_version)
93
82
  end
94
83
 
@@ -126,9 +115,6 @@ module ShopifyAPI
126
115
  sig { returns(Auth::AuthScopes) }
127
116
  attr_reader :scope
128
117
 
129
- sig { returns(T.nilable(ShopifyAPI::Auth::SessionStorage)) }
130
- attr_reader :session_storage
131
-
132
118
  sig { returns(::Logger) }
133
119
  attr_reader :logger
134
120
 
@@ -155,19 +141,17 @@ module ShopifyAPI
155
141
 
156
142
  sig { returns(T.nilable(Auth::Session)) }
157
143
  def active_session
158
- return @active_session.value unless @active_session.value.nil?
159
-
160
- private? ? Utils::SessionUtils.load_current_session : nil
144
+ @active_session&.value
161
145
  end
162
146
 
163
147
  sig { params(session: T.nilable(Auth::Session)).void }
164
148
  def activate_session(session)
165
- @active_session.value = session
149
+ T.must(@active_session).value = session
166
150
  end
167
151
 
168
152
  sig { void }
169
153
  def deactivate_session
170
- @active_session.value = nil
154
+ T.must(@active_session).value = nil
171
155
  end
172
156
 
173
157
  sig { returns(String) }
@@ -21,7 +21,7 @@ module ShopifyAPI
21
21
  sig { returns(T::Hash[Symbol, T.untyped]) }
22
22
  attr_accessor :original_state
23
23
 
24
- sig { returns(Rest::BaseErrors) }
24
+ sig { returns(T.any(Rest::BaseErrors, T.nilable(T::Hash[T.untyped, T.untyped]))) }
25
25
  attr_reader :errors
26
26
 
27
27
  sig do
@@ -234,16 +234,20 @@ module ShopifyAPI
234
234
  attr_sym = attribute.to_sym
235
235
 
236
236
  if has_many?(attr_sym) && value
237
+ instance.original_state[attr_sym] = []
237
238
  attr_list = []
238
239
  value.each do |element|
239
- attr_list << T.unsafe(@has_many[attr_sym]).create_instance(data: element, session: session)
240
+ child = T.unsafe(@has_many[attr_sym]).create_instance(data: element, session: session)
241
+ attr_list << child
242
+ instance.original_state[attr_sym] << child.to_hash(true)
240
243
  end
241
244
  instance.public_send("#{attribute}=", attr_list)
242
245
  elsif has_one?(attr_sym) && value
243
246
  # force a hash if core returns values that instantiate objects like "USD"
244
247
  data_hash = value.is_a?(Hash) ? value : { attribute.to_s => value }
245
- instance.public_send("#{attribute}=",
246
- T.unsafe(@has_one[attr_sym]).create_instance(data: data_hash, session: session))
248
+ child = T.unsafe(@has_one[attr_sym]).create_instance(data: data_hash, session: session)
249
+ instance.public_send("#{attribute}=", child)
250
+ instance.original_state[attr_sym] = child.to_hash(true)
247
251
  else
248
252
  instance.public_send("#{attribute}=", value)
249
253
  instance.original_state[attr_sym] = value
@@ -335,16 +339,12 @@ module ShopifyAPI
335
339
 
336
340
  sig { params(update_object: T::Boolean).void }
337
341
  def save(update_object: false)
338
- hash = HashDiff::Comparison.new(original_state, to_hash(true)).left_diff
339
- method = hash[self.class.primary_key] ? :put : :post
340
-
341
- path = self.class.get_path(http_method: method, operation: method, entity: self)
342
- if path.nil?
343
- method = method == :post ? :put : :post
344
- path = self.class.get_path(http_method: method, operation: method, entity: self)
345
- end
346
-
347
- response = @client.public_send(method, body: { self.class.json_body_name => hash }, path: path)
342
+ method = deduce_write_verb
343
+ response = @client.public_send(
344
+ method,
345
+ body: { self.class.json_body_name => attributes_to_update },
346
+ path: deduce_write_path(method),
347
+ )
348
348
 
349
349
  if update_object
350
350
  self.class.create_instance(
@@ -359,6 +359,40 @@ module ShopifyAPI
359
359
 
360
360
  private
361
361
 
362
+ sig { returns(T::Hash[String, String]) }
363
+ def attributes_to_update
364
+ HashDiff::Comparison.new(
365
+ deep_stringify_keys(original_state),
366
+ deep_stringify_keys(to_hash(true)),
367
+ ).left_diff
368
+ end
369
+
370
+ sig { returns(Symbol) }
371
+ def deduce_write_verb
372
+ send(self.class.primary_key) ? :put : :post
373
+ end
374
+
375
+ sig { params(method: Symbol).returns(T.nilable(String)) }
376
+ def deduce_write_path(method)
377
+ path = self.class.get_path(http_method: method, operation: method, entity: self)
378
+
379
+ if path.nil?
380
+ method = method == :post ? :put : :post
381
+ path = self.class.get_path(http_method: method, operation: method, entity: self)
382
+ end
383
+
384
+ path
385
+ end
386
+
387
+ sig { params(hash: T::Hash[T.any(String, Symbol), T.untyped]).returns(T::Hash[String, String]) }
388
+ def deep_stringify_keys(hash)
389
+ hash.each_with_object({}) do |(key, value), result|
390
+ new_key = key.to_s
391
+ new_value = value.is_a?(Hash) ? deep_stringify_keys(value) : value
392
+ result[new_key] = new_value
393
+ end
394
+ end
395
+
362
396
  sig { params(key: T.any(String, Symbol), val: T.untyped).void }
363
397
  def set_property(key, val)
364
398
  # Some API fields contain invalid characters, like `?`, which causes issues when setting them as instance
@@ -0,0 +1,190 @@
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 AbandonedCheckout < 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
+ sig { params(session: T.nilable(ShopifyAPI::Auth::Session)).void }
16
+ def initialize(session: ShopifyAPI::Context.active_session)
17
+ super(session: session)
18
+
19
+ @abandoned_checkout_url = T.let(nil, T.nilable(String))
20
+ @billing_address = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
21
+ @buyer_accepts_marketing = T.let(nil, T.nilable(T::Boolean))
22
+ @buyer_accepts_sms_marketing = T.let(nil, T.nilable(T::Boolean))
23
+ @cart_token = T.let(nil, T.nilable(String))
24
+ @closed_at = T.let(nil, T.nilable(String))
25
+ @completed_at = T.let(nil, T.nilable(String))
26
+ @created_at = T.let(nil, T.nilable(String))
27
+ @currency = T.let(nil, T.nilable(Currency))
28
+ @customer = T.let(nil, T.nilable(Customer))
29
+ @customer_locale = T.let(nil, T.nilable(String))
30
+ @device_id = T.let(nil, T.nilable(Integer))
31
+ @discount_codes = T.let(nil, T.nilable(T::Array[T.untyped]))
32
+ @email = T.let(nil, T.nilable(String))
33
+ @gateway = T.let(nil, T.nilable(String))
34
+ @id = T.let(nil, T.nilable(Integer))
35
+ @landing_site = T.let(nil, T.nilable(String))
36
+ @line_items = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
37
+ @location_id = T.let(nil, T.nilable(Integer))
38
+ @note = T.let(nil, T.nilable(String))
39
+ @phone = T.let(nil, T.nilable(String))
40
+ @presentment_currency = T.let(nil, T.nilable(String))
41
+ @referring_site = T.let(nil, T.nilable(String))
42
+ @shipping_address = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
43
+ @shipping_lines = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
44
+ @sms_marketing_phone = T.let(nil, T.nilable(String))
45
+ @source_name = T.let(nil, T.nilable(String))
46
+ @subtotal_price = T.let(nil, T.nilable(String))
47
+ @tax_lines = T.let(nil, T.nilable(T::Hash[T.untyped, T.untyped]))
48
+ @taxes_included = T.let(nil, T.nilable(T::Boolean))
49
+ @token = T.let(nil, T.nilable(String))
50
+ @total_discounts = T.let(nil, T.nilable(String))
51
+ @total_duties = T.let(nil, T.nilable(String))
52
+ @total_line_items_price = T.let(nil, T.nilable(String))
53
+ @total_price = T.let(nil, T.nilable(String))
54
+ @total_tax = T.let(nil, T.nilable(String))
55
+ @total_weight = T.let(nil, T.nilable(Integer))
56
+ @updated_at = T.let(nil, T.nilable(String))
57
+ @user_id = T.let(nil, T.nilable(Integer))
58
+ end
59
+
60
+ @has_one = T.let({
61
+ currency: Currency,
62
+ customer: Customer
63
+ }, T::Hash[Symbol, Class])
64
+ @has_many = T.let({
65
+ discount_codes: DiscountCode
66
+ }, T::Hash[Symbol, Class])
67
+ @paths = T.let([
68
+ {http_method: :get, operation: :checkouts, ids: [], path: "checkouts.json"},
69
+ {http_method: :get, operation: :checkouts, ids: [], path: "checkouts.json"}
70
+ ], T::Array[T::Hash[String, T.any(T::Array[Symbol], String, Symbol)]])
71
+
72
+ sig { returns(T.nilable(String)) }
73
+ attr_reader :abandoned_checkout_url
74
+ sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
75
+ attr_reader :billing_address
76
+ sig { returns(T.nilable(T::Boolean)) }
77
+ attr_reader :buyer_accepts_marketing
78
+ sig { returns(T.nilable(T::Boolean)) }
79
+ attr_reader :buyer_accepts_sms_marketing
80
+ sig { returns(T.nilable(String)) }
81
+ attr_reader :cart_token
82
+ sig { returns(T.nilable(String)) }
83
+ attr_reader :closed_at
84
+ sig { returns(T.nilable(String)) }
85
+ attr_reader :completed_at
86
+ sig { returns(T.nilable(String)) }
87
+ attr_reader :created_at
88
+ sig { returns(T.nilable(Currency)) }
89
+ attr_reader :currency
90
+ sig { returns(T.nilable(Customer)) }
91
+ attr_reader :customer
92
+ sig { returns(T.nilable(String)) }
93
+ attr_reader :customer_locale
94
+ sig { returns(T.nilable(Integer)) }
95
+ attr_reader :device_id
96
+ sig { returns(T.nilable(T::Array[DiscountCode])) }
97
+ attr_reader :discount_codes
98
+ sig { returns(T.nilable(String)) }
99
+ attr_reader :email
100
+ sig { returns(T.nilable(String)) }
101
+ attr_reader :gateway
102
+ sig { returns(T.nilable(Integer)) }
103
+ attr_reader :id
104
+ sig { returns(T.nilable(String)) }
105
+ attr_reader :landing_site
106
+ sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
107
+ attr_reader :line_items
108
+ sig { returns(T.nilable(Integer)) }
109
+ attr_reader :location_id
110
+ sig { returns(T.nilable(String)) }
111
+ attr_reader :note
112
+ sig { returns(T.nilable(String)) }
113
+ attr_reader :phone
114
+ sig { returns(T.nilable(String)) }
115
+ attr_reader :presentment_currency
116
+ sig { returns(T.nilable(String)) }
117
+ attr_reader :referring_site
118
+ sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
119
+ attr_reader :shipping_address
120
+ sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
121
+ attr_reader :shipping_lines
122
+ sig { returns(T.nilable(String)) }
123
+ attr_reader :sms_marketing_phone
124
+ sig { returns(T.nilable(String)) }
125
+ attr_reader :source_name
126
+ sig { returns(T.nilable(String)) }
127
+ attr_reader :subtotal_price
128
+ sig { returns(T.nilable(T::Hash[T.untyped, T.untyped])) }
129
+ attr_reader :tax_lines
130
+ sig { returns(T.nilable(T::Boolean)) }
131
+ attr_reader :taxes_included
132
+ sig { returns(T.nilable(String)) }
133
+ attr_reader :token
134
+ sig { returns(T.nilable(String)) }
135
+ attr_reader :total_discounts
136
+ sig { returns(T.nilable(String)) }
137
+ attr_reader :total_duties
138
+ sig { returns(T.nilable(String)) }
139
+ attr_reader :total_line_items_price
140
+ sig { returns(T.nilable(String)) }
141
+ attr_reader :total_price
142
+ sig { returns(T.nilable(String)) }
143
+ attr_reader :total_tax
144
+ sig { returns(T.nilable(Integer)) }
145
+ attr_reader :total_weight
146
+ sig { returns(T.nilable(String)) }
147
+ attr_reader :updated_at
148
+ sig { returns(T.nilable(Integer)) }
149
+ attr_reader :user_id
150
+
151
+ class << self
152
+ sig do
153
+ params(
154
+ since_id: T.untyped,
155
+ created_at_min: T.untyped,
156
+ created_at_max: T.untyped,
157
+ updated_at_min: T.untyped,
158
+ updated_at_max: T.untyped,
159
+ status: T.untyped,
160
+ limit: T.untyped,
161
+ session: Auth::Session,
162
+ kwargs: T.untyped
163
+ ).returns(T.untyped)
164
+ end
165
+ def checkouts(
166
+ since_id: nil,
167
+ created_at_min: nil,
168
+ created_at_max: nil,
169
+ updated_at_min: nil,
170
+ updated_at_max: nil,
171
+ status: nil,
172
+ limit: nil,
173
+ session: ShopifyAPI::Context.active_session,
174
+ **kwargs
175
+ )
176
+ request(
177
+ http_method: :get,
178
+ operation: :checkouts,
179
+ session: session,
180
+ ids: {},
181
+ params: {since_id: since_id, created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max, status: status, limit: limit}.merge(kwargs).compact,
182
+ body: {},
183
+ entity: nil,
184
+ )
185
+ end
186
+
187
+ end
188
+
189
+ end
190
+ end
@@ -0,0 +1,58 @@
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 AccessScope < 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
+ sig { params(session: T.nilable(ShopifyAPI::Auth::Session)).void }
16
+ def initialize(session: ShopifyAPI::Context.active_session)
17
+ super(session: session)
18
+
19
+ @handle = T.let(nil, T.nilable(String))
20
+ @access_scopes = T.let(nil, T.nilable(T::Array[T.untyped]))
21
+ end
22
+
23
+ @has_one = T.let({}, T::Hash[Symbol, Class])
24
+ @has_many = T.let({}, T::Hash[Symbol, Class])
25
+ @custom_prefix = T.let("/admin/oauth", T.nilable(String))
26
+ @paths = T.let([
27
+ {http_method: :get, operation: :get, ids: [], path: "access_scopes.json"}
28
+ ], T::Array[T::Hash[String, T.any(T::Array[Symbol], String, Symbol)]])
29
+
30
+ sig { returns(T.nilable(String)) }
31
+ attr_reader :handle
32
+ sig { returns(T.nilable(T::Array[T::Hash[T.untyped, T.untyped]])) }
33
+ attr_reader :access_scopes
34
+
35
+ class << self
36
+ sig do
37
+ params(
38
+ session: Auth::Session,
39
+ kwargs: T.untyped
40
+ ).returns(T::Array[AccessScope])
41
+ end
42
+ def all(
43
+ session: ShopifyAPI::Context.active_session,
44
+ **kwargs
45
+ )
46
+ response = base_find(
47
+ session: session,
48
+ ids: {},
49
+ params: {}.merge(kwargs).compact,
50
+ )
51
+
52
+ T.cast(response, T::Array[AccessScope])
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+ end
@@ -0,0 +1,77 @@
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 AndroidPayKey < 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
+ sig { params(session: T.nilable(ShopifyAPI::Auth::Session)).void }
16
+ def initialize(session: ShopifyAPI::Context.active_session)
17
+ super(session: session)
18
+
19
+ @id = T.let(nil, T.nilable(Integer))
20
+ @public_key = T.let(nil, T.nilable(String))
21
+ end
22
+
23
+ @has_one = T.let({}, T::Hash[Symbol, Class])
24
+ @has_many = T.let({}, T::Hash[Symbol, Class])
25
+ @paths = T.let([
26
+ {http_method: :delete, operation: :delete, ids: [:id], path: "android_pay_keys/<id>.json"},
27
+ {http_method: :get, operation: :get, ids: [:id], path: "android_pay_keys/<id>.json"},
28
+ {http_method: :post, operation: :post, ids: [], path: "android_pay_keys.json"}
29
+ ], T::Array[T::Hash[String, T.any(T::Array[Symbol], String, Symbol)]])
30
+
31
+ sig { returns(T.nilable(Integer)) }
32
+ attr_reader :id
33
+ sig { returns(T.nilable(String)) }
34
+ attr_reader :public_key
35
+
36
+ class << self
37
+ sig do
38
+ params(
39
+ id: T.any(Integer, String),
40
+ session: Auth::Session
41
+ ).returns(T.nilable(AndroidPayKey))
42
+ end
43
+ def find(
44
+ id:,
45
+ session: ShopifyAPI::Context.active_session
46
+ )
47
+ result = base_find(
48
+ session: session,
49
+ ids: {id: id},
50
+ params: {},
51
+ )
52
+ T.cast(result[0], T.nilable(AndroidPayKey))
53
+ end
54
+
55
+ sig do
56
+ params(
57
+ id: T.any(Integer, String),
58
+ session: Auth::Session
59
+ ).returns(T.untyped)
60
+ end
61
+ def delete(
62
+ id:,
63
+ session: ShopifyAPI::Context.active_session
64
+ )
65
+ request(
66
+ http_method: :delete,
67
+ operation: :delete,
68
+ session: session,
69
+ ids: {id: id},
70
+ params: {},
71
+ )
72
+ end
73
+
74
+ end
75
+
76
+ end
77
+ end