shopify_api 12.2.1 → 12.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/ISSUE_TEMPLATE/BUG_REPORT.md +40 -0
- data/.github/ISSUE_TEMPLATE/ENHANCEMENT.md +9 -0
- data/.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md +9 -0
- data/.github/workflows/build.yml +0 -3
- data/.github/workflows/stale.yml +1 -0
- data/CHANGELOG.md +13 -0
- data/Gemfile.lock +17 -17
- data/README.md +9 -10
- data/docs/getting_started.md +1 -1
- data/docs/usage/oauth.md +3 -4
- data/lib/shopify_api/admin_versions.rb +2 -1
- data/lib/shopify_api/auth/oauth.rb +1 -4
- data/lib/shopify_api/clients/http_client.rb +3 -3
- data/lib/shopify_api/context.rb +38 -8
- data/lib/shopify_api/errors/feature_deprecated_error.rb +9 -0
- data/lib/shopify_api/errors/http_response_error.rb +7 -3
- data/lib/shopify_api/errors/log_level_not_found_error.rb +9 -0
- data/lib/shopify_api/logger.rb +82 -0
- data/lib/shopify_api/rest/base.rb +11 -4
- data/lib/shopify_api/rest/resources/2022_01/assigned_fulfillment_order.rb +7 -0
- data/lib/shopify_api/rest/resources/2022_01/customer.rb +9 -1
- data/lib/shopify_api/rest/resources/2022_01/fulfillment.rb +5 -1
- data/lib/shopify_api/rest/resources/2022_01/fulfillment_order.rb +3 -3
- data/lib/shopify_api/rest/resources/2022_04/assigned_fulfillment_order.rb +7 -0
- data/lib/shopify_api/rest/resources/2022_04/customer.rb +9 -1
- data/lib/shopify_api/rest/resources/2022_04/fulfillment.rb +5 -1
- data/lib/shopify_api/rest/resources/2022_04/fulfillment_order.rb +3 -3
- data/lib/shopify_api/rest/resources/2022_04/metafield.rb +5 -3
- data/lib/shopify_api/rest/resources/2022_07/assigned_fulfillment_order.rb +7 -0
- data/lib/shopify_api/rest/resources/2022_07/customer.rb +9 -1
- data/lib/shopify_api/rest/resources/2022_07/fulfillment.rb +5 -1
- data/lib/shopify_api/rest/resources/2022_07/fulfillment_order.rb +3 -3
- data/lib/shopify_api/rest/resources/2022_07/metafield.rb +5 -3
- data/lib/shopify_api/rest/resources/2022_10/assigned_fulfillment_order.rb +7 -0
- data/lib/shopify_api/rest/resources/2022_10/customer.rb +9 -1
- data/lib/shopify_api/rest/resources/2022_10/fulfillment.rb +5 -1
- data/lib/shopify_api/rest/resources/2022_10/fulfillment_order.rb +3 -3
- data/lib/shopify_api/rest/resources/2022_10/metafield.rb +5 -3
- data/lib/shopify_api/rest/resources/2023_01/abandoned_checkout.rb +190 -0
- data/lib/shopify_api/rest/resources/2023_01/access_scope.rb +58 -0
- data/lib/shopify_api/rest/resources/2023_01/apple_pay_certificate.rb +105 -0
- data/lib/shopify_api/rest/resources/2023_01/application_charge.rb +104 -0
- data/lib/shopify_api/rest/resources/2023_01/application_credit.rb +87 -0
- data/lib/shopify_api/rest/resources/2023_01/article.rb +265 -0
- data/lib/shopify_api/rest/resources/2023_01/asset.rb +118 -0
- data/lib/shopify_api/rest/resources/2023_01/assigned_fulfillment_order.rb +86 -0
- data/lib/shopify_api/rest/resources/2023_01/balance.rb +50 -0
- data/lib/shopify_api/rest/resources/2023_01/blog.rb +162 -0
- data/lib/shopify_api/rest/resources/2023_01/cancellation_request.rb +83 -0
- data/lib/shopify_api/rest/resources/2023_01/carrier_service.rb +113 -0
- data/lib/shopify_api/rest/resources/2023_01/checkout.rb +209 -0
- data/lib/shopify_api/rest/resources/2023_01/collect.rb +142 -0
- data/lib/shopify_api/rest/resources/2023_01/collection.rb +110 -0
- data/lib/shopify_api/rest/resources/2023_01/collection_listing.rb +155 -0
- data/lib/shopify_api/rest/resources/2023_01/comment.rb +283 -0
- data/lib/shopify_api/rest/resources/2023_01/country.rb +137 -0
- data/lib/shopify_api/rest/resources/2023_01/currency.rb +57 -0
- data/lib/shopify_api/rest/resources/2023_01/custom_collection.rb +187 -0
- data/lib/shopify_api/rest/resources/2023_01/customer.rb +329 -0
- data/lib/shopify_api/rest/resources/2023_01/customer_address.rb +201 -0
- data/lib/shopify_api/rest/resources/2023_01/customer_saved_search.rb +169 -0
- data/lib/shopify_api/rest/resources/2023_01/deprecated_api_call.rb +57 -0
- data/lib/shopify_api/rest/resources/2023_01/discount_code.rb +219 -0
- data/lib/shopify_api/rest/resources/2023_01/dispute.rb +111 -0
- data/lib/shopify_api/rest/resources/2023_01/draft_order.rb +275 -0
- data/lib/shopify_api/rest/resources/2023_01/event.rb +148 -0
- data/lib/shopify_api/rest/resources/2023_01/fulfillment.rb +225 -0
- data/lib/shopify_api/rest/resources/2023_01/fulfillment_event.rb +166 -0
- data/lib/shopify_api/rest/resources/2023_01/fulfillment_order.rb +316 -0
- data/lib/shopify_api/rest/resources/2023_01/fulfillment_request.rb +87 -0
- data/lib/shopify_api/rest/resources/2023_01/fulfillment_service.rb +130 -0
- data/lib/shopify_api/rest/resources/2023_01/gift_card.rb +215 -0
- data/lib/shopify_api/rest/resources/2023_01/gift_card_adjustment.rb +118 -0
- data/lib/shopify_api/rest/resources/2023_01/image.rb +157 -0
- data/lib/shopify_api/rest/resources/2023_01/inventory_item.rb +108 -0
- data/lib/shopify_api/rest/resources/2023_01/inventory_level.rb +179 -0
- data/lib/shopify_api/rest/resources/2023_01/location.rb +167 -0
- data/lib/shopify_api/rest/resources/2023_01/locations_for_move.rb +56 -0
- data/lib/shopify_api/rest/resources/2023_01/marketing_event.rb +209 -0
- data/lib/shopify_api/rest/resources/2023_01/metafield.rb +344 -0
- data/lib/shopify_api/rest/resources/2023_01/mobile_platform_application.rb +110 -0
- data/lib/shopify_api/rest/resources/2023_01/order.rb +479 -0
- data/lib/shopify_api/rest/resources/2023_01/order_risk.rb +135 -0
- data/lib/shopify_api/rest/resources/2023_01/page.rb +194 -0
- data/lib/shopify_api/rest/resources/2023_01/payment.rb +140 -0
- data/lib/shopify_api/rest/resources/2023_01/payment_gateway.rb +143 -0
- data/lib/shopify_api/rest/resources/2023_01/payment_transaction.rb +107 -0
- data/lib/shopify_api/rest/resources/2023_01/payout.rb +97 -0
- data/lib/shopify_api/rest/resources/2023_01/policy.rb +69 -0
- data/lib/shopify_api/rest/resources/2023_01/price_rule.rb +223 -0
- data/lib/shopify_api/rest/resources/2023_01/product.rb +223 -0
- data/lib/shopify_api/rest/resources/2023_01/product_listing.rb +196 -0
- data/lib/shopify_api/rest/resources/2023_01/product_resource_feedback.rb +88 -0
- data/lib/shopify_api/rest/resources/2023_01/province.rb +132 -0
- data/lib/shopify_api/rest/resources/2023_01/recurring_application_charge.rb +167 -0
- data/lib/shopify_api/rest/resources/2023_01/redirect.rb +139 -0
- data/lib/shopify_api/rest/resources/2023_01/refund.rb +151 -0
- data/lib/shopify_api/rest/resources/2023_01/report.rb +121 -0
- data/lib/shopify_api/rest/resources/2023_01/resource_feedback.rb +73 -0
- data/lib/shopify_api/rest/resources/2023_01/script_tag.rb +155 -0
- data/lib/shopify_api/rest/resources/2023_01/shipping_zone.rb +83 -0
- data/lib/shopify_api/rest/resources/2023_01/shop.rb +221 -0
- data/lib/shopify_api/rest/resources/2023_01/smart_collection.rb +216 -0
- data/lib/shopify_api/rest/resources/2023_01/storefront_access_token.rb +87 -0
- data/lib/shopify_api/rest/resources/2023_01/tender_transaction.rb +93 -0
- data/lib/shopify_api/rest/resources/2023_01/theme.rb +120 -0
- data/lib/shopify_api/rest/resources/2023_01/transaction.rb +181 -0
- data/lib/shopify_api/rest/resources/2023_01/usage_charge.rb +97 -0
- data/lib/shopify_api/rest/resources/2023_01/user.rb +138 -0
- data/lib/shopify_api/rest/resources/2023_01/variant.rb +212 -0
- data/lib/shopify_api/rest/resources/2023_01/webhook.rb +168 -0
- data/lib/shopify_api/utils/session_utils.rb +38 -21
- data/lib/shopify_api/version.rb +1 -1
- data/shopify_api.gemspec +2 -2
- metadata +100 -16
- data/.github/ISSUE_TEMPLATE.md +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f87e892122968b0fc410c734d089ec03952c3b5bbf2793fcca078730ac280233
|
4
|
+
data.tar.gz: 928a01df0d1bc4312fee18e768d84c3585e1d72b39871e63b473080ee35943ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd43ee271006e1ca390d151c002ad9a65439ad2cbe2a9350bd20e2756797dd38697eaf1c3437f243d3d478fd55d116eebb991be148913d2b0c48293fcd572496
|
7
|
+
data.tar.gz: 295e7ec37443a12589fe3bd2a8edd18fdba3cc76016d1fa829a6334378547a017f326f798f318eb833da33f75361921553843cb1207139edf33e426636ef2c6c
|
@@ -0,0 +1,40 @@
|
|
1
|
+
---
|
2
|
+
name: "🐛 Bug Report"
|
3
|
+
about: Something isn't working
|
4
|
+
labels: "Type: Bug 🐛"
|
5
|
+
---
|
6
|
+
|
7
|
+
# Issue summary
|
8
|
+
|
9
|
+
<!--
|
10
|
+
|
11
|
+
Write a short description of the issue here. Please provide any details or logs that
|
12
|
+
can help us debug it.
|
13
|
+
|
14
|
+
Increase the logs as described in the README by setting log_level to :debug, and paste the relevant portion here.
|
15
|
+
|
16
|
+
Learn more: https://github.com/Shopify/shopify-api-ruby#setup-shopify-context
|
17
|
+
|
18
|
+
-->
|
19
|
+
|
20
|
+
- `shopify_api` version:
|
21
|
+
- Ruby version:
|
22
|
+
- Operating system:
|
23
|
+
|
24
|
+
```
|
25
|
+
// Paste any relevant logs here
|
26
|
+
```
|
27
|
+
|
28
|
+
## Expected behavior
|
29
|
+
|
30
|
+
<!-- What do you think should happen? -->
|
31
|
+
|
32
|
+
## Actual behavior
|
33
|
+
|
34
|
+
<!-- What actually happens? -->
|
35
|
+
|
36
|
+
## Steps to reproduce the problem
|
37
|
+
|
38
|
+
1.
|
39
|
+
1.
|
40
|
+
1.
|
data/.github/workflows/build.yml
CHANGED
data/.github/workflows/stale.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -4,7 +4,20 @@ Note: For changes to the API, see https://shopify.dev/changelog?filter=api
|
|
4
4
|
|
5
5
|
## Unreleased
|
6
6
|
|
7
|
+
## Version 12.4.0
|
8
|
+
|
9
|
+
- [#1092](https://github.com/Shopify/shopify-api-ruby/pull/1092) Add support for 2023-01 API version.
|
10
|
+
- [#1081](https://github.com/Shopify/shopify-api-ruby/pull/1081) Fixed an error when parsing the JSON response body for the AssignedFulfillmentOrder resource.
|
11
|
+
|
12
|
+
## Version 12.3.0
|
13
|
+
|
14
|
+
- [#1040](https://github.com/Shopify/shopify-api-ruby/pull/1040) `ShopifyAPI::Clients::HttpResponse` as argument for `ShopifyAPI::Errors::HttpResponseError`
|
15
|
+
- [#1055](https://github.com/Shopify/shopify-api-ruby/pull/1055) Makes session_storage optional. Configuring the API with session_storage is now deprecated. Session persistence is handled by the [shopify_app gem](https://github.com/Shopify/shopify_app) if using Rails.
|
16
|
+
- [#1063](https://github.com/Shopify/shopify-api-ruby/pull/1063) Fix ActiveSupport inflector dependency
|
17
|
+
- [#1069](https://github.com/Shopify/shopify-api-ruby/pull/1069) Adds a custom Logger to help write uniform logs across the api and the [shopify_app gem](https://github.com/Shopify/shopify_app)
|
18
|
+
|
7
19
|
## Version 12.2.1
|
20
|
+
|
8
21
|
- [#1045](https://github.com/Shopify/shopify-api-ruby/pull/1045) Fixes bug with host/host_name requirement.
|
9
22
|
|
10
23
|
## Version 12.2.0
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
shopify_api (12.
|
4
|
+
shopify_api (12.4.0)
|
5
|
+
activesupport
|
5
6
|
concurrent-ruby
|
6
7
|
hash_diff
|
7
8
|
httparty
|
@@ -10,12 +11,12 @@ PATH
|
|
10
11
|
openssl
|
11
12
|
securerandom
|
12
13
|
sorbet-runtime
|
13
|
-
zeitwerk (~> 2.5)
|
14
|
+
zeitwerk (~> 2.5, < 2.6.5)
|
14
15
|
|
15
16
|
GEM
|
16
17
|
remote: https://rubygems.org/
|
17
18
|
specs:
|
18
|
-
activesupport (7.0.
|
19
|
+
activesupport (7.0.4)
|
19
20
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
20
21
|
i18n (>= 1.6, < 2)
|
21
22
|
minitest (>= 5.1)
|
@@ -25,31 +26,29 @@ GEM
|
|
25
26
|
ast (2.4.2)
|
26
27
|
byebug (11.1.3)
|
27
28
|
coderay (1.1.3)
|
28
|
-
concurrent-ruby (1.1.
|
29
|
+
concurrent-ruby (1.1.10)
|
29
30
|
crack (0.4.5)
|
30
31
|
rexml
|
31
32
|
diff-lcs (1.5.0)
|
32
33
|
fakefs (1.4.1)
|
33
34
|
hash_diff (1.1.1)
|
34
35
|
hashdiff (1.0.1)
|
35
|
-
httparty (0.
|
36
|
-
|
36
|
+
httparty (0.21.0)
|
37
|
+
mini_mime (>= 1.0.0)
|
37
38
|
multi_xml (>= 0.5.2)
|
38
|
-
i18n (1.
|
39
|
+
i18n (1.12.0)
|
39
40
|
concurrent-ruby (~> 1.0)
|
40
41
|
json (2.6.2)
|
41
|
-
jwt (2.
|
42
|
+
jwt (2.6.0)
|
42
43
|
language_server-protocol (3.17.0.1)
|
43
44
|
method_source (1.0.0)
|
44
|
-
|
45
|
-
mime-types-data (~> 3.2015)
|
46
|
-
mime-types-data (3.2022.0105)
|
45
|
+
mini_mime (1.1.2)
|
47
46
|
minitest (5.15.0)
|
48
47
|
mocha (1.13.0)
|
49
48
|
multi_xml (0.6.0)
|
50
49
|
netrc (0.11.0)
|
51
|
-
oj (3.13.
|
52
|
-
openssl (3.0
|
50
|
+
oj (3.13.23)
|
51
|
+
openssl (3.1.0)
|
53
52
|
parallel (1.22.1)
|
54
53
|
parser (3.1.2.1)
|
55
54
|
ast (~> 2.4.1)
|
@@ -91,11 +90,12 @@ GEM
|
|
91
90
|
sorbet-runtime
|
92
91
|
syntax_tree (>= 3.4)
|
93
92
|
ruby-progressbar (1.11.0)
|
94
|
-
securerandom (0.2.
|
93
|
+
securerandom (0.2.2)
|
95
94
|
sorbet (0.5.10438)
|
96
95
|
sorbet-static (= 0.5.10438)
|
97
96
|
sorbet-runtime (0.5.10438)
|
98
97
|
sorbet-static (0.5.10438-universal-darwin-21)
|
98
|
+
sorbet-static (0.5.10438-universal-darwin-22)
|
99
99
|
sorbet-static (0.5.10438-x86_64-linux)
|
100
100
|
sorbet-static-and-runtime (0.5.10438)
|
101
101
|
sorbet (= 0.5.10438)
|
@@ -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.
|
120
|
+
tzinfo (2.0.5)
|
121
121
|
concurrent-ruby (~> 1.0)
|
122
122
|
unicode-display_width (2.3.0)
|
123
123
|
unparser (0.6.5)
|
@@ -133,14 +133,14 @@ GEM
|
|
133
133
|
yard-sorbet (0.7.0)
|
134
134
|
sorbet-runtime (>= 0.5)
|
135
135
|
yard (>= 0.9)
|
136
|
-
zeitwerk (2.6.
|
136
|
+
zeitwerk (2.6.4)
|
137
137
|
|
138
138
|
PLATFORMS
|
139
139
|
arm64-darwin-21
|
140
|
+
universal-darwin-22
|
140
141
|
x86_64-linux
|
141
142
|
|
142
143
|
DEPENDENCIES
|
143
|
-
activesupport
|
144
144
|
fakefs
|
145
145
|
minitest
|
146
146
|
mocha
|
data/README.md
CHANGED
@@ -23,7 +23,6 @@ To follow these usage guides, you will need to:
|
|
23
23
|
|
24
24
|
- have a working knowledge of ruby and a web framework such as Rails or Sinatra
|
25
25
|
- have a Shopify Partner account and development store
|
26
|
-
- _OR_ have a test store where you can create a private app
|
27
26
|
- have an app already set up in your test store or partner account
|
28
27
|
- add the URL and the appropriate redirect for your OAuth callback route to your app settings
|
29
28
|
|
@@ -55,8 +54,8 @@ ShopifyAPI::Context.setup(
|
|
55
54
|
scope: "read_orders,read_products,etc",
|
56
55
|
session_storage: ShopifyAPI::Auth::FileSessionStorage.new, # See more details below
|
57
56
|
is_embedded: true, # Set to true if you are building an embedded app
|
58
|
-
is_private: false, # Set to true if you are building a private app
|
59
57
|
api_version: "2022-01" # The version of the API you would like to use
|
58
|
+
is_private: false, # Set to true if you have an existing private app
|
60
59
|
)
|
61
60
|
```
|
62
61
|
|
@@ -68,7 +67,7 @@ Session information would is typically stored in cookies on the browser. However
|
|
68
67
|
|
69
68
|
### Performing OAuth
|
70
69
|
|
71
|
-
|
70
|
+
You need to go through OAuth as described [here](https://shopify.dev/apps/auth/oauth) to create sessions for shops using your app.
|
72
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.
|
73
72
|
|
74
73
|
### Register Webhooks and a Webhook Handler
|
@@ -83,7 +82,7 @@ Once your app can perform OAuth, it can now make authenticated Shopify API calls
|
|
83
82
|
|
84
83
|
### Breaking change notice for version 10.0.0
|
85
84
|
|
86
|
-
We've rewritten this library for v10, so that it provides all essential features for a Shopify app without
|
85
|
+
We've rewritten this library for v10, so that it provides all essential features for a Shopify app without depending on the [Active Resource](https://github.com/rails/activeresource) or [graphql-client](https://github.com/github/graphql-client) libraries.
|
87
86
|
|
88
87
|
Here are the main features it provides:
|
89
88
|
|
@@ -107,12 +106,12 @@ With this, a lot changed in how apps access the library. Here are the updates yo
|
|
107
106
|
|
108
107
|
Please see below a (non-exhaustive) list of common replacements to guide you in your updates, using the `Order` resource as an example.
|
109
108
|
|
110
|
-
| Before
|
111
|
-
| ---
|
112
|
-
| `Order.find(:all, params: {param1: value1})`
|
113
|
-
| `Order.find(<id>)`
|
114
|
-
| `order = Order.new(<id>)`<br/>`order.post(:close)` | `order = Order.new
|
115
|
-
| `order = Order.new(<id>)`<br/>`order.delete`
|
109
|
+
| Before | After |
|
110
|
+
| --- | --- |
|
111
|
+
| `Order.find(:all, params: {param1: value1})` | `Order.all(param1: value1)` |
|
112
|
+
| `Order.find(<id>)` | `Order.find(id: <id>)` |
|
113
|
+
| `order = Order.new(<id>)`<br/>`order.post(:close)` | `order = Order.new`<br/>`order.close` |
|
114
|
+
| `order = Order.new(<id>)`<br/>`order.delete` | `Order.delete(id: <id>)` |
|
116
115
|
|
117
116
|
## Breaking changes for older versions
|
118
117
|
|
data/docs/getting_started.md
CHANGED
@@ -5,7 +5,7 @@ This page will outline everything you need to know and the steps you need to fol
|
|
5
5
|
## Requirements
|
6
6
|
|
7
7
|
- A working knowledge of ruby and a web framework such as Rails or Sinatra
|
8
|
-
- A
|
8
|
+
- A custom app already set up in your test store or partner account
|
9
9
|
- We recommend `ngrok` to tunnel traffic to your localhost for testing
|
10
10
|
|
11
11
|
## Installation
|
data/docs/usage/oauth.md
CHANGED
@@ -3,8 +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
|
-
|
7
|
-
**Note:** You do not need to go through the OAuth process if you are creating a private app. In this case you can simply set your `<key+password>` as the `api_secret_key` in `ShopifyAPI::Context.setup`. 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/apps/auth#types-of-authentication) page.
|
8
7
|
|
9
8
|
## Add a route to start OAuth
|
10
9
|
|
@@ -53,7 +52,7 @@ def callback
|
|
53
52
|
cookies: cookies.to_h,
|
54
53
|
auth_query: ShopifyAPI::Auth::Oauth::AuthQuery.new(request.parameters.symbolize_keys.except(:controller, :action))
|
55
54
|
)
|
56
|
-
|
55
|
+
|
57
56
|
cookies[auth_result[:cookie].name] = {
|
58
57
|
expires: auth_result[:cookie].expires,
|
59
58
|
secure: true,
|
@@ -66,7 +65,7 @@ def callback
|
|
66
65
|
head 307
|
67
66
|
response.set_header("Location", "<some-redirect-url>")
|
68
67
|
rescue => e
|
69
|
-
puts(e.message)
|
68
|
+
puts(e.message)
|
70
69
|
head 500
|
71
70
|
end
|
72
71
|
end
|
@@ -5,13 +5,14 @@ module ShopifyAPI
|
|
5
5
|
module AdminVersions
|
6
6
|
SUPPORTED_ADMIN_VERSIONS = T.let([
|
7
7
|
"unstable",
|
8
|
+
"2023-01",
|
8
9
|
"2022-10",
|
9
10
|
"2022-07",
|
10
11
|
"2022-04",
|
11
12
|
"2022-01",
|
12
13
|
], T::Array[String])
|
13
14
|
|
14
|
-
LATEST_SUPPORTED_ADMIN_VERSION = T.let("
|
15
|
+
LATEST_SUPPORTED_ADMIN_VERSION = T.let("2023-01", String)
|
15
16
|
end
|
16
17
|
|
17
18
|
SUPPORTED_ADMIN_VERSIONS = ShopifyAPI::AdminVersions::SUPPORTED_ADMIN_VERSIONS
|
@@ -93,10 +93,7 @@ module ShopifyAPI
|
|
93
93
|
)
|
94
94
|
end
|
95
95
|
|
96
|
-
|
97
|
-
raise Errors::SessionStorageError,
|
98
|
-
"Session could not be saved. Please check your session storage implementation."
|
99
|
-
end
|
96
|
+
Context.session_storage&.store_session(session)
|
100
97
|
|
101
98
|
{ session: session, cookie: cookie }
|
102
99
|
end
|
@@ -69,13 +69,13 @@ module ShopifyAPI
|
|
69
69
|
error_message = error_messages.join("\n")
|
70
70
|
|
71
71
|
unless [429, 500].include?(response.code)
|
72
|
-
raise ShopifyAPI::Errors::HttpResponseError.new(
|
72
|
+
raise ShopifyAPI::Errors::HttpResponseError.new(response: response), error_message
|
73
73
|
end
|
74
74
|
|
75
75
|
if tries == request.tries
|
76
|
-
raise ShopifyAPI::Errors::HttpResponseError.new(
|
76
|
+
raise ShopifyAPI::Errors::HttpResponseError.new(response: response), error_message if request.tries == 1
|
77
77
|
|
78
|
-
raise ShopifyAPI::Errors::MaxHttpRetriesExceededError.new(
|
78
|
+
raise ShopifyAPI::Errors::MaxHttpRetriesExceededError.new(response: response),
|
79
79
|
"Exceeded maximum retry count of #{request.tries}. Last message: #{error_message}"
|
80
80
|
end
|
81
81
|
|
data/lib/shopify_api/context.rb
CHANGED
@@ -9,13 +9,14 @@ module ShopifyAPI
|
|
9
9
|
@api_secret_key = T.let("", String)
|
10
10
|
@api_version = T.let(LATEST_SUPPORTED_ADMIN_VERSION, String)
|
11
11
|
@scope = T.let(Auth::AuthScopes.new, Auth::AuthScopes)
|
12
|
-
@session_storage = T.let(ShopifyAPI::Auth::FileSessionStorage.new, ShopifyAPI::Auth::SessionStorage)
|
13
12
|
@is_private = T.let(false, T::Boolean)
|
14
13
|
@private_shop = T.let(nil, T.nilable(String))
|
15
14
|
@is_embedded = T.let(true, T::Boolean)
|
16
|
-
@logger = T.let(Logger.new($stdout), Logger)
|
15
|
+
@logger = T.let(::Logger.new($stdout), ::Logger)
|
16
|
+
@log_level = T.let(:info, Symbol)
|
17
17
|
@notified_missing_resources_folder = T.let({}, T::Hash[String, T::Boolean])
|
18
18
|
@active_session = T.let(Concurrent::ThreadLocalVar.new { nil }, Concurrent::ThreadLocalVar)
|
19
|
+
@session_storage = T.let(nil, T.nilable(ShopifyAPI::Auth::SessionStorage))
|
19
20
|
@user_agent_prefix = T.let(nil, T.nilable(String))
|
20
21
|
@old_api_secret_key = T.let(nil, T.nilable(String))
|
21
22
|
|
@@ -32,8 +33,9 @@ module ShopifyAPI
|
|
32
33
|
scope: T.any(T::Array[String], String),
|
33
34
|
is_private: T::Boolean,
|
34
35
|
is_embedded: T::Boolean,
|
35
|
-
|
36
|
-
logger: Logger,
|
36
|
+
log_level: T.any(String, Symbol),
|
37
|
+
logger: ::Logger,
|
38
|
+
session_storage: T.nilable(ShopifyAPI::Auth::SessionStorage),
|
37
39
|
host_name: T.nilable(String),
|
38
40
|
host: T.nilable(String),
|
39
41
|
private_shop: T.nilable(String),
|
@@ -48,8 +50,9 @@ module ShopifyAPI
|
|
48
50
|
scope:,
|
49
51
|
is_private:,
|
50
52
|
is_embedded:,
|
51
|
-
|
52
|
-
logger: Logger.new($stdout),
|
53
|
+
log_level: :info,
|
54
|
+
logger: ::Logger.new($stdout),
|
55
|
+
session_storage: nil,
|
53
56
|
host_name: nil,
|
54
57
|
host: ENV["HOST"] || "https://#{host_name}",
|
55
58
|
private_shop: nil,
|
@@ -73,6 +76,18 @@ module ShopifyAPI
|
|
73
76
|
@private_shop = private_shop
|
74
77
|
@user_agent_prefix = user_agent_prefix
|
75
78
|
@old_api_secret_key = old_api_secret_key
|
79
|
+
@log_level = if valid_log_level?(log_level)
|
80
|
+
log_level.to_sym
|
81
|
+
else
|
82
|
+
:info
|
83
|
+
end
|
84
|
+
|
85
|
+
if @session_storage
|
86
|
+
::ShopifyAPI::Logger.deprecated("The use of SessionStorage in the API library has been deprecated. " \
|
87
|
+
"The ShopifyAPI will no longer have responsibility for session persistence. " \
|
88
|
+
"Upgrading to `shopify_app` 21.3 will allow you to remove session_storage" \
|
89
|
+
" from the API library Context configuration.", "13.0.0")
|
90
|
+
end
|
76
91
|
|
77
92
|
load_rest_resources(api_version: api_version)
|
78
93
|
end
|
@@ -111,12 +126,15 @@ module ShopifyAPI
|
|
111
126
|
sig { returns(Auth::AuthScopes) }
|
112
127
|
attr_reader :scope
|
113
128
|
|
114
|
-
sig { returns(ShopifyAPI::Auth::SessionStorage) }
|
129
|
+
sig { returns(T.nilable(ShopifyAPI::Auth::SessionStorage)) }
|
115
130
|
attr_reader :session_storage
|
116
131
|
|
117
|
-
sig { returns(Logger) }
|
132
|
+
sig { returns(::Logger) }
|
118
133
|
attr_reader :logger
|
119
134
|
|
135
|
+
sig { returns(Symbol) }
|
136
|
+
attr_reader :log_level
|
137
|
+
|
120
138
|
sig { returns(T::Boolean) }
|
121
139
|
def private?
|
122
140
|
@is_private
|
@@ -161,6 +179,18 @@ module ShopifyAPI
|
|
161
179
|
def host_name
|
162
180
|
T.must(URI(T.must(host)).host)
|
163
181
|
end
|
182
|
+
|
183
|
+
private
|
184
|
+
|
185
|
+
sig { params(log_level: T.any(Symbol, String)).returns(T::Boolean) }
|
186
|
+
def valid_log_level?(log_level)
|
187
|
+
return true if ::ShopifyAPI::Logger.levels.include?(log_level.to_sym)
|
188
|
+
|
189
|
+
ShopifyAPI::Logger.warn("#{log_level} is not a valid log_level. "\
|
190
|
+
"Valid options are #{::ShopifyAPI::Logger.levels.join(", ")}")
|
191
|
+
|
192
|
+
false
|
193
|
+
end
|
164
194
|
end
|
165
195
|
end
|
166
196
|
end
|
@@ -9,10 +9,14 @@ module ShopifyAPI
|
|
9
9
|
sig { returns(Integer) }
|
10
10
|
attr_reader :code
|
11
11
|
|
12
|
-
sig {
|
13
|
-
|
12
|
+
sig { returns(ShopifyAPI::Clients::HttpResponse) }
|
13
|
+
attr_reader :response
|
14
|
+
|
15
|
+
sig { params(response: ShopifyAPI::Clients::HttpResponse).void }
|
16
|
+
def initialize(response:)
|
14
17
|
super
|
15
|
-
@code = code
|
18
|
+
@code = T.let(response.code, Integer)
|
19
|
+
@response = response
|
16
20
|
end
|
17
21
|
end
|
18
22
|
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# typed: strict
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
module ShopifyAPI
|
5
|
+
class Logger
|
6
|
+
LOG_LEVELS = T.let({ debug: 0, info: 1, warn: 2, error: 3, off: 6 }, T::Hash[Symbol, Integer])
|
7
|
+
DEFAULT_LOG_LEVEL = :info
|
8
|
+
|
9
|
+
class << self
|
10
|
+
extend T::Sig
|
11
|
+
|
12
|
+
sig { params(message: String).void }
|
13
|
+
def debug(message)
|
14
|
+
send_to_logger(:debug, message)
|
15
|
+
end
|
16
|
+
|
17
|
+
sig { params(message: String).void }
|
18
|
+
def info(message)
|
19
|
+
send_to_logger(:info, message)
|
20
|
+
end
|
21
|
+
|
22
|
+
sig { params(message: String).void }
|
23
|
+
def warn(message)
|
24
|
+
send_to_logger(:warn, message)
|
25
|
+
end
|
26
|
+
|
27
|
+
sig { params(message: String).void }
|
28
|
+
def error(message)
|
29
|
+
send_to_logger(:error, message)
|
30
|
+
end
|
31
|
+
|
32
|
+
sig { params(message: String, version: String).void }
|
33
|
+
def deprecated(message, version)
|
34
|
+
return unless enabled_for_log_level?(:warn)
|
35
|
+
|
36
|
+
raise Errors::FeatureDeprecatedError unless valid_version(version)
|
37
|
+
|
38
|
+
send_to_logger(:warn, message)
|
39
|
+
end
|
40
|
+
|
41
|
+
sig { returns(T::Array[Symbol]) }
|
42
|
+
def levels
|
43
|
+
LOG_LEVELS.keys
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
sig { params(log_level: Symbol).returns(String) }
|
49
|
+
def context(log_level)
|
50
|
+
current_shop = ShopifyAPI::Context.active_session&.shop
|
51
|
+
|
52
|
+
if current_shop.nil?
|
53
|
+
"[ ShopifyAPI | #{log_level.to_s.upcase} ]"
|
54
|
+
else
|
55
|
+
"[ ShopifyAPI | #{log_level.to_s.upcase} | #{current_shop} ]"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
sig { params(log_level: Symbol, message: String).void }
|
60
|
+
def send_to_logger(log_level, message)
|
61
|
+
return unless enabled_for_log_level?(log_level)
|
62
|
+
|
63
|
+
full_message = "#{context(log_level)} #{message}"
|
64
|
+
|
65
|
+
ShopifyAPI::Context.logger.public_send(log_level, full_message)
|
66
|
+
end
|
67
|
+
|
68
|
+
sig { params(log_level: Symbol).returns(T::Boolean) }
|
69
|
+
def enabled_for_log_level?(log_level)
|
70
|
+
T.must(LOG_LEVELS[log_level]) >= T.must(LOG_LEVELS[ShopifyAPI::Context.log_level] ||
|
71
|
+
LOG_LEVELS[DEFAULT_LOG_LEVEL])
|
72
|
+
end
|
73
|
+
|
74
|
+
sig { params(version: String).returns(T::Boolean) }
|
75
|
+
def valid_version(version)
|
76
|
+
current_version = Gem::Version.create(ShopifyAPI::VERSION)
|
77
|
+
deprecate_version = Gem::Version.create(version)
|
78
|
+
current_version < deprecate_version
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -97,6 +97,11 @@ module ShopifyAPI
|
|
97
97
|
class_name.underscore
|
98
98
|
end
|
99
99
|
|
100
|
+
sig { returns(String) }
|
101
|
+
def json_response_body_name
|
102
|
+
class_name
|
103
|
+
end
|
104
|
+
|
100
105
|
sig { returns(T.nilable(String)) }
|
101
106
|
def prev_page_info
|
102
107
|
instance_variable_get(:"@prev_page_info").value
|
@@ -205,12 +210,14 @@ module ShopifyAPI
|
|
205
210
|
|
206
211
|
body = T.cast(response.body, T::Hash[String, T.untyped])
|
207
212
|
|
208
|
-
|
209
|
-
|
213
|
+
response_name = json_response_body_name
|
214
|
+
|
215
|
+
if body.key?(response_name.pluralize) || (body.key?(response_name) && body[response_name].is_a?(Array))
|
216
|
+
(body[response_name.pluralize] || body[response_name]).each do |entry|
|
210
217
|
objects << create_instance(data: entry, session: session)
|
211
218
|
end
|
212
|
-
elsif body.key?(
|
213
|
-
objects << create_instance(data: body[
|
219
|
+
elsif body.key?(response_name)
|
220
|
+
objects << create_instance(data: body[response_name], session: session)
|
214
221
|
end
|
215
222
|
|
216
223
|
objects
|
@@ -197,11 +197,19 @@ module ShopifyAPI
|
|
197
197
|
|
198
198
|
sig do
|
199
199
|
params(
|
200
|
+
created_at_min: T.untyped,
|
201
|
+
created_at_max: T.untyped,
|
202
|
+
updated_at_min: T.untyped,
|
203
|
+
updated_at_max: T.untyped,
|
200
204
|
session: Auth::Session,
|
201
205
|
kwargs: T.untyped
|
202
206
|
).returns(T.untyped)
|
203
207
|
end
|
204
208
|
def count(
|
209
|
+
created_at_min: nil,
|
210
|
+
created_at_max: nil,
|
211
|
+
updated_at_min: nil,
|
212
|
+
updated_at_max: nil,
|
205
213
|
session: ShopifyAPI::Context.active_session,
|
206
214
|
**kwargs
|
207
215
|
)
|
@@ -210,7 +218,7 @@ module ShopifyAPI
|
|
210
218
|
operation: :count,
|
211
219
|
session: session,
|
212
220
|
ids: {},
|
213
|
-
params: {}.merge(kwargs).compact,
|
221
|
+
params: {created_at_min: created_at_min, created_at_max: created_at_max, updated_at_min: updated_at_min, updated_at_max: updated_at_max}.merge(kwargs).compact,
|
214
222
|
body: {},
|
215
223
|
entity: nil,
|
216
224
|
)
|