shopify_api 12.4.0 → 12.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (200) hide show
  1. checksums.yaml +4 -4
  2. data/.github/api_update_reminder.md +25 -0
  3. data/.github/api_update_reminder_on_release.md +19 -0
  4. data/.github/workflows/api_update_reminder.yml +16 -0
  5. data/.github/workflows/api_update_reminder_on_release.yml +16 -0
  6. data/.github/workflows/stale.yml +20 -10
  7. data/CHANGELOG.md +11 -4
  8. data/CONTRIBUTING.md +2 -2
  9. data/Gemfile.lock +6 -6
  10. data/README.md +10 -10
  11. data/docs/getting_started.md +2 -2
  12. data/docs/usage/graphql.md +6 -0
  13. data/docs/usage/graphql_storefront.md +8 -2
  14. data/docs/usage/oauth.md +1 -1
  15. data/docs/usage/rest.md +9 -2
  16. data/docs/usage/webhooks.md +1 -1
  17. data/lib/shopify_api/admin_versions.rb +2 -1
  18. data/lib/shopify_api/clients/graphql/admin.rb +3 -3
  19. data/lib/shopify_api/clients/graphql/client.rb +13 -3
  20. data/lib/shopify_api/clients/graphql/storefront.rb +3 -3
  21. data/lib/shopify_api/clients/http_client.rb +8 -1
  22. data/lib/shopify_api/clients/rest/admin.rb +14 -3
  23. data/lib/shopify_api/rest/base.rb +3 -1
  24. data/lib/shopify_api/rest/resources/2022_07/application_charge.rb +6 -1
  25. data/lib/shopify_api/rest/resources/2022_07/application_credit.rb +6 -1
  26. data/lib/shopify_api/rest/resources/2022_07/gift_card.rb +4 -4
  27. data/lib/shopify_api/rest/resources/2022_07/metafield.rb +2 -2
  28. data/lib/shopify_api/rest/resources/2022_07/order.rb +2 -2
  29. data/lib/shopify_api/rest/resources/2022_07/recurring_application_charge.rb +6 -1
  30. data/lib/shopify_api/rest/resources/2022_07/shipping_zone.rb +6 -6
  31. data/lib/shopify_api/rest/resources/2022_07/usage_charge.rb +6 -1
  32. data/lib/shopify_api/rest/resources/2022_10/application_charge.rb +6 -1
  33. data/lib/shopify_api/rest/resources/2022_10/application_credit.rb +6 -1
  34. data/lib/shopify_api/rest/resources/2022_10/gift_card.rb +4 -4
  35. data/lib/shopify_api/rest/resources/2022_10/metafield.rb +2 -2
  36. data/lib/shopify_api/rest/resources/2022_10/order.rb +2 -2
  37. data/lib/shopify_api/rest/resources/2022_10/recurring_application_charge.rb +6 -1
  38. data/lib/shopify_api/rest/resources/2022_10/shipping_zone.rb +6 -6
  39. data/lib/shopify_api/rest/resources/2022_10/usage_charge.rb +6 -1
  40. data/lib/shopify_api/rest/resources/2023_01/application_charge.rb +6 -1
  41. data/lib/shopify_api/rest/resources/2023_01/application_credit.rb +6 -1
  42. data/lib/shopify_api/rest/resources/2023_01/dispute_evidence.rb +117 -0
  43. data/lib/shopify_api/rest/resources/{2022_04/storefront_access_token.rb → 2023_01/dispute_file_upload.rb} +27 -33
  44. data/lib/shopify_api/rest/resources/2023_01/gift_card.rb +4 -4
  45. data/lib/shopify_api/rest/resources/2023_01/metafield.rb +2 -2
  46. data/lib/shopify_api/rest/resources/2023_01/order.rb +2 -2
  47. data/lib/shopify_api/rest/resources/2023_01/recurring_application_charge.rb +6 -1
  48. data/lib/shopify_api/rest/resources/2023_01/shipping_zone.rb +6 -6
  49. data/lib/shopify_api/rest/resources/2023_01/usage_charge.rb +6 -1
  50. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/application_charge.rb +6 -1
  51. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/application_credit.rb +6 -1
  52. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/carrier_service.rb +0 -3
  53. data/lib/shopify_api/rest/resources/2023_04/dispute_evidence.rb +117 -0
  54. data/lib/shopify_api/rest/resources/{2022_04/android_pay_key.rb → 2023_04/dispute_file_upload.rb} +29 -25
  55. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/fulfillment.rb +2 -49
  56. data/lib/shopify_api/rest/resources/{2022_04 → 2023_04}/fulfillment_order.rb +36 -8
  57. data/lib/shopify_api/rest/resources/{2022_04 → 2023_04}/fulfillment_service.rb +3 -3
  58. data/lib/shopify_api/rest/resources/{2022_04 → 2023_04}/gift_card.rb +4 -4
  59. data/lib/shopify_api/rest/resources/{2022_04 → 2023_04}/metafield.rb +2 -2
  60. data/lib/shopify_api/rest/resources/{2022_04 → 2023_04}/order.rb +14 -2
  61. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/recurring_application_charge.rb +6 -1
  62. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/shipping_zone.rb +6 -6
  63. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/shop.rb +3 -0
  64. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/transaction.rb +3 -0
  65. data/lib/shopify_api/rest/resources/{2022_04 → 2023_04}/usage_charge.rb +6 -1
  66. data/lib/shopify_api/version.rb +1 -1
  67. data/shopify_api.gemspec +1 -1
  68. metadata +85 -152
  69. data/lib/shopify_api/rest/resources/2022_01/android_pay_key.rb +0 -77
  70. data/lib/shopify_api/rest/resources/2022_01/customer.rb +0 -326
  71. data/lib/shopify_api/rest/resources/2022_01/fulfillment_order.rb +0 -281
  72. data/lib/shopify_api/rest/resources/2022_01/fulfillment_service.rb +0 -130
  73. data/lib/shopify_api/rest/resources/2022_01/gift_card.rb +0 -215
  74. data/lib/shopify_api/rest/resources/2022_01/metafield.rb +0 -349
  75. data/lib/shopify_api/rest/resources/2022_01/order.rb +0 -473
  76. data/lib/shopify_api/rest/resources/2022_01/price_rule.rb +0 -223
  77. data/lib/shopify_api/rest/resources/2022_01/usage_charge.rb +0 -97
  78. data/lib/shopify_api/rest/resources/2022_04/abandoned_checkout.rb +0 -190
  79. data/lib/shopify_api/rest/resources/2022_04/access_scope.rb +0 -58
  80. data/lib/shopify_api/rest/resources/2022_04/apple_pay_certificate.rb +0 -105
  81. data/lib/shopify_api/rest/resources/2022_04/application_charge.rb +0 -104
  82. data/lib/shopify_api/rest/resources/2022_04/application_credit.rb +0 -87
  83. data/lib/shopify_api/rest/resources/2022_04/article.rb +0 -265
  84. data/lib/shopify_api/rest/resources/2022_04/asset.rb +0 -118
  85. data/lib/shopify_api/rest/resources/2022_04/assigned_fulfillment_order.rb +0 -86
  86. data/lib/shopify_api/rest/resources/2022_04/balance.rb +0 -50
  87. data/lib/shopify_api/rest/resources/2022_04/blog.rb +0 -162
  88. data/lib/shopify_api/rest/resources/2022_04/cancellation_request.rb +0 -83
  89. data/lib/shopify_api/rest/resources/2022_04/carrier_service.rb +0 -116
  90. data/lib/shopify_api/rest/resources/2022_04/checkout.rb +0 -209
  91. data/lib/shopify_api/rest/resources/2022_04/collect.rb +0 -142
  92. data/lib/shopify_api/rest/resources/2022_04/collection.rb +0 -110
  93. data/lib/shopify_api/rest/resources/2022_04/collection_listing.rb +0 -155
  94. data/lib/shopify_api/rest/resources/2022_04/comment.rb +0 -283
  95. data/lib/shopify_api/rest/resources/2022_04/country.rb +0 -137
  96. data/lib/shopify_api/rest/resources/2022_04/currency.rb +0 -57
  97. data/lib/shopify_api/rest/resources/2022_04/custom_collection.rb +0 -187
  98. data/lib/shopify_api/rest/resources/2022_04/customer_address.rb +0 -201
  99. data/lib/shopify_api/rest/resources/2022_04/customer_saved_search.rb +0 -169
  100. data/lib/shopify_api/rest/resources/2022_04/deprecated_api_call.rb +0 -57
  101. data/lib/shopify_api/rest/resources/2022_04/discount_code.rb +0 -219
  102. data/lib/shopify_api/rest/resources/2022_04/dispute.rb +0 -111
  103. data/lib/shopify_api/rest/resources/2022_04/draft_order.rb +0 -275
  104. data/lib/shopify_api/rest/resources/2022_04/event.rb +0 -148
  105. data/lib/shopify_api/rest/resources/2022_04/fulfillment.rb +0 -272
  106. data/lib/shopify_api/rest/resources/2022_04/fulfillment_event.rb +0 -166
  107. data/lib/shopify_api/rest/resources/2022_04/fulfillment_request.rb +0 -87
  108. data/lib/shopify_api/rest/resources/2022_04/gift_card_adjustment.rb +0 -118
  109. data/lib/shopify_api/rest/resources/2022_04/image.rb +0 -157
  110. data/lib/shopify_api/rest/resources/2022_04/inventory_item.rb +0 -108
  111. data/lib/shopify_api/rest/resources/2022_04/inventory_level.rb +0 -179
  112. data/lib/shopify_api/rest/resources/2022_04/location.rb +0 -167
  113. data/lib/shopify_api/rest/resources/2022_04/locations_for_move.rb +0 -56
  114. data/lib/shopify_api/rest/resources/2022_04/marketing_event.rb +0 -209
  115. data/lib/shopify_api/rest/resources/2022_04/mobile_platform_application.rb +0 -110
  116. data/lib/shopify_api/rest/resources/2022_04/order_risk.rb +0 -135
  117. data/lib/shopify_api/rest/resources/2022_04/page.rb +0 -194
  118. data/lib/shopify_api/rest/resources/2022_04/payment.rb +0 -140
  119. data/lib/shopify_api/rest/resources/2022_04/payment_gateway.rb +0 -143
  120. data/lib/shopify_api/rest/resources/2022_04/payment_transaction.rb +0 -107
  121. data/lib/shopify_api/rest/resources/2022_04/payout.rb +0 -97
  122. data/lib/shopify_api/rest/resources/2022_04/policy.rb +0 -69
  123. data/lib/shopify_api/rest/resources/2022_04/product.rb +0 -223
  124. data/lib/shopify_api/rest/resources/2022_04/product_listing.rb +0 -196
  125. data/lib/shopify_api/rest/resources/2022_04/product_resource_feedback.rb +0 -88
  126. data/lib/shopify_api/rest/resources/2022_04/province.rb +0 -132
  127. data/lib/shopify_api/rest/resources/2022_04/recurring_application_charge.rb +0 -167
  128. data/lib/shopify_api/rest/resources/2022_04/redirect.rb +0 -139
  129. data/lib/shopify_api/rest/resources/2022_04/refund.rb +0 -151
  130. data/lib/shopify_api/rest/resources/2022_04/report.rb +0 -121
  131. data/lib/shopify_api/rest/resources/2022_04/resource_feedback.rb +0 -73
  132. data/lib/shopify_api/rest/resources/2022_04/script_tag.rb +0 -155
  133. data/lib/shopify_api/rest/resources/2022_04/shipping_zone.rb +0 -83
  134. data/lib/shopify_api/rest/resources/2022_04/shop.rb +0 -218
  135. data/lib/shopify_api/rest/resources/2022_04/smart_collection.rb +0 -216
  136. data/lib/shopify_api/rest/resources/2022_04/tender_transaction.rb +0 -93
  137. data/lib/shopify_api/rest/resources/2022_04/theme.rb +0 -120
  138. data/lib/shopify_api/rest/resources/2022_04/transaction.rb +0 -181
  139. data/lib/shopify_api/rest/resources/2022_04/user.rb +0 -138
  140. data/lib/shopify_api/rest/resources/2022_04/variant.rb +0 -212
  141. data/lib/shopify_api/rest/resources/2022_04/webhook.rb +0 -168
  142. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/abandoned_checkout.rb +0 -0
  143. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/access_scope.rb +0 -0
  144. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/apple_pay_certificate.rb +0 -0
  145. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/article.rb +0 -0
  146. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/asset.rb +0 -0
  147. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/assigned_fulfillment_order.rb +0 -0
  148. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/balance.rb +0 -0
  149. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/blog.rb +0 -0
  150. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/cancellation_request.rb +0 -0
  151. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/checkout.rb +0 -0
  152. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/collect.rb +0 -0
  153. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/collection.rb +0 -0
  154. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/collection_listing.rb +0 -0
  155. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/comment.rb +0 -0
  156. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/country.rb +0 -0
  157. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/currency.rb +0 -0
  158. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/custom_collection.rb +0 -0
  159. /data/lib/shopify_api/rest/resources/{2022_04 → 2023_04}/customer.rb +0 -0
  160. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/customer_address.rb +0 -0
  161. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/customer_saved_search.rb +0 -0
  162. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/deprecated_api_call.rb +0 -0
  163. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/discount_code.rb +0 -0
  164. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/dispute.rb +0 -0
  165. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/draft_order.rb +0 -0
  166. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/event.rb +0 -0
  167. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/fulfillment_event.rb +0 -0
  168. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/fulfillment_request.rb +0 -0
  169. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/gift_card_adjustment.rb +0 -0
  170. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/image.rb +0 -0
  171. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/inventory_item.rb +0 -0
  172. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/inventory_level.rb +0 -0
  173. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/location.rb +0 -0
  174. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/locations_for_move.rb +0 -0
  175. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/marketing_event.rb +0 -0
  176. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/mobile_platform_application.rb +0 -0
  177. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/order_risk.rb +0 -0
  178. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/page.rb +0 -0
  179. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/payment.rb +0 -0
  180. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/payment_gateway.rb +0 -0
  181. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/payment_transaction.rb +0 -0
  182. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/payout.rb +0 -0
  183. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/policy.rb +0 -0
  184. /data/lib/shopify_api/rest/resources/{2022_04 → 2023_04}/price_rule.rb +0 -0
  185. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/product.rb +0 -0
  186. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/product_listing.rb +0 -0
  187. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/product_resource_feedback.rb +0 -0
  188. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/province.rb +0 -0
  189. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/redirect.rb +0 -0
  190. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/refund.rb +0 -0
  191. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/report.rb +0 -0
  192. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/resource_feedback.rb +0 -0
  193. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/script_tag.rb +0 -0
  194. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/smart_collection.rb +0 -0
  195. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/storefront_access_token.rb +0 -0
  196. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/tender_transaction.rb +0 -0
  197. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/theme.rb +0 -0
  198. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/user.rb +0 -0
  199. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/variant.rb +0 -0
  200. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/webhook.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f87e892122968b0fc410c734d089ec03952c3b5bbf2793fcca078730ac280233
