Skip to content

Commit b476327

Browse files
authored
Merge branch 'main' into master
2 parents 1b693b5 + f58c991 commit b476327

File tree

19 files changed

+171
-56
lines changed

19 files changed

+171
-56
lines changed

.github/workflows/build.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ jobs:
66
name: Python ${{ matrix.version }}
77
strategy:
88
matrix:
9-
version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
9+
version: ["3.8", "3.9", "3.10", "3.11", "3.12"]
1010

1111
steps:
1212
- name: Checkout
@@ -18,7 +18,7 @@ jobs:
1818
- name: Install Dependencies
1919
run: |
2020
python -m pip install --upgrade pip
21-
pip install pytest mock pytest-cov
21+
pip install pytest mock pytest-cov setuptools
2222
python setup.py install
2323
pytest --cov=./ --cov-report=xml
2424
- name: Run Tests
@@ -27,4 +27,4 @@ jobs:
2727
uses: codecov/codecov-action@v1
2828
with:
2929
name: codecov-umbrella
30-
fail_ci_if_error: true
30+
fail_ci_if_error: false

.github/workflows/pre-commit.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: pre-commit
33
on:
44
pull_request:
55
push:
6-
branches: [master]
6+
branches: [main]
77

88
jobs:
99
pre-commit:
@@ -12,6 +12,6 @@ jobs:
1212
- name: Checkout
1313
uses: actions/checkout@v2
1414
- name: Setup
15-
uses: actions/setup-python@v2
15+
uses: actions/setup-python@v4
1616
- name: Pre-commit
1717
uses: pre-commit/[email protected]

.github/workflows/stale.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
This probably means that it is not reproducible or it has been fixed in a newer version.
2323
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
2424
25-
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_python_api/blob/master/CONTRIBUTING.md) file for guidelines
25+
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_python_api/blob/main/CONTRIBUTING.md) file for guidelines
2626
2727
Thank you!
2828
days-before-pr-stale: -1

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
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

CHANGELOG

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
== Unreleased
22

