From 341b95dc43d7a95d4e2cec0631f1555b9f7f5654 Mon Sep 17 00:00:00 2001 From: Ridley Larsen Date: Fri, 10 Jan 2020 11:38:48 -0700 Subject: [PATCH 1/3] Fixed issues discovered post-release. * Fixed authentication header containing the wrong content. * Corrected usage of open() instead of pkg_resources. * Bumped version number to 1.01 --- dynatademand/api.py | 4 ++-- dynatademand/validator.py | 13 +++++++++++-- pyproject.toml | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/dynatademand/api.py b/dynatademand/api.py index f32ae5a..40e1afd 100644 --- a/dynatademand/api.py +++ b/dynatademand/api.py @@ -45,7 +45,7 @@ def _api_post(self, uri, payload): self._check_authentication() url = '{}{}'.format(self.base_url, uri) request_headers = { - 'oauth_access_token': self._access_token, + 'Authorization': 'Bearer {}'.format(self._access_token), 'Content-Type': "application/json", } response = requests.post(url=url, json=payload, headers=request_headers) @@ -60,7 +60,7 @@ def _api_get(self, uri, query_params=None): self._check_authentication() url = '{}{}'.format(self.base_url, uri) request_headers = { - 'oauth_access_token': self._access_token, + 'Authorization': 'Bearer {}'.format(self._access_token), 'Content-Type': "application/json", } response = requests.get(url=url, params=query_params, headers=request_headers) diff --git a/dynatademand/validator.py b/dynatademand/validator.py index 657fddb..c8c42fd 100644 --- a/dynatademand/validator.py +++ b/dynatademand/validator.py @@ -1,5 +1,6 @@ import json import jsonschema +import pkg_resources ENDPOINTS = { # Authorization @@ -57,10 +58,18 @@ def __init__(self, ): 'query': {}, 'body': {}, } + resource_package = __name__ for endpoint_name, schemas in ENDPOINTS.items(): for schema in schemas: - with open('dynatademand/schemas/request/{}/{}.json'.format(schema, endpoint_name), 'r') as schema_file: - self.schemas[schema][endpoint_name] = json.load(schema_file) + resource_path = '/'.join(( + 'schemas', + 'request', + schema, + '{}.json'.format(endpoint_name) + )) + self.schemas[schema][endpoint_name] = json.loads( + pkg_resources.resource_string(resource_package, resource_path) + ) def _validate_object(self, schema_type, endpoint_name, data): jsonschema.validate(schema=self.schemas[schema_type][endpoint_name], instance=data) diff --git a/pyproject.toml b/pyproject.toml index 1f0a847..ecab992 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "dynatademand" -version = "1.0" +version = "1.01" description = "A Python client library for the Dynata Demand API" authors = ["Ridley Larsen ", "Bradley Wogsland ", "Nathan Workman "] From f49891364f27852bb407b765825cd05eaada150a Mon Sep 17 00:00:00 2001 From: Ridley Larsen Date: Fri, 10 Jan 2020 11:41:04 -0700 Subject: [PATCH 2/3] Bumped version number to 1.01 in setup.py. --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 0540ab9..bfae1c6 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='dynata-demandapi-client', - version=1.0, + version=1.01, license="MIT", description="A Python client library for the Dynata Demand API", long_description="A Python client library for the Dynata Demand API", From c41ce86a2736bf393987b0f4ee57383960a959cd Mon Sep 17 00:00:00 2001 From: Ridley Larsen Date: Fri, 10 Jan 2020 15:13:23 -0700 Subject: [PATCH 3/3] Fixed python 3.5 compatibility for the validator. --- dynatademand/validator.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dynatademand/validator.py b/dynatademand/validator.py index c8c42fd..513a408 100644 --- a/dynatademand/validator.py +++ b/dynatademand/validator.py @@ -68,7 +68,7 @@ def __init__(self, ): '{}.json'.format(endpoint_name) )) self.schemas[schema][endpoint_name] = json.loads( - pkg_resources.resource_string(resource_package, resource_path) + pkg_resources.resource_string(resource_package, resource_path).decode('utf-8') ) def _validate_object(self, schema_type, endpoint_name, data):