4
- data.tar.gz: 928a01df0d1bc4312fee18e768d84c3585e1d72b39871e63b473080ee35943ed
3
+ metadata.gz: 7fee0ac74bfc70897541951eb87b46e750e0ed650c11b77d3a1c582451c3f4c0
4
+ data.tar.gz: 2e935108619f59022b9101a838582311bb5824a268fe2c1034b629339613dce3
5
5
  SHA512:
6
- metadata.gz: dd43ee271006e1ca390d151c002ad9a65439ad2cbe2a9350bd20e2756797dd38697eaf1c3437f243d3d478fd55d116eebb991be148913d2b0c48293fcd572496
7
- data.tar.gz: 295e7ec37443a12589fe3bd2a8edd18fdba3cc76016d1fa829a6334378547a017f326f798f318eb833da33f75361921553843cb1207139edf33e426636ef2c6c
6
+ metadata.gz: f5830157e403f197fedd154dbd5b69653026fc8ec9cce3d4427764b8e1e189ff303e1104b82faf124e7093f92979003b33be5061db81d825e2219fd7a70e8bef
7
+ data.tar.gz: e8fac7416a292ade97b591fa86e91034ae04a50e1d0f870b1f5289dcf40df0b1ccada6210b4255aae8c4e1d57e263bd38a8d0b990da0fa3e3383ef83a1333c60
@@ -0,0 +1,25 @@
1
+ ---
2
+ title: A new release of the Shopify API is due soon
3
+ labels: automated
4
+ ---
5
+
6
+ This is an automated reminder for the maintainers that a new Stable release of the Shopify API is due soon, so the library needs to be updated.
7
+
8
+ A new library release should be prepared to:
9
+ * add the upcoming Stable release
10
+ * remove the oldest Stable release which will no longer be supported.
11
+
12
+ The PR should be created as a **draft** but not yet be merged.
13
+
14
+ The release schedule can be found at https://shopify.dev/concepts/about-apis/versioning
15
+
16
+ Review the changelog and consider if anything in the library needs to change:
17
+
18
+ https://shopify.dev/changelog
19
+
20
+ Test against the upcoming release by using the Release Candidate.
21
+
22
+ Another reminder issue will be created on the date of the next release.
23
+ When that happens, test again using the now Stable API version, and aim to release an update of the library within one week.
24
+
25
+ Thank you!
@@ -0,0 +1,19 @@
1
+ ---
2
+ title: A new release of the Shopify API occurred
3
+ labels: automated
4
+ ---
5
+
6
+ This is an automated reminder for the maintainers that a new Stable release of the Shopify API is scheduled for today
7
+ at 12pm Eastern Time, so a new release of the library is now due.
8
+
9
+ A draft PR should already exist for this.
10
+
11
+ Review the changelog again and consider if anything in the library needs to change:
12
+
13
+ https://shopify.dev/changelog
14
+
15
+ Test against the new release by using the Stable version just released.
16
+
17
+ Aim to release an update of the library within one week.
18
+
19
+ Thank you!
@@ -0,0 +1,16 @@
1
+ on:
2
+ workflow_dispatch: ~
3
+ schedule:
4
+ - cron: "0 0 1 3,6,9,12 *" # At 00:00 on 1st of March, June, September, and December
5
+
6
+ name: API update reminder
7
+ jobs:
8
+ reminder:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - uses: JasonEtco/create-an-issue@v2.4.0
13
+ env:
14
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15
+ with:
16
+ filename: .github/api_update_reminder.md
@@ -0,0 +1,16 @@
1
+ on:
2
+ workflow_dispatch: ~
3
+ schedule:
4
+ - cron: "0 0 1 1,4,7,10 *" # At 00:00 on 1st of January, April, July, and October
5
+
6
+ name: API update reminder on release
7
+ jobs:
8
+ reminder:
9
+ runs-on: ubuntu-latest
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - uses: JasonEtco/create-an-issue@v2.4.0
13
+ env:
14
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
15
+ with:
16
+ filename: .github/api_update_reminder_on_release.md
@@ -1,33 +1,43 @@
1
- name: Close inactive issues
1
+ name: Close inactive issues / prs
2
2
  on:
