Skip to content
This repository has been archived by the owner on Jul 3, 2020. It is now read-only.

Commit

Permalink
Add dnd APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
os committed Jan 9, 2016
1 parent 81efda0 commit 95a3a16
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion slacker/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
__all__ = ['Error', 'Response', 'BaseAPI', 'API', 'Auth', 'Users', 'Groups',
'Channels', 'Chat', 'IM', 'IncomingWebhook', 'Search', 'Files',
'Stars', 'Emoji', 'Presence', 'RTM', 'Team', 'Reactions', 'Pins',
'UserGroups', 'UserGroupsUsers', 'MPIM', 'OAuth', 'Slacker']
'UserGroups', 'UserGroupsUsers', 'MPIM', 'OAuth', 'DND', 'Slacker']


class Error(Exception):
Expand Down Expand Up @@ -612,6 +612,26 @@ def enable(self, usergroup, include_count=None):
})


class DND(BaseAPI):
def team_info(self, users=None):
if isinstance(users, (tuple, list)):
users = ','.join(users)

return self.get('dnd.teamInfo', params={'users': users})

def set_snooze(self, num_minutes):
return self.post('dnd.setSnooze', data={'num_minutes': num_minutes})

def info(self, user=None):
return self.get('dnd.info', params={'user': user})

def end_dnd(self):
return self.post('dnd.endDnd')

def end_snooze(self):
return self.post('dnd.endSnooze')


class OAuth(BaseAPI):
def access(self, client_id, client_secret, code, redirect_uri=None):
return self.post('oauth.access',
Expand Down Expand Up @@ -647,6 +667,7 @@ def __init__(self, token, incoming_webhook_url=None,
timeout=DEFAULT_TIMEOUT):
self.im = IM(token=token, timeout=timeout)
self.api = API(token=token, timeout=timeout)
self.dnd = DND(token=token, timeout=timeout)
self.rtm = RTM(token=token, timeout=timeout)
self.auth = Auth(token=token, timeout=timeout)
self.chat = Chat(token=token, timeout=timeout)
Expand Down

0 comments on commit 95a3a16

Please sign in to comment.