Skip to content

Commit

Permalink
Merge pull request #4 from herzaso/master
Browse files Browse the repository at this point in the history
upgrade OCR to version 5 and add optional filter parameter
  • Loading branch information
herzaso authored Jul 17, 2017
2 parents dbb6e07 + f96ef94 commit 34814bf
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
7 changes: 6 additions & 1 deletion ocr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -33,6 +33,11 @@
'values': resource_values,
'dependencies': ['clientUUID', 'apiKey'],
'required': True
},
{
'name': 'filterId',
'title': 'Filter ID',
'dependencies': ['clientUUID', 'apiKey']
}
],
'categories': ['APIS'],
Expand Down
6 changes: 5 additions & 1 deletion ocr/ocr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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

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='panoply_ocr',
version='1.0.0',
version='2.0.0',
description='Panoply Data Source for One Click Retail',
author='Lior Rozen',
author_email='[email protected]',
Expand Down
5 changes: 4 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 34814bf

Please sign in to comment.