From 24f70e0b785ed54d722cc899d731e0d0f0d91e24 Mon Sep 17 00:00:00 2001 From: herzaso Date: Sun, 16 Jul 2017 16:04:49 +0300 Subject: [PATCH 1/4] upgrade OCR to version 5 and add optional filter parameter --- ocr/__init__.py | 7 ++++++- ocr/ocr.py | 6 +++++- setup.py | 2 +- test.py | 2 +- 4 files changed, 13 insertions(+), 4 deletions(-) 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..58b0cbf 100644 --- a/test.py +++ b/test.py @@ -24,7 +24,7 @@ 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) From 11131299cfdeabe8e0f5d7c65c373d40f693bd62 Mon Sep 17 00:00:00 2001 From: herzaso Date: Mon, 17 Jul 2017 14:37:32 +0300 Subject: [PATCH 2/4] travis didnt report status --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ad2dc74..254849e 100644 --- a/README.md +++ b/README.md @@ -3,3 +3,4 @@ One Click Retail Data Source for [Panoply.io](http://panoply.io). See [Panoply's SDK](https://github.com/panoplyio/panoply-python-sdk) for more information about the API used here. + From 964e216b14b4257d9faabce3c7d7726082016b97 Mon Sep 17 00:00:00 2001 From: herzaso Date: Mon, 17 Jul 2017 15:40:56 +0300 Subject: [PATCH 3/4] travis didnt report status --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 254849e..ad2dc74 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,3 @@ One Click Retail Data Source for [Panoply.io](http://panoply.io). See [Panoply's SDK](https://github.com/panoplyio/panoply-python-sdk) for more information about the API used here. - From f96ef945d9e6498cb159107e02115739ced08f34 Mon Sep 17 00:00:00 2001 From: herzaso Date: Mon, 17 Jul 2017 15:44:58 +0300 Subject: [PATCH 4/4] fix linting issue --- test.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test.py b/test.py index 58b0cbf..322052d 100644 --- a/test.py +++ b/test.py @@ -24,7 +24,10 @@ def setUp(self): 'apiKey': 'testKey', 'weeks': 1, 'resources': [ - {'name': 'reports csv', 'value': 'v5/clients/%s/reports/export'} + { + 'name': 'reports csv', + 'value': 'v5/clients/%s/reports/export' + } ] } self.stream = OcrSource(self.source, OPTIONS)