Skip to content

Commit 9de19fd

Browse files
committed
Bumped v0.8.0
Signed-off-by: Vishal Rana <vr@labstack.com>
1 parent f0e0b32 commit 9de19fd

File tree

8 files changed

+30
-219
lines changed

8 files changed

+30
-219
lines changed

README.md

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

1515
```python
16-
from labstack import Client
17-
18-
client = Client('<ACCOUNT_ID>', '<API_KEY>')
19-
store = client.store()
20-
doc = store.insert('users', {
21-
name: 'Jack',
22-
location: 'Disney'
23-
})
24-
print(doc)
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)
2524
```
2625

2726
From terminal run your app:
@@ -30,4 +29,4 @@ From terminal run your app:
3029
python app.py
3130
```
3231

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

labstack/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
11
from .client import Client
2-
from .email import EmailMessage, EmailError
3-
from .log import Level, LogError
4-
from .store import StoreError
2+
from .jet import JetMessage, JetError

labstack/client.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import requests
2-
from .message import _Message
3-
from .email import _Email
4-
from .log import _Log
5-
from .store import _Store
2+
from .hub import _Hub
3+
from .jet import _Jet
64

75
class _Interceptor(requests.auth.AuthBase):
86
def __init__(self, api_key):
@@ -19,16 +17,9 @@ def __init__(self, account_id, api_key):
1917
self.api_key = api_key
2018
self.interceptor = _Interceptor(api_key)
2119

22-
def message(self, client_id):
23-
return _Message(self.account_id, self.api_key, client_id)
20+
def hub(self, client_id):
21+
return _Hub(self.account_id, self.api_key, client_id)
2422

25-
def email(self):
26-
return _Email(self.interceptor)
27-
28-
def log(self):
29-
log = _Log(self.interceptor)
30-
return log
31-
32-
def store(self):
33-
return _Store(self.interceptor)
23+
def jet(self):
24+
return _Jet(self.interceptor)
3425

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import paho.mqtt.client as mqtt
22

3-
class _Message():
3+
class _Hub():
44
def __init__(self, account_id, api_key, client_id):
55
self.account_id = account_id
66
self.client = mqtt.Client(client_id=client_id, clean_session=True)
@@ -12,10 +12,10 @@ def connect_handler(client, userdata, flags, rc):
1212
handler()
1313
self.client.on_connect = connect_handler
1414

15-
def data_handler(self, handler):
16-
def data_handler(client, userdata, msg):
15+
def message_handler(self, handler):
16+
def message_handler(client, userdata, msg):
1717
handler(msg.topic, msg.payload)
18-
self.client.on_message = data_handler
18+
self.client.on_message = message_handler
1919

2020
def publish(self, topic, message):
2121
self.client.publish('{}/{}'.format(self.account_id, topic), message)

labstack/email.py renamed to labstack/jet.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,21 @@
44
import json
55
from .common import API_URL
66

7-
class _Email():
7+
class _Jet():
88
def __init__(self, interceptor):
9-
self.path = '/email'
9+
self.path = '/jet'
1010
self.interceptor = interceptor
1111

1212
def send(self, message):
1313
message._add_inlines()
1414
message._add_attachments()
15-
r = requests.post(API_URL + self.path, auth=self.interceptor, data=message.to_json())
15+
r = requests.post('{}{}/send'.format(API_URL, self.path), auth=self.interceptor, data=message.to_json())
1616
data = r.json()
1717
if not 200 <= r.status_code < 300:
18-
raise EmailError(data['code'], data['message'])
19-
return EmailMessage.from_json(data)
18+
raise JetError(data['code'], data['message'])
19+
return JetMessage.from_json(data)
2020

21-
class EmailMessage():
21+
class JetMessage():
2222
def __init__(self, to, from_, subject):
2323
self._inlines = []
2424
self._attachments = []
@@ -64,13 +64,13 @@ def to_json(self):
6464

6565
@classmethod
6666
def from_json(self, message):
67-
em = EmailMessage(message['to'], message['from'], message['subject'])
67+
em = JetMessage(message['to'], message['from'], message['subject'])
6868
em.id = message['id']
6969
em.time = message['time']
7070
em.status = message['status']
7171
return em
7272

73-
class EmailError(Exception):
73+
class JetError(Exception):
7474
def __init__(self, code, message):
7575
self.code = code
7676
self.message = message

labstack/log.py

Lines changed: 0 additions & 80 deletions
This file was deleted.

labstack/store.py

Lines changed: 0 additions & 97 deletions
This file was deleted.

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
setup(
44
name='labstack',
5-
version='0.7.1',
5+
version='0.8.0',
66
description='Official Python client library for the LabStack platform',
77
long_description='`<https://github.com/labstack/labstack-python>`_',
8-
keywords='labstack cube email log mqtt store',
8+
keywords='labstack, email as a service, http analytics, pub/sub messaging',
99
url='https://github.com/labstack/labstack-python',
1010
author='Vishal Rana',
1111
author_email='vr@labstack.com',

0 commit comments

Comments
 (0)