Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
name: Python ${{ matrix.version }}
strategy:
matrix:
version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
version: ["3.8", "3.9", "3.10", "3.11", "3.12"]

steps:
- name: Checkout
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Install Dependencies
run: |
python -m pip install --upgrade pip
pip install pytest mock pytest-cov
pip install pytest mock pytest-cov setuptools
python setup.py install
pytest --cov=./ --cov-report=xml
- name: Run Tests
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: pre-commit
on:
pull_request:
push:
branches: [master]
branches: [main]

jobs:
pre-commit:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
This probably means that it is not reproducible or it has been fixed in a newer version.
If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

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
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

Thank you!
days-before-pr-stale: -1
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
== Unreleased

== Version 12.7.0

- 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))

== Version 12.6.0

- Update API version with 2024-07 release ([#723](https://github.com/Shopify/shopify_python_api/pull/723))

== Version 12.5.0

- Remove `cgi` import to avoid triggering a `DeprecationWarning` on Python 3.11.
- Update API version with 2024-04 release.([710](https://github.com/Shopify/shopify_python_api/pull/710))

Expand Down
37 changes: 23 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

[![Build Status](https://github.com/Shopify/shopify_python_api/workflows/CI/badge.svg)](https://github.com/Shopify/shopify_python_api/actions)
[![PyPI version](https://badge.fury.io/py/ShopifyAPI.svg)](https://badge.fury.io/py/ShopifyAPI)
[![codecov](https://codecov.io/gh/Shopify/shopify_python_api/branch/master/graph/badge.svg?token=pNTx0TARUx)](https://codecov.io/gh/Shopify/shopify_python_api)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Shopify/shopify_python_api/blob/master/LICENSE)
![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)
[![codecov](https://codecov.io/gh/Shopify/shopify_python_api/branch/main/graph/badge.svg?token=pNTx0TARUx)](https://codecov.io/gh/Shopify/shopify_python_api)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://github.com/Shopify/shopify_python_api/blob/main/LICENSE)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)

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

### Table of Contents

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


### Getting Started
Expand All @@ -54,7 +63,7 @@ pip install --upgrade ShopifyAPI

```python
shop_url = "SHOP_NAME.myshopify.com"
api_version = '2024-01'
api_version = '2024-07'
state = binascii.b2a_hex(os.urandom(15)).decode("utf-8")
redirect_uri = "http://myapp.com/auth/shopify/callback"
scopes = ['read_products', 'read_orders']
Expand Down Expand Up @@ -263,7 +272,7 @@ page2 = shopify.Product.find(from_=next_url)
```

## Set up pre-commit locally [OPTIONAL]
[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
[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
```shell
pip install -r requirements.txt
pre-commit install
Expand Down
2 changes: 1 addition & 1 deletion RELEASING
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ Releasing shopify_python_api
git tag -m "Release X.Y.Z" vX.Y.Z

7. Push the changes to github
git push --tags origin master
git push --tags origin main

8. Shipit!
2 changes: 1 addition & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

### New features

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

### Bug fixes

Expand Down
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
install_requires=[
"pyactiveresource>=2.2.2",
"PyJWT >= 2.0.0",
"PyYAML",
"PyYAML>=6.0.1; python_version>='3.12'",
"PyYAML; python_version<'3.12'",
"six",
],
test_suite="test",
Expand All @@ -44,6 +45,7 @@
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development",
"Topic :: Software Development :: Libraries",
"Topic :: Software Development :: Libraries :: Python Modules",
Expand Down
5 changes: 5 additions & 0 deletions shopify/api_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ def coerce_to_version(cls, version):
try:
return cls.versions[version]
except KeyError:
# Dynamically create a new Release object if version string is not found
if Release.FORMAT.match(version):
return Release(version)
raise VersionNotFoundError

@classmethod
Expand All @@ -38,6 +41,8 @@ def define_known_versions(cls):
cls.define_version(Release("2023-10"))
cls.define_version(Release("2024-01"))
cls.define_version(Release("2024-04"))
cls.define_version(Release("2024-07"))
cls.define_version(Release("2024-10"))

@classmethod
def clear_defined_versions(cls):
Expand Down
2 changes: 1 addition & 1 deletion shopify/resources/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from .page import Page
from .country import Country
from .refund import Refund
from .fulfillment import Fulfillment, FulfillmentOrders
from .fulfillment import Fulfillment, FulfillmentOrders, FulfillmentV2
from .fulfillment_event import FulfillmentEvent
from .fulfillment_service import FulfillmentService
from .carrier_service import CarrierService
Expand Down
2 changes: 1 addition & 1 deletion shopify/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "12.5.0"
VERSION = "12.7.0"
14 changes: 14 additions & 0 deletions test/api_version_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ def test_coerce_to_version_raises_with_string_that_does_not_match_known_version(
with self.assertRaises(shopify.VersionNotFoundError):
shopify.ApiVersion.coerce_to_version("crazy-name")

def test_coerce_to_version_creates_new_release_on_the_fly(self):
new_version = "2025-01"
coerced_version = shopify.ApiVersion.coerce_to_version(new_version)

self.assertIsInstance(coerced_version, shopify.Release)
self.assertEqual(coerced_version.name, new_version)
self.assertEqual(
coerced_version.api_path("https://test.myshopify.com"),
f"https://test.myshopify.com/admin/api/{new_version}",
)

# Verify that the new version is not added to the known versions
self.assertNotIn(new_version, shopify.ApiVersion.versions)


class ReleaseTest(TestCase):
def test_raises_if_format_invalid(self):
Expand Down
13 changes: 13 additions & 0 deletions test/session_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,16 @@ def normalize_url(self, url):
scheme, netloc, path, query, fragment = urllib.parse.urlsplit(url)
query = "&".join(sorted(query.split("&")))
return urllib.parse.urlunsplit((scheme, netloc, path, query, fragment))

def test_session_with_coerced_version(self):
future_version = "2030-01"
session = shopify.Session("test.myshopify.com", future_version, "token")
self.assertEqual(session.api_version.name, future_version)
self.assertEqual(
session.api_version.api_path("https://test.myshopify.com"),
f"https://test.myshopify.com/admin/api/{future_version}",
)

def test_session_with_invalid_version(self):
with self.assertRaises(shopify.VersionNotFoundError):
shopify.Session("test.myshopify.com", "invalid-version", "token")
Loading