3
3
  schedule:
4
4
  - cron: "30 1 * * *"
5
5
 
6
6
  jobs:
7
- close-issues:
7
+ stale:
8
8
  runs-on: ubuntu-latest
9
9
  permissions:
10
10
  issues: write
11
11
  pull-requests: write
12
12
  steps:
13
- - uses: actions/stale@v5
13
+ - uses: actions/stale@v7
14
14
  with:
15
15
  days-before-issue-stale: 60
16
16
  days-before-issue-close: 14
17
+ days-before-pr-stale: 60
18
+ days-before-pr-close: 14
17
19
  operations-per-run: 1000
18
20
  stale-issue-label: "Stale"
21
+ stale-pr-label: "Stale"
19
22
  stale-issue-message: >
20
- This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.
23
+ This issue is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.
21
24
  close-issue-message: |
22
- We are closing this issue because it has been inactive for a few months.
23
- This probably means that it is not reproducible or it has been fixed in a newer version.
25
+ We are closing this issue because it has been inactive for a few months.
26
+ This probably means that it is not reproducible or it has been fixed in a newer version.
24
27
  If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
25
28
 
26
29
  If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the [CONTRIBUTING.md](https://github.com/Shopify/shopify-api-ruby/blob/main/CONTRIBUTING.md) file for guidelines
27
30
 
28
31
  Thank you!
29
- days-before-pr-stale: -1
30
- days-before-pr-close: -1
31
- repo-token: ${{ secrets.GITHUB_TOKEN }}
32
- exempt-issue-labels: "feature request"
32
+ stale-pr-message: >
33
+ This pull request is stale because it has been open for 60 days with no activity. It will be closed if no further action occurs in 14 days.
34
+ close-pr-message: |
35
+ We are closing this pull request because it has been inactive for a few months.
36
+ This probably means that it is not reproducible or it has been fixed in a newer version.
37
+ If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
38
+
39
+ If you still encounter this pull request with the latest stable version, please reopen using the pull request template. You can also contribute directly by submitting a pull request– see the [CONTRIBUTING.md](https://github.com/Shopify/shopify-api-ruby/blob/main/CONTRIBUTING.md) file for guidelines
40
+
41
+ Thank you!
42
+ repo-token: ${{ github.token }}
33
43
  close-issue-reason: "not_planned"
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
+ ## 12.5.0
8
+
9
+ - [#1113](https://github.com/Shopify/shopify-api-ruby/pull/1113) Handle JSON::ParserError when http response is HTML and raise ShopifyAPI::Errors::HttpResponseError
10
+ - [#1098](https://github.com/Shopify/shopify-api-ruby/pull/1098) Gracefully handle HTTP 204 repsonse bodies
11
+ - [#1104](https://github.com/Shopify/shopify-api-ruby/pull/1104) Allow api version overrides.
12
+ - [#1137](https://github.com/Shopify/shopify-api-ruby/pull/1137) Support for 2023_04 API version. Fix reported typing bugs.
13
+
7
14
  ## Version 12.4.0
8
15
 
9
16
  - [#1092](https://github.com/Shopify/shopify-api-ruby/pull/1092) Add support for 2023-01 API version.
@@ -129,13 +136,13 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
129
136
  ## Version 9.0.3
130
137
 
131
138
  - We now raise a `ShopifyAPI::ValidationException` exception when clients try to use `Product` and `Variant` with deprecated inventory-related fields in API version `2019-10` or later. [#655](https://github.com/Shopify/shopify-api-ruby/pull/655) Deprecation and migration information can be found in the following documents:
132
- - [Product Variant REST API Reference](https://shopify.dev/docs/admin-api/rest/reference/products/product-variant)
139
+ - [Product Variant REST API Reference](https://shopify.dev/docs/api/admin-rest/reference/resources/product-variant)
133
140
  - [Migrate your app to support multiple locations](https://shopify.dev/tutorials/migrate-your-app-to-support-multiple-locations)
134
141
  - [Manage product inventory with the Admin API](https://shopify.dev/tutorials/manage-product-inventory-with-admin-api)
135
142
  - Added support for the Discount Code API batch endpoints [#701](https://github.com/Shopify/shopify-api-ruby/pull/701)
136
- - [Create](https://shopify.dev/docs/admin-api/rest/reference/discounts/discountcode#batch_create-2020-01)
137
- - [Show](https://shopify.dev/docs/admin-api/rest/reference/discounts/discountcode#batch_show-2020-01)
138
- - [List](https://shopify.dev/docs/admin-api/rest/reference/discounts/discountcode#batch_discount_codes_index-2020-01)
143
+ - [Create](https://shopify.dev/docs/api/admin-rest/reference/resources/discountcode#batch_create-2020-01)
144
+ - [Show](https://shopify.dev/docs/api/admin-rest/reference/resources/discountcode#batch_show-2020-01)
145
+ - [List](https://shopify.dev/docs/api/admin-rest/reference/resources/discountcode#batch_discount_codes_index-2020-01)
139
146
  - Fix issue in the README to explicitly say clients need to require the `shopify_api` gem [#700](https://github.com/Shopify/shopify-api-ruby/pull/700)
140
147
 
141
148
  ## Version 9.0.2
data/CONTRIBUTING.md CHANGED
@@ -2,8 +2,8 @@
2
2
  Submitting Issues
3
3
  -----------------
4
4
 
5
- Please open an issue here if you encounter a specific bug with this API client library or if something is documented here https://shopify.dev/apps but is missing from this package.
5
+ Please open an issue here if you encounter a specific bug with this API client library or if something is documented here https://shopify.dev/docs/apps but is missing from this package.
6
6
 
7
7
  General questions about the Shopify API and usage of this package (not necessarily a bug) should be posted on the [Shopify forums](https://community.shopify.com/c/partners-and-developers/ct-p/appdev).
8
8
 
9
- When in doubt, post on the forum first. You'll likely have your questions answered more quickly if you post there; more people monitor the forum than Github.
9
+ When in doubt, post on the forum first. You'll likely have your questions answered more quickly if you post there; more people monitor the forum than Github.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- shopify_api (12.4.0)
4
+ shopify_api (12.5.0)
5
5
  activesupport
6
6
  concurrent-ruby
7
7
  hash_diff
@@ -16,7 +16,7 @@ PATH
16
16
  GEM
17
17
  remote: https://rubygems.org/
18
18
  specs:
19
- activesupport (7.0.4)
19
+ activesupport (7.0.4.3)
20
20
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
21
  i18n (>= 1.6, < 2)
22
22
  minitest (>= 5.1)
@@ -26,7 +26,7 @@ GEM
26
26
  ast (2.4.2)
27
27
  byebug (11.1.3)
28
28
  coderay (1.1.3)
29
- concurrent-ruby (1.1.10)
29
+ concurrent-ruby (1.2.2)
30
30
  crack (0.4.5)
31
31
  rexml
32
32
  diff-lcs (1.5.0)
@@ -39,7 +39,7 @@ GEM
39
39
  i18n (1.12.0)
40
40
  concurrent-ruby (~> 1.0)
41
41
  json (2.6.2)
42
- jwt (2.6.0)
42
+ jwt (2.7.0)
43
43
  language_server-protocol (3.17.0.1)
44
44
  method_source (1.0.0)
45
45
  mini_mime (1.1.2)
@@ -47,7 +47,7 @@ GEM
47
47
  mocha (1.13.0)
48
48
  multi_xml (0.6.0)
49
49
  netrc (0.11.0)
50
- oj (3.13.23)
50
+ oj (3.14.3)
51
51
  openssl (3.1.0)
52
52
  parallel (1.22.1)
53
53
  parser (3.1.2.1)
@@ -117,7 +117,7 @@ GEM
117
117
  thor (>= 1.2.0)
118
118
  yard-sorbet
119
119
  thor (1.2.1)
120
- tzinfo (2.0.5)
120
+ tzinfo (2.0.6)
121
121
  concurrent-ruby (~> 1.0)
122
122
  unicode-display_width (2.3.0)
123
123
  unparser (0.6.5)
data/README.md CHANGED
@@ -4,14 +4,14 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)
5
5
  ![Build Status](https://github.com/Shopify/shopify-api-ruby/workflows/CI/badge.svg?branch=main)
6
6
 
7
- This library provides support for Ruby [Shopify apps](https://apps.shopify.com/) to access the [Shopify Admin API](https://shopify.dev/api/admin), by making it easier to perform the following actions:
7
+ This library provides support for Ruby [Shopify apps](https://apps.shopify.com/) to access the [Shopify Admin API](https://shopify.dev/docs/api/admin), by making it easier to perform the following actions:
8
8
 
9
- - Creating [online](https://shopify.dev/apps/auth/oauth/access-modes#online-access) or [offline](https://shopify.dev/apps/auth/oauth/access-modes#offline-access) access tokens for the Admin API via OAuth
10
- - Making requests to the [REST API](https://shopify.dev/api/admin-rest)
11
- - Making requests to the [GraphQL API](https://shopify.dev/api/admin-graphql)
9
+ - Creating [online](https://shopify.dev/docs/apps/auth/oauth/access-modes#online-access) or [offline](https://shopify.dev/docs/apps/auth/oauth/access-modes#offline-access) access tokens for the Admin API via OAuth
10
+ - Making requests to the [REST API](https://shopify.dev/docs/api/admin-rest)
11
+ - Making requests to the [GraphQL API](https://shopify.dev/docs/api/admin-graphql)
12
12
  - Registering/processing webhooks
13
13
 
14
- In addition to the Admin API, this library also allows querying the [Storefront API](https://shopify.dev/docs/storefront-api).
14
+ In addition to the Admin API, this library also allows querying the [Storefront API](https://shopify.dev/docs/api/storefront).
15
15
 
16
16
  You can use this library in any application that has a Ruby backend, since it doesn't rely on any specific framework — you can include it alongside your preferred stack and use the features that you need to build your app.
17
17
 
@@ -54,7 +54,7 @@ ShopifyAPI::Context.setup(
54
54
  scope: "read_orders,read_products,etc",
55
55
  session_storage: ShopifyAPI::Auth::FileSessionStorage.new, # See more details below
56
56
  is_embedded: true, # Set to true if you are building an embedded app
57
- api_version: "2022-01" # The version of the API you would like to use
57
+ api_version: "2022-01", # The version of the API you would like to use
58
58
  is_private: false, # Set to true if you have an existing private app
59
59
  )
60
60
  ```
@@ -63,11 +63,11 @@ ShopifyAPI::Context.setup(
63
63
 
64
64
  In order for the Shopify API gem to properly store sessions it needs an implementation of `ShopifyAPI::Auth::SessionStorage`. We provide one implementation in the gem, `ShopifyAPI::Auth::FileSessionStorage`, which is suitable for testing/development, but isn't intended for production apps. See the [Session Storage doc](docs/usage/session_storage.md) for instructions on how to create a custom session store for a production application.
65
65
 
66
- Session information would is typically stored in cookies on the browser. However, due to restrictions with modern browsers we highly discourage using cookies for embedded apps. For this reason, an app needs to define a storage implementation that the library can use to store and retrieve a session given its ID. In a non-embedded app this ID will come from a cookie, whereas in an embedded app this ID will come from [App Bridge](https://shopify.dev/apps/tools/app-bridge).
66
+ Session information would is typically stored in cookies on the browser. However, due to restrictions with modern browsers we highly discourage using cookies for embedded apps. For this reason, an app needs to define a storage implementation that the library can use to store and retrieve a session given its ID. In a non-embedded app this ID will come from a cookie, whereas in an embedded app this ID will come from [App Bridge](https://shopify.dev/docs/apps/tools/app-bridge).
67
67
 
68
68
  ### Performing OAuth
69
69
 
70
- You need to go through OAuth as described [here](https://shopify.dev/apps/auth/oauth) to create sessions for shops using your app.
70
+ You need to go through OAuth as described [here](https://shopify.dev/docs/apps/auth/oauth) to create sessions for shops using your app.
71
71
  The Shopify API gem tries to make this easy by providing functions to begin and complete the OAuth process. See the [Oauth doc](docs/usage/oauth.md) for instructions on how to use these.
72
72
 
73
73
  ### Register Webhooks and a Webhook Handler
@@ -90,7 +90,7 @@ Here are the main features it provides:
90
90
  - Full, transparent support for JWT sessions for embedded apps and cookies for non-embedded ones.
91
91
  - Removal of support for 3rd party cookies which are increasingly more difficult to use with modern browsers.
92
92
  - Admin API support
93
- - Auto-generated, version-specific REST resources which are similar to `ActiveResource` (though not identical), that provide methods for all endpoints defined in our [REST API reference](https://shopify.dev/api/admin-rest), as well as direct definition of known attributes.
93
+ - Auto-generated, version-specific REST resources which are similar to `ActiveResource` (though not identical), that provide methods for all endpoints defined in our [REST API reference](https://shopify.dev/docs/api/admin-rest), as well as direct definition of known attributes.
94
94
  - A GraphQL client that doesn't rely on the ActiveResource implementation for REST.
95
95
  - Webhook management, with features for adding handlers and registering them with Shopify.
96
96
  - Storefront GraphQL API support
@@ -102,7 +102,7 @@ With this, a lot changed in how apps access the library. Here are the updates yo
102
102
  - Call `ShopifyAPI::Context.setup` when setting up your app. This class holds global configurations for your app and defines how the library behaves.
103
103
  - If not using the `shopify_app` gem, your app needs to provide an implementation of `ShopifyAPI::Auth::SessionStorage` for production. Read more about this [in our documentation](docs/usage/session_storage.md).
104
104
  - To change the `User-Agent` header, use `user_agent_prefix` in `ShopifyAPI::Context.setup`.
105
- - Usages of the `ActiveResource` classes for REST API requests need to be refactored into the new format. You can find detailed examples on how each of the endpoints work in our [reference documentation](https://shopify.dev/api/admin-rest).
105
+ - Usages of the `ActiveResource` classes for REST API requests need to be refactored into the new format. You can find detailed examples on how each of the endpoints work in our [reference documentation](https://shopify.dev/docs/api/admin-rest).
106
106
 
107
107
  Please see below a (non-exhaustive) list of common replacements to guide you in your updates, using the `Order` resource as an example.
108
108
 
@@ -37,11 +37,11 @@ ShopifyAPI::Context.setup(
37
37
 
38
38
  In order for the Shopify API gem to properly store sessions it needs an implementation of `ShopifyAPI::Auth::SessionStorage`. There is one provided in the gem, `ShopifyAPI::Auth::FileSessionStorage`, this is suitable for testing, however it is not intended for production apps. See the [Session Storage doc](usage/session_storage.md) for instructions on how to create a custom session store for a production application.
39
39
 
40
- Normally session information would be stored in cookies on the browser. However, due to restrictions with modern browsers we highly discourage using cookies for embedded apps. For this reason, an app needs to define a storage implementation that can be used to store and retrieve a session given an ID. In a non embedded app this ID will come from a cookie however, in an embedded app this ID will come from [App Bridge](https://shopify.dev/apps/tools/app-bridge)
40
+ Normally session information would be stored in cookies on the browser. However, due to restrictions with modern browsers we highly discourage using cookies for embedded apps. For this reason, an app needs to define a storage implementation that can be used to store and retrieve a session given an ID. In a non embedded app this ID will come from a cookie however, in an embedded app this ID will come from [App Bridge](https://shopify.dev/docs/apps/tools/app-bridge)
41
41
 
42
42
  ### Performing OAuth
43
43
 
44
- Next, unless you are making a private app, you need to go through OAuth as described [here](https://shopify.dev/apps/auth/oauth) to create sessions for shops using your app.
44
+ Next, unless you are making a private app, you need to go through OAuth as described [here](https://shopify.dev/docs/apps/auth/oauth) to create sessions for shops using your app.
45
45
  The Shopify API gem tries to make this easy by providing functions to begin and complete the OAuth process. See the [Oauth doc](usage/oauth.md) for instructions on how to use these.
46
46
 
47
47
  ### Register Webhooks and a Webhook Handler
@@ -88,6 +88,12 @@ response = client.query(query: query, variables: variables)
88
88
  # do something with the reponse
89
89
  ```
90
90
 
91
+ By default, the client uses the API version configured in `ShopifyAPI`. To use a different API version, set the optional `api_version` parameter. To experiment with prerelease API features, use `"unstable"` for the API version.
92
+
93
+ ```ruby
94
+ client = ShopifyAPI::Clients::Graphql::Admin.new(session: session, api_version: "unstable")
95
+ ```
96
+
91
97
  Want to make calls to the Storefront API? Click [here](graphql_storefront.md)
92
98
 
93
99
  # Proxy a GraphQL Query
@@ -1,8 +1,8 @@
1
1
  # Make a Storefront API call
2
2
 
3
- The library also allows you to send GraphQL requests to the [Shopify Storefront API](https://shopify.dev/docs/storefront-api). To do that, you can use `ShopifyAPI::Clients::Graphql::Storefront` with the current session and a `storefrontAccessToken`.
3
+ The library also allows you to send GraphQL requests to the [Shopify Storefront API](https://shopify.dev/docs/api/storefront). To do that, you can use `ShopifyAPI::Clients::Graphql::Storefront` with the current session and a `storefrontAccessToken`.
4
4
 
5
- You can obtain Storefront API access tokens for both private apps and sales channels. Please read [our documentation](https://shopify.dev/docs/storefront-api/getting-started) to learn more about Storefront Access Tokens.
5
+ You can obtain Storefront API access tokens for both private apps and sales channels. Please read [our documentation](https://shopify.dev/docs/custom-storefronts/building-with-the-storefront-api/getting-started) to learn more about Storefront Access Tokens.
6
6
 
7
7
  Below is an example of how you may query the Storefront API:
8
8
 
@@ -39,4 +39,10 @@ response = client.query(query: query)
39
39
  # do something with the returned data
40
40
  ```
41
41
 
42
+ By default, the client uses the API version configured in `ShopifyAPI`. To use a different API version, set the optional `api_version` parameter. To experiment with prerelease API features, use `"unstable"` for the API version.
43
+
44
+ ```ruby
45
+ client = ShopifyAPI::Clients::Graphql::Storefront.new(shop_url, storefront_access_token, api_version: "unstable")
46
+ ```
47
+
42
48
  Want to make calls to the Admin API? Click [here](graphql.md)
data/docs/usage/oauth.md CHANGED
@@ -3,7 +3,7 @@
3
3
  Once the library is set up for your project, you'll be able to use it to start adding functionality to your app. The first thing your app will need to do is to obtain an access token to the Admin API by performing the OAuth process.
4
4
 
5
5
  To do this, you can follow the steps below.
6
- For more information on authenticating a Shopify app please see the [Types of Authentication](https://shopify.dev/apps/auth#types-of-authentication) page.
6
+ For more information on authenticating a Shopify app please see the [Types of Authentication](https://shopify.dev/docs/apps/auth#types-of-authentication) page.
7
7
 
8
8
  ## Add a route to start OAuth
9
9
 
data/docs/usage/rest.md CHANGED
@@ -60,11 +60,18 @@ client.post({
60
60
  });
61
61
  ```
62
62
 
63
- _for more information on the `products` endpoint, [check out our API reference guide](https://shopify.dev/api/admin-rest/unstable/resources/product)._
63
+ _for more information on the `products` endpoint, [check out our API reference guide](https://shopify.dev/docs/api/admin-rest/unstable/resources/product)._
64
+
65
+ ### Override the `api_version`:
66
+
67
+ ```ruby
68
+ # To experiment with prerelease features, pass the api_version "unstable".
69
+ client = ShopifyAPI::Clients::Rest::Admin.new(session: session, api_version: "unstable")
70
+ ```
64
71
 
65
72
  ## Pagination
66
73
 
67
- This library also supports cursor-based pagination for REST Admin API requests. [Learn more about REST request pagination](https://shopify.dev/api/usage/pagination-rest).
74
+ This library also supports cursor-based pagination for REST Admin API requests. [Learn more about REST request pagination](https://shopify.dev/docs/api/usage/pagination-rest).
68
75
 
69
76
  After making a request, the `next_page_info` and `prev_page_info` can be found on the response object and passed as the page_info query param in other requests.
70
77
 
@@ -90,7 +90,7 @@ To process an http webhook, you need to listen on the route(s) you provided duri
90
90
  class WebhookController < ApplicationController
91
91
  def webhook
92
92
  ShopifyAPI::Webhooks::Registry.process(
93
- ShopifyAPI::Webhooks::WebhookRequest.new(raw_body: request.raw_post, headers: request.headers.to_h)
93
+ ShopifyAPI::Webhooks::Request.new(raw_body: request.raw_post, headers: request.headers.to_h)
94
94
  )
95
95
  render json: {success: true}.to_json
96
96
  end
@@ -5,6 +5,7 @@ module ShopifyAPI
5
5
  module AdminVersions
6
6
  SUPPORTED_ADMIN_VERSIONS = T.let([
7
7
  "unstable",
8
+ "2023-04",
8
9
  "2023-01",
9
10
  "2022-10",
10
11
  "2022-07",
@@ -12,7 +13,7 @@ module ShopifyAPI
12
13
  "2022-01",
13
14
  ], T::Array[String])
14
15
 
15
- LATEST_SUPPORTED_ADMIN_VERSION = T.let("2023-01", String)
16
+ LATEST_SUPPORTED_ADMIN_VERSION = T.let("2023-04", String)
16
17
  end
17
18
 
18
19
  SUPPORTED_ADMIN_VERSIONS = ShopifyAPI::AdminVersions::SUPPORTED_ADMIN_VERSIONS
@@ -5,9 +5,9 @@ module ShopifyAPI
5
5
  module Clients
6
6
  module Graphql
7
7
  class Admin < Client
8
- sig { params(session: T.nilable(Auth::Session)).void }
9
- def initialize(session:)
10
- super(session: session, base_path: "/admin/api")
8
+ sig { params(session: T.nilable(Auth::Session), api_version: T.nilable(String)).void }
9
+ def initialize(session:, api_version: nil)
10
+ super(session: session, base_path: "/admin/api", api_version: api_version)
11
11
  end
12
12
  end
13
13
  end
@@ -7,9 +7,19 @@ module ShopifyAPI
7
7
  class Client
8
8
  extend T::Sig
9
9
 
10
- sig { params(session: T.nilable(Auth::Session), base_path: String).void }
11
- def initialize(session:, base_path:)
10
+ sig { params(session: T.nilable(Auth::Session), base_path: String, api_version: T.nilable(String)).void }
11
+ def initialize(session:, base_path:, api_version: nil)
12
12
  @http_client = T.let(HttpClient.new(session: session, base_path: base_path), HttpClient)
13
+ @api_version = T.let(api_version || Context.api_version, String)
14
+ if api_version
15
+ if api_version == Context.api_version
16
+ Context.logger.debug("Graphql client has a redundant API version override "\
17
+ "to the default #{Context.api_version}")
18
+ else
19
+ Context.logger.debug("Graphql client overriding default API version "\
20
+ "#{Context.api_version} with #{api_version}")
21
+ end
22
+ end
13
23
  end
14
24
 
15
25
  sig do
@@ -25,7 +35,7 @@ module ShopifyAPI
25
35
  @http_client.request(
26
36
  HttpRequest.new(
27
37
  http_method: :post,
28
- path: "#{Context.api_version}/graphql.json",
38
+ path: "#{@api_version}/graphql.json",
29
39
  body: body,
30
40
  query: nil,
31
41
  extra_headers: headers,
@@ -5,15 +5,15 @@ module ShopifyAPI
5
5
  module Clients
6
6
  module Graphql
7
7
  class Storefront < Client
8
- sig { params(shop: String, storefront_access_token: String).void }
9
- def initialize(shop, storefront_access_token)
8
+ sig { params(shop: String, storefront_access_token: String, api_version: T.nilable(String)).void }
9
+ def initialize(shop, storefront_access_token, api_version: nil)
10
10
  session = Auth::Session.new(
11
11
  id: shop,
12
12
  shop: shop,
13
13
  access_token: "",
14
14
  is_online: false,
15
15
  )
16
- super(session: session, base_path: "/api")
16
+ super(session: session, base_path: "/api", api_version: api_version)
17
17
  @storefront_access_token = storefront_access_token
18
18
  end
19
19
 
@@ -48,7 +48,14 @@ module ShopifyAPI
48
48
  body: request.body.class == Hash ? T.unsafe(request.body).to_json : request.body,
49
49
  ), HTTParty::Response)
50
50
 
51
- body = res.body.empty? ? {} : JSON.parse(res.body)
51
+ begin
52
+ body = res.body.nil? || res.body.empty? ? {} : JSON.parse(res.body)
53
+ rescue JSON::ParserError
54
+ raise if res.code.to_i < 500
55
+
56
+ body = res.body
57
+ end
58
+
52
59
  response = HttpResponse.new(code: res.code.to_i, headers: res.headers.to_h, body: body)
53
60
 
54
61
  if response.headers["x-shopify-api-deprecated-reason"]
@@ -7,9 +7,20 @@ module ShopifyAPI
7
7
  class Admin < HttpClient
8
8
  extend T::Sig
9
9
 
10
- sig { params(session: T.nilable(Auth::Session)).void }
11
- def initialize(session: nil)
12
- super(session: session, base_path: "/admin/api/#{Context.api_version}")
10
+ sig { params(session: T.nilable(Auth::Session), api_version: T.nilable(String)).void }
11
+ def initialize(session: nil, api_version: nil)
12
+ @api_version = T.let(api_version || Context.api_version, String)
13
+ if api_version
14
+ if api_version == Context.api_version
15
+ Context.logger.debug("Rest client has a redundant API version override "\
16
+ "to the default #{Context.api_version}")
17
+ else
18
+ Context.logger.debug("Rest client overriding default API version "\
19
+ "#{Context.api_version} with #{api_version}")
20
+ end
21
+ end
22
+
23
+ super(session: session, base_path: "/admin/api/#{@api_version}")
13
24
  end
14
25
 
15
26
  sig do
@@ -240,8 +240,10 @@ module ShopifyAPI
240
240
  end
241
241
  instance.public_send("#{attribute}=", attr_list)
242
242
  elsif has_one?(attr_sym) && value
243
+ # force a hash if core returns values that instantiate objects like "USD"
244
+ data_hash = value.is_a?(Hash) ? value : { attribute.to_s => value }
243
245
  instance.public_send("#{attribute}=",
244
- T.unsafe(@has_one[attr_sym]).create_instance(data: value, session: session))
246
+ T.unsafe(@has_one[attr_sym]).create_instance(data: data_hash, session: session))
245
247
  else
246
248
  instance.public_send("#{attribute}=", value)
247
249
  instance.original_state[attr_sym] = value
@@ -18,6 +18,7 @@ module ShopifyAPI
18
18
 
19
19
  @confirmation_url = T.let(nil, T.nilable(String))
20
20
  @created_at = T.let(nil, T.nilable(String))
21
+ @currency = T.let(nil, T.nilable(Currency))
21
22
  @id = T.let(nil, T.nilable(Integer))
22
23
  @name = T.let(nil, T.nilable(String))
23
24
  @price = T.let(nil, T.nilable(T.any(String, Float)))
@@ -27,7 +28,9 @@ module ShopifyAPI
27
28
  @updated_at = T.let(nil, T.nilable(String))
28
29
  end
29
30
 
30
- @has_one = T.let({}, T::Hash[Symbol, Class])
31
+ @has_one = T.let({
32
+ currency: Currency
33
+ }, T::Hash[Symbol, Class])
31
34
  @has_many = T.let({}, T::Hash[Symbol, Class])
32
35
  @paths = T.let([
33
36
  {http_method: :get, operation: :get, ids: [], path: "application_charges.json"},
@@ -39,6 +42,8 @@ module ShopifyAPI
39
42
  attr_reader :confirmation_url
40
43
  sig { returns(T.nilable(String)) }
41
44
  attr_reader :created_at
45
+ sig { returns(T.nilable(Currency)) }
46
+ attr_reader :currency
42
47
  sig { returns(T.nilable(Integer)) }
43
48
  attr_reader :id
44
49
  sig { returns(T.nilable(String)) }
@@ -17,12 +17,15 @@ module ShopifyAPI
17
17
  super(session: session)
18
18
 
19
19
  @amount = T.let(nil, T.nilable(Integer))
20
+ @currency = T.let(nil, T.nilable(Currency))
20
21
  @description = T.let(nil, T.nilable(String))
21
22
  @id = T.let(nil, T.nilable(Integer))
22
23
  @test = T.let(nil, T.nilable(T::Boolean))
23
24
  end
24
25
 
25
- @has_one = T.let({}, T::Hash[Symbol, Class])
26
+ @has_one = T.let({
27
+ currency: Currency
28
+ }, T::Hash[Symbol, Class])
26
29
  @has_many = T.let({}, T::Hash[Symbol, Class])
27
30
  @paths = T.let([
28
31
  {http_method: :get, operation: :get, ids: [], path: "application_credits.json"},
@@ -32,6 +35,8 @@ module ShopifyAPI
32
35
 
33
36
  sig { returns(T.nilable(Integer)) }
34
37
  attr_reader :amount
38
+ sig { returns(T.nilable(Currency)) }
39
+ attr_reader :currency
35
40
  sig { returns(T.nilable(String)) }
36
41
  attr_reader :description
37
42
  sig { returns(T.nilable(Integer)) }
@@ -17,7 +17,7 @@ module ShopifyAPI
17
17
  super(session: session)
18
18
 
19
19
  @api_client_id = T.let(nil, T.nilable(Integer))
20
- @balance = T.let(nil, T.nilable(Float))
20
+ @balance = T.let(nil, T.nilable(String))
21
21
  @code = T.let(nil, T.nilable(String))
22
22
  @created_at = T.let(nil, T.nilable(String))
23
23
  @currency = T.let(nil, T.nilable(String))
@@ -25,7 +25,7 @@ module ShopifyAPI
25
25
  @disabled_at = T.let(nil, T.nilable(String))
26
26
  @expires_on = T.let(nil, T.nilable(String))
27
27
  @id = T.let(nil, T.nilable(Integer))
28
- @initial_value = T.let(nil, T.nilable(Float))
28
+ @initial_value = T.let(nil, T.nilable(String))
29
29
  @last_characters = T.let(nil, T.nilable(String))
30
30
  @line_item_id = T.let(nil, T.nilable(Integer))
31
31
  @note = T.let(nil, T.nilable(String))
@@ -49,7 +49,7 @@ module ShopifyAPI
49
49
 
50
50
  sig { returns(T.nilable(Integer)) }
51
51
  attr_reader :api_client_id
52
- sig { returns(T.nilable(Float)) }
52
+ sig { returns(T.nilable(String)) }
53
53
  attr_reader :balance
54
54
  sig { returns(T.nilable(String)) }
55
55
  attr_reader :code
@@ -65,7 +65,7 @@ module ShopifyAPI
65
65
  attr_reader :expires_on
66
66
  sig { returns(T.nilable(Integer)) }
67
67
  attr_reader :id
68
- sig { returns(T.nilable(Float)) }
68
+ sig { returns(T.nilable(String)) }
69
69
  attr_reader :initial_value
70
70
  sig { returns(T.nilable(String)) }
71
71
  attr_reader :last_characters