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..513a408 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).decode('utf-8') + ) 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 "] 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",