3+
- Remove requirement to provide scopes to Permission URL, as it should be omitted if defined with the TOML file.
4+
5+
== Version 12.7.0
6+
7+
- Remove requirement to use a predefined API version. Now you can use any valid API version string. ([#737](https://github.com/Shopify/shopify_python_api/pull/737))
8+
9+
== Version 12.6.0
10+
11+
- Update API version with 2024-07 release ([#723](https://github.com/Shopify/shopify_python_api/pull/723))
12+
13+
== Version 12.5.0
14+
15+
- Remove `cgi` import to avoid triggering a `DeprecationWarning` on Python 3.11.
16+
- Update API version with 2024-04 release.([710](https://github.com/Shopify/shopify_python_api/pull/710))
17+
18+
== Version 12.4.0
19+
20+
- Update API version with 2023-07, 2023-10, 2024-01 releases ([#694](https://github.com/Shopify/shopify_python_api/pull/694))
21+
322
== Version 12.3.0
423

524
- Update API version with 2023-04 release ([#649](https://github.com/Shopify/shopify_python_api/pull/649))

README.md

Lines changed: 51 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22

33
[![Build Status](https://github.com/Shopify/shopify_python_api/workflows/CI/badge.svg)](https://github.com/Shopify/shopify_python_api/actions)
44
[![PyPI version](https://badge.fury.io/py/ShopifyAPI.svg)](https://badge.fury.io/py/ShopifyAPI)
5-
[![codecov](https://codecov.io/gh/Shopify/shopify_python_api/branch/master/graph/badge.svg?token=pNTx0TARUx)](https://codecov.io/gh/Shopify/shopify_python_api)
6-
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Shopify/shopify_python_api/blob/master/LICENSE)
5+
![Supported Python Versions](https://img.shields.io/badge/python-3.7%20|%203.8%20|%203.9%20|%203.10%20|%203.11%20|%203.12-brightgreen)
6+
[![codecov](https://codecov.io/gh/Shopify/shopify_python_api/branch/main/graph/badge.svg?token=pNTx0TARUx)](https://codecov.io/gh/Shopify/shopify_python_api)
7+
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Shopify/shopify_python_api/blob/main/LICENSE)
78
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
89

910
The [Shopify Admin API](https://shopify.dev/docs/admin-api) Python Library
@@ -23,20 +24,28 @@ pip install --upgrade ShopifyAPI
2324

2425
### Table of Contents
2526

26-
- [Getting Started](#getting-started)
27-
- [Public and Custom Apps](#public-and-custom-apps)
28-
- [Private Apps](#private-apps)
29-
- [Billing](#billing)
30-
- [Session Tokens](docs/session-tokens.md)
31-
- [Handling Access Scope Operations](docs/api-access.md)
32-
- [Advanced Usage](#advanced-usage)
33-
- [Prefix Options](#prefix-options)
34-
- [Console](#console)
35-
- [GraphQL](#graphql)
27+
- [Usage](#usage)
28+
- [Requirements](#requirements)
29+
- [Installation](#installation)
30+
- [Table of Contents](#table-of-contents)
31+
- [Getting Started](#getting-started)
32+
- [Public and Custom Apps](#public-and-custom-apps)
33+
- [Private Apps](#private-apps)
34+
- [With full session](#with-full-session)
35+
- [With temporary session](#with-temporary-session)
36+
- [Billing](#billing)
37+
- [Advanced Usage](#advanced-usage)
38+
- [Prefix options](#prefix-options)
39+
- [Console](#console)
40+
- [GraphQL](#graphql)
3641
- [Using Development Version](#using-development-version)
42+
- [Building and installing dev version](#building-and-installing-dev-version)
43+
- [Running Tests](#running-tests)
3744
- [Relative Cursor Pagination](#relative-cursor-pagination)
45+
- [Set up pre-commit locally \[OPTIONAL\]](#set-up-pre-commit-locally-optional)
3846
- [Limitations](#limitations)
3947
- [Additional Resources](#additional-resources)
48+
- [Sample apps built using this library](#sample-apps-built-using-this-library)
4049

4150

4251
### Getting Started
@@ -46,19 +55,23 @@ pip install --upgrade ShopifyAPI
4655
1. We then need to supply these keys to the Shopify Session Class so that it knows how to authenticate.
4756

4857
```python
58+
import shopify
59+
4960
shopify.Session.setup(api_key=API_KEY, secret=API_SECRET)
5061
```
5162
1. In order to access a shop's data, apps need an access token from that specific shop. We need to authenticate with that shop using OAuth, which we can start in the following way:
5263

5364
```python
5465
shop_url = "SHOP_NAME.myshopify.com"
55-
api_version = '2020-10'
66+
api_version = '2024-07'
5667
state = binascii.b2a_hex(os.urandom(15)).decode("utf-8")
5768
redirect_uri = "http://myapp.com/auth/shopify/callback"
69+
# `scope` should be omitted if provided by app's TOML
5870
scopes = ['read_products', 'read_orders']
5971

6072
newSession = shopify.Session(shop_url, api_version)
61-
auth_url = newSession.create_permission_url(scopes, redirect_uri, state)
73+
# `scope` should be omitted if provided by app's TOML
74+
auth_url = newSession.create_permission_url(redirect_uri, scopes, state)
6275
# redirect to auth_url
6376
```
6477

@@ -76,10 +89,11 @@ pip install --upgrade ShopifyAPI
7689
session = shopify.Session(shop_url, api_version, access_token)
7790
shopify.ShopifyResource.activate_session(session)
7891

79-
shop = shopify.Shop.current() # Get the current shop
80-
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
8195

82-
# execute a graphQL call
96+
# GraphQL API example
8397
shopify.GraphQL().execute("{ shop { name id } }")
8498
```
8599

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

141155
### 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+
142163
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.
143164

144165
Instances of `pyactiveresource` resources map to RESTful resources in the Shopify API.
145166

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

148169
```python
170+
# Note: REST API examples will be deprecated in 2025
149171
product = shopify.Product()
150172
product.title = "Shopify Logo T-Shirt"
151173
product.id # => 292082188312
@@ -160,11 +182,18 @@ product.destroy()
160182
# Delete the resource from the remote server (i.e. Shopify)
161183
```
162184

185+
Here is another example to retrieve a list of open orders using certain parameters:
186+
187+
```python
188+
new_orders = shopify.Order.find(status="open", limit="50")
189+
```
190+
163191
### Prefix options
164192

165193
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.
166194

167195
```python
196+
# Note: This REST API example will be deprecated in the future
168197
shopify.Fulfillment.find(255858046, order_id=450789469)
169198
```
170199

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

180209
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.
181210

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+
182214
```python
183215
result = shopify.GraphQL().execute('{ shop { name id } }')
184216
```
@@ -242,7 +274,7 @@ python setup.py test
242274
## Relative Cursor Pagination
243275
Cursor based pagination support has been added in 6.0.0.
244276

245-
```
277+
```python
246278
import shopify
247279

248280
page1 = shopify.Product.find()
@@ -255,7 +287,7 @@ page2 = shopify.Product.find(from_=next_url)
255287
```
256288

257289
## Set up pre-commit locally [OPTIONAL]
258-
[Pre-commit](https://pre-commit.com/) is set up as a GitHub action that runs on pull requests and pushes to the `master` branch. If you want to run pre-commit locally, install it and set up the git hook scripts
290+
[Pre-commit](https://pre-commit.com/) is set up as a GitHub action that runs on pull requests and pushes to the `main` branch. If you want to run pre-commit locally, install it and set up the git hook scripts
259291
```shell
260292
pip install -r requirements.txt
261293
pre-commit install

RELEASING

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ Releasing shopify_python_api
1515
git tag -m "Release X.Y.Z" vX.Y.Z
1616

1717
7. Push the changes to github
18-
git push --tags origin master
18+
git push --tags origin main
1919

2020
8. Shipit!

SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
### New features
66

7-
New features will only be added to the master branch and will not be made available in point releases.
7+
New features will only be added to the main branch and will not be made available in point releases.
88

99
### Bug fixes
1010

scripts/shopify_api.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,18 @@
1616
def start_interpreter(**variables):
1717
# add the current working directory to the sys paths
1818
sys.path.append(os.getcwd())
19-
console = type("shopify " + shopify.version.VERSION, (code.InteractiveConsole, object), {})
20-
import readline
19+
try:
20+
from IPython import start_ipython
21+
from traitlets.config.loader import Config
2122

22-
console(variables).interact()
23+
config = Config(TerminalInteractiveShell={"banner2": "(shopify %s)" % shopify.version.VERSION})
24+
start_ipython(argv=[], user_ns=variables, config=config)
25+
26+
except ImportError:
27+
console = type("shopify " + shopify.version.VERSION, (code.InteractiveConsole, object), {})
28+
import readline
29+
30+
console(variables).interact()
2331

2432

2533
class ConfigFileError(Exception):
@@ -120,7 +128,7 @@ def add(cls, connection):
120128
if os.path.exists(filename):
121129
raise ConfigFileError("There is already a config file at " + filename)
122130
else:
123-
config = dict(protocol="https")
131+
config = {"protocol": "https"}
124132
domain = input("Domain? (leave blank for %s.myshopify.com) " % (connection))
125133
if not domain.strip():
126134
domain = "%s.myshopify.com" % (connection)

setup.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
install_requires=[
2525
"pyactiveresource>=2.2.2",
2626
"PyJWT >= 2.0.0",
27-
"PyYAML",
27+
"PyYAML>=6.0.1; python_version>='3.12'",
28+
"PyYAML; python_version<'3.12'",
2829
"six",
2930
],
3031
test_suite="test",
@@ -44,6 +45,7 @@
4445
"Programming Language :: Python :: 3.9",
4546
"Programming Language :: Python :: 3.10",
4647
"Programming Language :: Python :: 3.11",
48+
"Programming Language :: Python :: 3.12",
4749
"Topic :: Software Development",
4850
"Topic :: Software Development :: Libraries",
4951
"Topic :: Software Development :: Libraries :: Python Modules",

0 commit comments

Comments
 (0)