diff --git a/ocr/__init__.py b/ocr/__init__.py index a38cad2..e59cd91 100644 --- a/ocr/__init__.py +++ b/ocr/__init__.py @@ -3,7 +3,7 @@ Stream = OcrSource resource_values = [ - {'name': 'reports csv', 'value': 'v3/clients/%s/reports/csv'} + {'name': 'reports csv', 'value': 'v5/clients/%s/reports/export'} ] CONFIG = { @@ -33,6 +33,11 @@ 'values': resource_values, 'dependencies': ['clientUUID', 'apiKey'], 'required': True + }, + { + 'name': 'filterId', + 'title': 'Filter ID', + 'dependencies': ['clientUUID', 'apiKey'] } ], 'categories': ['APIS'], diff --git a/ocr/ocr.py b/ocr/ocr.py index 8a2f5bd..8e3f2a6 100644 --- a/ocr/ocr.py +++ b/ocr/ocr.py @@ -19,7 +19,7 @@ class OcrSource(panoply.DataSource): One Click Retail data source. API Docs (require login) - https://api.oneclickretail.com/api-docs-login Implemented endpoints - - GET /v3/clients/{client_uuid}/reports/csv + GET /v5/clients/{client_uuid}/reports/export?format=csv """ def __init__(self, source, options): @@ -89,11 +89,15 @@ def _fetch_resource(self): def _build_qs(self): params = { + 'format': 'csv', 'meta': FETCH_META, 'X-API-KEY': self.api_key, 'weeks_back': self.weeks } + if self.source.get('filterId'): + params['filter_id'] = self.source['filterId'] + qs = urllib.urlencode(params) return qs diff --git a/setup.py b/setup.py index 61df7f4..54ebf83 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ setup( name='panoply_ocr', - version='1.0.0', + version='2.0.0', description='Panoply Data Source for One Click Retail', author='Lior Rozen', author_email='lior@panoply.io', diff --git a/test.py b/test.py index 7c78c8b..322052d 100644 --- a/test.py +++ b/test.py @@ -24,7 +24,10 @@ def setUp(self): 'apiKey': 'testKey', 'weeks': 1, 'resources': [ - {'name': 'reports csv', 'value': 'v3/clients/%s/reports/csv'} + { + 'name': 'reports csv', + 'value': 'v5/clients/%s/reports/export' + } ] } self.stream = OcrSource(self.source, OPTIONS)