shopify_api 12.4.0 → 13.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (178) 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/.rubocop.yml +3 -0
  8. data/CHANGELOG.md +18 -4
  9. data/CONTRIBUTING.md +2 -2
  10. data/Gemfile.lock +7 -7
  11. data/README.md +10 -10
  12. data/docs/getting_started.md +2 -2
  13. data/docs/usage/graphql.md +6 -0
  14. data/docs/usage/graphql_storefront.md +8 -2
  15. data/docs/usage/oauth.md +1 -1
  16. data/docs/usage/rest.md +9 -2
  17. data/docs/usage/webhooks.md +1 -1
  18. data/lib/shopify_api/admin_versions.rb +2 -1
  19. data/lib/shopify_api/auth/oauth.rb +0 -2
  20. data/lib/shopify_api/clients/graphql/admin.rb +3 -3
  21. data/lib/shopify_api/clients/graphql/client.rb +13 -3
  22. data/lib/shopify_api/clients/graphql/storefront.rb +3 -3
  23. data/lib/shopify_api/clients/http_client.rb +21 -10
  24. data/lib/shopify_api/clients/rest/admin.rb +14 -3
  25. data/lib/shopify_api/context.rb +4 -20
  26. data/lib/shopify_api/rest/base.rb +50 -14
  27. data/lib/shopify_api/rest/resources/2022_04/application_charge.rb +6 -1
  28. data/lib/shopify_api/rest/resources/2022_04/application_credit.rb +8 -3
  29. data/lib/shopify_api/rest/resources/2022_04/discount_code.rb +3 -0
  30. data/lib/shopify_api/rest/resources/2022_04/dispute.rb +2 -2
  31. data/lib/shopify_api/rest/resources/2022_04/draft_order.rb +2 -2
  32. data/lib/shopify_api/rest/resources/2022_04/event.rb +2 -2
  33. data/lib/shopify_api/rest/resources/2022_04/fulfillment.rb +6 -0
  34. data/lib/shopify_api/rest/resources/2022_04/gift_card.rb +10 -7
  35. data/lib/shopify_api/rest/resources/2022_04/metafield.rb +2 -2
  36. data/lib/shopify_api/rest/resources/2022_04/order.rb +2 -2
  37. data/lib/shopify_api/rest/resources/2022_04/order_risk.rb +9 -2
  38. data/lib/shopify_api/rest/resources/2022_04/recurring_application_charge.rb +6 -1
  39. data/lib/shopify_api/rest/resources/2022_04/shipping_zone.rb +8 -8
  40. data/lib/shopify_api/rest/resources/2022_04/shop.rb +2 -2
  41. data/lib/shopify_api/rest/resources/2022_04/theme.rb +3 -0
  42. data/lib/shopify_api/rest/resources/2022_04/usage_charge.rb +8 -3
  43. data/lib/shopify_api/rest/resources/2022_07/application_charge.rb +6 -1
  44. data/lib/shopify_api/rest/resources/2022_07/application_credit.rb +8 -3
  45. data/lib/shopify_api/rest/resources/2022_07/carrier_service.rb +3 -0
  46. data/lib/shopify_api/rest/resources/2022_07/discount_code.rb +3 -0
  47. data/lib/shopify_api/rest/resources/2022_07/dispute.rb +2 -2
  48. data/lib/shopify_api/rest/resources/2022_07/draft_order.rb +2 -2
  49. data/lib/shopify_api/rest/resources/2022_07/event.rb +2 -2
  50. data/lib/shopify_api/rest/resources/2022_07/fulfillment.rb +6 -0
  51. data/lib/shopify_api/rest/resources/2022_07/gift_card.rb +10 -7
  52. data/lib/shopify_api/rest/resources/2022_07/metafield.rb +2 -2
  53. data/lib/shopify_api/rest/resources/2022_07/order.rb +2 -2
  54. data/lib/shopify_api/rest/resources/2022_07/order_risk.rb +9 -2
  55. data/lib/shopify_api/rest/resources/2022_07/recurring_application_charge.rb +6 -1
  56. data/lib/shopify_api/rest/resources/2022_07/shipping_zone.rb +8 -8
  57. data/lib/shopify_api/rest/resources/2022_07/shop.rb +2 -2
  58. data/lib/shopify_api/rest/resources/2022_07/theme.rb +3 -0
  59. data/lib/shopify_api/rest/resources/2022_07/usage_charge.rb +8 -3
  60. data/lib/shopify_api/rest/resources/2022_10/application_charge.rb +6 -1
  61. data/lib/shopify_api/rest/resources/2022_10/application_credit.rb +8 -3
  62. data/lib/shopify_api/rest/resources/2022_10/carrier_service.rb +3 -0
  63. data/lib/shopify_api/rest/resources/2022_10/discount_code.rb +3 -0
  64. data/lib/shopify_api/rest/resources/2022_10/dispute.rb +2 -2
  65. data/lib/shopify_api/rest/resources/2022_10/draft_order.rb +2 -2
  66. data/lib/shopify_api/rest/resources/2022_10/event.rb +2 -2
  67. data/lib/shopify_api/rest/resources/2022_10/fulfillment.rb +6 -0
  68. data/lib/shopify_api/rest/resources/2022_10/gift_card.rb +10 -7
  69. data/lib/shopify_api/rest/resources/2022_10/metafield.rb +2 -2
  70. data/lib/shopify_api/rest/resources/2022_10/order.rb +2 -2
  71. data/lib/shopify_api/rest/resources/2022_10/order_risk.rb +9 -2
  72. data/lib/shopify_api/rest/resources/2022_10/recurring_application_charge.rb +6 -1
  73. data/lib/shopify_api/rest/resources/2022_10/shipping_zone.rb +8 -8
  74. data/lib/shopify_api/rest/resources/2022_10/shop.rb +2 -2
  75. data/lib/shopify_api/rest/resources/2022_10/theme.rb +3 -0
  76. data/lib/shopify_api/rest/resources/2022_10/usage_charge.rb +8 -3
  77. data/lib/shopify_api/rest/resources/2023_01/application_charge.rb +6 -1
  78. data/lib/shopify_api/rest/resources/2023_01/application_credit.rb +8 -3
  79. data/lib/shopify_api/rest/resources/2023_01/carrier_service.rb +3 -0
  80. data/lib/shopify_api/rest/resources/2023_01/discount_code.rb +3 -0
  81. data/lib/shopify_api/rest/resources/2023_01/dispute.rb +2 -2
  82. data/lib/shopify_api/rest/resources/2023_01/dispute_evidence.rb +117 -0
  83. data/lib/shopify_api/rest/resources/{2022_01/android_pay_key.rb → 2023_01/dispute_file_upload.rb} +29 -25
  84. data/lib/shopify_api/rest/resources/2023_01/draft_order.rb +2 -2
  85. data/lib/shopify_api/rest/resources/2023_01/event.rb +2 -2
  86. data/lib/shopify_api/rest/resources/2023_01/fulfillment.rb +6 -0
  87. data/lib/shopify_api/rest/resources/2023_01/gift_card.rb +10 -7
  88. data/lib/shopify_api/rest/resources/2023_01/metafield.rb +2 -2
  89. data/lib/shopify_api/rest/resources/2023_01/order.rb +2 -2
  90. data/lib/shopify_api/rest/resources/2023_01/order_risk.rb +9 -2
  91. data/lib/shopify_api/rest/resources/2023_01/recurring_application_charge.rb +6 -1
  92. data/lib/shopify_api/rest/resources/2023_01/shipping_zone.rb +8 -8
  93. data/lib/shopify_api/rest/resources/2023_01/shop.rb +2 -2
  94. data/lib/shopify_api/rest/resources/2023_01/theme.rb +3 -0
  95. data/lib/shopify_api/rest/resources/2023_01/usage_charge.rb +8 -3
  96. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/application_charge.rb +6 -1
  97. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/application_credit.rb +8 -3
  98. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/customer.rb +3 -0
  99. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/discount_code.rb +3 -0
  100. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/dispute.rb +2 -2
  101. data/lib/shopify_api/rest/resources/2023_04/dispute_evidence.rb +117 -0
  102. data/lib/shopify_api/rest/resources/2023_04/dispute_file_upload.rb +81 -0
  103. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/draft_order.rb +2 -2
  104. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/event.rb +2 -2
  105. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/fulfillment.rb +8 -49
  106. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/fulfillment_order.rb +39 -8
  107. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/fulfillment_service.rb +3 -3
  108. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/gift_card.rb +10 -7
  109. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/metafield.rb +8 -13
  110. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/order.rb +14 -2
  111. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/order_risk.rb +9 -2
  112. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/price_rule.rb +3 -3
  113. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/recurring_application_charge.rb +6 -1
  114. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/shipping_zone.rb +8 -8
  115. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/shop.rb +5 -2
  116. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/theme.rb +3 -0
  117. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/transaction.rb +3 -0
  118. data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/usage_charge.rb +8 -3
  119. data/lib/shopify_api/utils/graphql_proxy.rb +3 -6
  120. data/lib/shopify_api/utils/session_utils.rb +0 -84
  121. data/lib/shopify_api/version.rb +1 -1
  122. data/lib/shopify_api/webhooks/registry.rb +1 -1
  123. data/shopify_api.gemspec +1 -1
  124. metadata +85 -80
  125. data/lib/shopify_api/auth/file_session_storage.rb +0 -72
  126. data/lib/shopify_api/auth/session_storage.rb +0 -30
  127. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/abandoned_checkout.rb +0 -0
  128. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/access_scope.rb +0 -0
  129. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/apple_pay_certificate.rb +0 -0
  130. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/article.rb +0 -0
  131. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/asset.rb +0 -0
  132. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/assigned_fulfillment_order.rb +0 -0
  133. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/balance.rb +0 -0
  134. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/blog.rb +0 -0
  135. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/cancellation_request.rb +0 -0
  136. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/carrier_service.rb +0 -0
  137. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/checkout.rb +0 -0
  138. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/collect.rb +0 -0
  139. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/collection.rb +0 -0
  140. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/collection_listing.rb +0 -0
  141. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/comment.rb +0 -0
  142. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/country.rb +0 -0
  143. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/currency.rb +0 -0
  144. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/custom_collection.rb +0 -0
  145. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/customer_address.rb +0 -0
  146. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/customer_saved_search.rb +0 -0
  147. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/deprecated_api_call.rb +0 -0
  148. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/fulfillment_event.rb +0 -0
  149. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/fulfillment_request.rb +0 -0
  150. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/gift_card_adjustment.rb +0 -0
  151. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/image.rb +0 -0
  152. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/inventory_item.rb +0 -0
  153. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/inventory_level.rb +0 -0
  154. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/location.rb +0 -0
  155. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/locations_for_move.rb +0 -0
  156. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/marketing_event.rb +0 -0
  157. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/mobile_platform_application.rb +0 -0
  158. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/page.rb +0 -0
  159. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/payment.rb +0 -0
  160. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/payment_gateway.rb +0 -0
  161. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/payment_transaction.rb +0 -0
  162. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/payout.rb +0 -0
  163. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/policy.rb +0 -0
  164. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/product.rb +0 -0
  165. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/product_listing.rb +0 -0
  166. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/product_resource_feedback.rb +0 -0
  167. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/province.rb +0 -0
  168. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/redirect.rb +0 -0
  169. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/refund.rb +0 -0
  170. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/report.rb +0 -0
  171. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/resource_feedback.rb +0 -0
  172. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/script_tag.rb +0 -0
  173. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/smart_collection.rb +0 -0
  174. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/storefront_access_token.rb +0 -0
  175. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/tender_transaction.rb +0 -0
  176. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/user.rb +0 -0
  177. /data/lib/shopify_api/rest/resources/{2022_01 → 2023_04}/variant.rb +0 -0
  178. /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: d36c6512c91e12fdcc4d3f9ee1049241498e41b0406448d19cafb94d97d7c815
