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 dynatademand/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions dynatademand/validator.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import json
import jsonschema
import pkg_resources

ENDPOINTS = {
# Authorization
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <Ridley.Larsen@dynata.com>", "Bradley Wogsland <Bradley.Wogsland@dynata.com>", "Nathan Workman <Nathan.Workman@dynata.com>"]

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down