Skip to content

Commit 6ab59f3

Browse files
committed
Bumped v0.10.0
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent af4f06b commit 6ab59f3

File tree

4 files changed

+33
-15
lines changed

4 files changed

+33
-15
lines changed

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
Create a file `app.py` with the following content:
1414

1515
```python
16-
from labstack import Client, JetMessage
17-
18-
client = Client('ACCOUNT_ID', '<API_KEY>')
19-
jet = client.jet()
20-
message = JetMessage('jack@labstack.com', 'LabStack', 'Hello')
21-
message.body = 'hello'
22-
message.add_inline('walle.png')
23-
message = jet.send(message)
16+
from labstack import Client, APIError
17+
18+
client = Client('<API_KEY>')
19+
20+
try:
21+
response = client.barcode_generate(format='qr_code', content='https://labstack.com')
22+
client.download(response['id'], '/tmp/' + response['name'])
23+
except APIError as error:
24+
print(error)
2425
```
2526

2627
From terminal run your app:
@@ -29,4 +30,4 @@ From terminal run your app:
2930
python app.py
3031
```
3132

32-
## [Documentation](https://labstack.com/docs) | [Forum](https://forum.labstack.com)
33+
## [API](https://labstack.com/api) | [Forum](https://forum.labstack.com)

labstack/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .client import Client
1+
from .client import Client, APIError

labstack/client.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,25 @@ def __init__(self, api_key):
1515
self.api_key = api_key
1616
self.interceptor = _Interceptor(api_key)
1717

18+
def download(self, id, path):
19+
r = requests.get('{}/download/{}'.format(API_URL, id), stream=True)
20+
with open(path, 'wb') as f:
21+
for chunk in r.iter_content(chunk_size=1024):
22+
if chunk:
23+
f.write(chunk)
24+
f.flush()
25+
26+
def barcode_generate(self, format=None, content=None):
27+
json = {
28+
'format': format,
29+
'content': content
30+
}
31+
r = requests.post('{}/barcode/generate'.format(API_URL), auth=self.interceptor, json=json)
32+
data = r.json()
33+
if not 200 <= r.status_code < 300:
34+
raise APIError(data['code'], data['message'])
35+
return data
36+
1837
def image_compress(self, file=None):
1938
files = {'file': open(file, 'rb')}
2039
r = requests.post('{}/image/compress'.format(API_URL), auth=self.interceptor, files=files)

setup.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,16 @@
22

33
setup(
44
name='labstack',
5-
version='0.8.0',
6-
description='Official Python client library for the LabStack platform',
5+
version='0.10.0',
6+
description='Official Python client library for the LabStack API',
77
long_description='`<https://github.com/labstack/labstack-python>`_',
8-
keywords='labstack, email as a service, http analytics, pub/sub messaging',
8+
keywords='image compress, image resize, text summary, barcode generate, barcode scan',
99
url='https://github.com/labstack/labstack-python',
1010
author='Vishal Rana',
1111
author_email='vr@labstack.com',
1212
license='MIT',
1313
packages=['labstack'],
1414
install_requires=[
15-
'arrow==0.10.0',
16-
'paho-mqtt==1.3.0',
1715
'requests==2.18.1'
1816
],
1917
classifiers=[

0 commit comments

Comments
 (0)