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
3 changes: 3 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
== Unreleased
- Revert Feature #441 Dynamic API Versioning ([#495](https://github.com/Shopify/shopify_python_api/pull/495))

== Version 8.3.1
- Fix bug: Add the `shopify/utils` sub-package when building the source distribution ([#493](https://github.com/Shopify/shopify_python_api/pull/493))

Expand Down
18 changes: 7 additions & 11 deletions shopify/api_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import re
import json
from six.moves.urllib import request


class InvalidVersionError(Exception):
Expand Down Expand Up @@ -28,15 +26,13 @@ def define_version(cls, version):

@classmethod
def define_known_versions(cls):
req = request.urlopen("https://app.shopify.com/services/apis.json")
data = json.loads(req.read().decode("utf-8"))
for api in data["apis"]:
if api["handle"] == "admin":
for release in api["versions"]:
if release["handle"] == "unstable":
cls.define_version(Unstable())
else:
cls.define_version(Release(release["handle"]))
cls.define_version(Unstable())
cls.define_version(Release("2020-01"))
cls.define_version(Release("2020-04"))
cls.define_version(Release("2020-07"))
cls.define_version(Release("2020-10"))
cls.define_version(Release("2021-01"))
cls.define_version(Release("2021-04"))

@classmethod
def clear_defined_versions(cls):
Expand Down
1 change: 0 additions & 1 deletion test/fixtures/api_version.json

This file was deleted.

20 changes: 7 additions & 13 deletions test/test_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,6 @@ def setUp(self):
self.http = http_fake.TestHandler
self.http.set_response(Exception("Bad request"))
self.http.site = "https://this-is-my-test-show.myshopify.com"
self.fake(
"apis",
url="https://app.shopify.com/services/apis.json",
method="GET",
code=200,
response_headers={"Content-type": "application/json"},
body=self.load_fixture("api_version"),
has_user_agent=False,
)

def load_fixture(self, name, format="json"):
with open(os.path.dirname(__file__) + "/fixtures/%s.%s" % (name, format), "rb") as f:
Expand All @@ -44,10 +35,13 @@ def fake(self, endpoint, **kwargs):
extension = ""
else:
extension = ".%s" % (kwargs.pop("extension", "json"))
if kwargs.get("url"):
url = kwargs.get("url")
else:
url = "https://this-is-my-test-show.myshopify.com%s/%s%s" % (prefix, endpoint, extension)

url = "https://this-is-my-test-show.myshopify.com%s/%s%s" % (prefix, endpoint, extension)
try:
url = kwargs["url"]
except KeyError:
pass

headers = {}
if kwargs.pop("has_user_agent", True):
userAgent = "ShopifyPythonAPI/%s Python/%s" % (shopify.VERSION, sys.version.split(" ", 1)[0])
Expand Down