Skip to content

Commit 6e417d2

Browse files
authored
Merge pull request #65 from seatable/script-run-completed-notification
add get_related_users and send_quick_notification APIs
2 parents 28694ef + fa6994c commit 6e417d2

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

seatable_api/main.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ def _third_party_accounts_url(self):
162162
def _dtable_db_query_url(self):
163163
return self.dtable_db_url + '/api/v1/query/' + self.dtable_uuid + '/'
164164

165+
def _get_related_users_url(self):
166+
return '%(server_url)s/api/v2.1/dtables/%(dtable_uuid)s/related-users/' % {
167+
'server_url': self.server_url,
168+
'dtable_uuid': self.dtable_uuid
169+
}
170+
171+
def _send_toast_notification_url(self):
172+
return '%(dtable_server_url)s/api/v1/dtables/%(dtable_uuid)s/ui-toasts/' % {
173+
'dtable_server_url': self.dtable_server_url,
174+
'dtable_uuid': self.dtable_uuid
175+
}
176+
165177
def _get_account_detail(self, account_name):
166178
url = self._third_party_accounts_url()
167179
params = {
@@ -814,6 +826,20 @@ def query(self, sql, convert=True):
814826
else:
815827
return results
816828

829+
def get_related_users(self):
830+
response = requests.get(self._get_related_users_url(), headers=self.headers)
831+
return parse_response(response)['user_list']
832+
833+
def send_toast_notification(self, email, msg, toast_type='success'):
834+
url = self._send_toast_notification_url()
835+
requests.post(url, json={
836+
'to_user': email,
837+
'toast_type': toast_type,
838+
'detail': {
839+
'msg': str(msg)
840+
}
841+
}, headers=self.headers)
842+
817843

818844
class Account(object):
819845
def __init__(self, login_name, password, server_url):

0 commit comments

Comments
 (0)