4
+ data.tar.gz: 9633547697ee1493db17837b28ea7e0b1e539d6d062e5066bd3f983fdaf4090f
5
5
  SHA512:
6
- metadata.gz: dd43ee271006e1ca390d151c002ad9a65439ad2cbe2a9350bd20e2756797dd38697eaf1c3437f243d3d478fd55d116eebb991be148913d2b0c48293fcd572496
7
- data.tar.gz: 295e7ec37443a12589fe3bd2a8edd18fdba3cc76016d1fa829a6334378547a017f326f798f318eb833da33f75361921553843cb1207139edf33e426636ef2c6c
6
+ metadata.gz: 8964e99218d49f9e0a9bd5e277ead941ad8252d59c59e97a2eba9234f7a7396d92a52628ac7268599f454c2c60cbb8f696d0501ea1e75c5c531b74d4708a28c0
7
+ data.tar.gz: 1d38649055c009278cabec33441525df0086a5fc078e2974da48d845d6f98014409d12068791cefa99c3ef5bc4a79f2012d60a514aeeba5db1a87e8ed1739070
@@ -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/.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,20 @@ 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
+
14
+ ## 12.5.0
15
+
16
+ - [#1113](https://github.com/Shopify/shopify-api-ruby/pull/1113) Handle JSON::ParserError when http response is HTML and raise ShopifyAPI::Errors::HttpResponseError
17
+ - [#1098](https://github.com/Shopify/shopify-api-ruby/pull/1098) Gracefully handle HTTP 204 repsonse bodies
18
+ - [#1104](https://github.com/Shopify/shopify-api-ruby/pull/1104) Allow api version overrides.
19
+ - [#1137](https://github.com/Shopify/shopify-api-ruby/pull/1137) Support for 2023_04 API version. Fix reported typing bugs.
20
+
7
21
  ## Version 12.4.0
8
22
 
9
23
  - [#1092](https://github.com/Shopify/shopify-api-ruby/pull/1092) Add support for 2023-01 API version.
@@ -129,13 +143,13 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
129
143
  ## Version 9.0.3
130
144
 
131
145
  - 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)
146
+ - [Product Variant REST API Reference](https://shopify.dev/docs/api/admin-rest/reference/resources/product-variant)
133
147
  - [Migrate your app to support multiple locations](https://shopify.dev/tutorials/migrate-your-app-to-support-multiple-locations)
134
148
  - [Manage product inventory with the Admin API](https://shopify.dev/tutorials/manage-product-inventory-with-admin-api)
135
149
  - 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)
150
+ - [Create](https://shopify.dev/docs/api/admin-rest/reference/resources/discountcode#batch_create-2020-01)
151
+ - [Show](https://shopify.dev/docs/api/admin-rest/reference/resources/discountcode#batch_show-2020-01)
152
+ - [List](https://shopify.dev/docs/api/admin-rest/reference/resources/discountcode#batch_discount_codes_index-2020-01)
139
153
  - 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
154
 
141
155
  ## 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 (13.0.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)
@@ -36,10 +36,10 @@ 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
- 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
@@ -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
 
@@ -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"]
@@ -58,15 +65,7 @@ module ShopifyAPI
58
65
 
59
66
  break if response.ok?
60
67
 
61
- error_messages = []
62
- error_messages << response.body["errors"] if response.body["errors"]
63
-
64
- if response.headers["x-request-id"]
65
- id = T.must(response.headers["x-request-id"])[0]
66
- error_messages << "If you report this error, please include this id: #{id}."
67
- end
68
-
69
- error_message = error_messages.join("\n")
68
+ error_message = serialized_error(response)
70
69
 
71
70
  unless [429, 500].include?(response.code)
72
71
  raise ShopifyAPI::Errors::HttpResponseError.new(response: response), error_message
@@ -95,6 +94,18 @@ module ShopifyAPI
95
94
  def request_url(request)
96
95
  "#{@base_uri_and_path}/#{request.path}"
97
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
98
109
  end
99
110
  end
100
111
  end
@@ -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