Skip to content

Commit a7b7ce0

Browse files
committed
Merge remote-tracking branch 'origin/main'
2 parents 12e933b + a3ae353 commit a7b7ce0

File tree

6 files changed

+22
-10
lines changed

6 files changed

+22
-10
lines changed

.pre-commit-config.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
# See https://pre-commit.com/hooks.html for more hooks
33
repos:
44
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: v3.4.0
5+
rev: v5.0.0
66
hooks:
77
- id: end-of-file-fixer
88
- id: trailing-whitespace
99
- repo: https://github.com/psf/black
10-
rev: 22.3.0
10+
rev: 24.10.0
1111
hooks:
1212
- id: black
1313
- repo: https://github.com/PyCQA/pylint
14-
rev: v2.15.8
14+
rev: v3.3.3
1515
hooks:
1616
- id: pylint

README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,11 @@ pip install --upgrade ShopifyAPI
8989
session = shopify.Session(shop_url, api_version, access_token)
9090
shopify.ShopifyResource.activate_session(session)
9191

92-
shop = shopify.Shop.current() # Get the current shop
93-
product = shopify.Product.find(179761209) # Get a specific product
92+
# Note: REST API examples will be deprecated in 2025
93+
shop = shopify.Shop.current() # Get the current shop
94+
product = shopify.Product.find(179761209) # Get a specific product
9495

95-
# execute a graphQL call
96+
# GraphQL API example
9697
shopify.GraphQL().execute("{ shop { name id } }")
9798
```
9899

@@ -152,13 +153,21 @@ _Note: Your application must be public to test the billing process. To test on a
152153
```
153154

154155
### Advanced Usage
156+
157+
> **⚠️ Note**: As of October 1, 2024, the REST Admin API is legacy:
158+
> - Public apps must migrate to GraphQL by February 2025
159+
> - Custom apps must migrate to GraphQL by April 2025
160+
>
161+
> For migration guidance, see [Shopify's migration guide](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model)
162+
155163
It is recommended to have at least a basic grasp on the principles of the [pyactiveresource](https://github.com/Shopify/pyactiveresource) library, which is a port of rails/ActiveResource to Python and upon which this package relies heavily.
156164

157165
Instances of `pyactiveresource` resources map to RESTful resources in the Shopify API.
158166

159167
`pyactiveresource` exposes life cycle methods for creating, finding, updating, and deleting resources which are equivalent to the `POST`, `GET`, `PUT`, and `DELETE` HTTP verbs.
160168

161169
```python
170+
# Note: REST API examples will be deprecated in 2025
162171
product = shopify.Product()
163172
product.title = "Shopify Logo T-Shirt"
164173
product.id # => 292082188312
@@ -184,6 +193,7 @@ new_orders = shopify.Order.find(status="open", limit="50")
184193
Some resources such as `Fulfillment` are prefixed by a parent resource in the Shopify API (e.g. `orders/450789469/fulfillments/255858046`). In order to interact with these resources, you must specify the identifier of the parent resource in your request.
185194

186195
```python
196+
# Note: This REST API example will be deprecated in the future
187197
shopify.Fulfillment.find(255858046, order_id=450789469)
188198
```
189199

@@ -198,6 +208,9 @@ This package also includes the `shopify_api.py` script to make it easy to open a
198208

199209
This library also supports Shopify's new [GraphQL API](https://help.shopify.com/en/api/graphql-admin-api). The authentication process is identical. Once your session is activated, simply construct a new graphql client and use `execute` to execute the query.
200210

211+
> **Note**: Shopify recommends using GraphQL API for new development as REST API will be deprecated.
212+
> See [Migration Guide](https://shopify.dev/docs/apps/build/graphql/migrate/new-product-model) for more details.
213+
201214
```python
202215
result = shopify.GraphQL().execute('{ shop { name id } }')
203216
```

scripts/shopify_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def add(cls, connection):
128128
if os.path.exists(filename):
129129
raise ConfigFileError("There is already a config file at " + filename)
130130
else:
131-
config = dict(protocol="https")
131+
config = {"protocol": "https"}
132132
domain = input("Domain? (leave blank for %s.myshopify.com) " % (connection))
133133
if not domain.strip():
134134
domain = "%s.myshopify.com" % (connection)

shopify/api_access.py

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ class ApiAccessError(Exception):
1414

1515

1616
class ApiAccess:
17-
1817
SCOPE_DELIMITER = ","
1918
SCOPE_RE = re.compile(r"\A(?P<unauthenticated>unauthenticated_)?(write|read)_(?P<resource>.*)\Z")
2019
IMPLIED_SCOPE_RE = re.compile(r"\A(?P<unauthenticated>unauthenticated_)?write_(?P<resource>.*)\Z")

shopify/mixins.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def add_metafield(self, metafield):
2424
if self.is_new():
2525
raise ValueError("You can only add metafields to a resource that has been saved")
2626

27-
metafield._prefix_options = dict(resource=self.__class__.plural, resource_id=self.id)
27+
metafield._prefix_options = {"resource": self.__class__.plural, "resource_id": self.id}
2828
metafield.save()
2929
return metafield
3030

shopify/session.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ def request_token(self, params):
7272
code = params["code"]
7373

7474
url = "https://%s/admin/oauth/access_token?" % self.url
75-
query_params = dict(client_id=self.api_key, client_secret=self.secret, code=code)
75+
query_params = {"client_id": self.api_key, "client_secret": self.secret, "code": code}
7676
request = urllib.request.Request(url, urllib.parse.urlencode(query_params).encode("utf-8"))
7777
response = urllib.request.urlopen(request)
7878

0 commit comments

Comments
 (0)