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

Commit 1568911

Browse files
committed
Add Reactions API.
1 parent f0cd630 commit 1568911

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

Diff for: slacker/__init__.py

+55-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424

2525
__all__ = ['Error', 'Response', 'BaseAPI', 'API', 'Auth', 'Users', 'Groups',
2626
'Channels', 'Chat', 'IM', 'IncomingWebhook', 'Search', 'Files',
27-
'Stars', 'Emoji', 'Presence', 'RTM', 'Team', 'OAuth', 'Slacker']
27+
'Stars', 'Emoji', 'Presence', 'RTM', 'Team', 'Reactions', 'OAuth',
28+
'Slacker']
2829

2930

3031
class Error(Exception):
@@ -396,6 +397,58 @@ def access_logs(self, count=None, page=None):
396397
params={'count': count, 'page': page})
397398

398399

400+
class Reactions(BaseAPI):
401+
def add(self, name, file_=None, file_comment=None, channel=None,
402+
timestamp=None):
403+
# One of file, file_comment, or the combination of channel and timestamp
404+
# must be specified
405+
assert (file_ or file_comment) or (channel and timestamp)
406+
407+
return self.post('reactions.add',
408+
params={
409+
'name': name,
410+
'file': file_,
411+
'file_comment': file_comment,
412+
'channel': channel,
413+
'timestamp': timestamp,
414+
})
415+
416+
def get(self, file_=None, file_comment=None, channel=None, timestamp=None,
417+
full=None):
418+
return super(Reactions, self).get('reactions.get',
419+
params={
420+
'file': file_,
421+
'file_comment': file_comment,
422+
'channel': channel,
423+
'timestamp': timestamp,
424+
'full': full,
425+
})
426+
427+
def list(self, user=None, full=None, count=None, page=None):
428+
return super(Reactions, self).get('reactions.list',
429+
params={
430+
'user': user,
431+
'full': full,
432+
'count': count,
433+
'page': page,
434+
})
435+
436+
def remove(self, name, file_=None, file_comment=None, channel=None,
437+
timestamp=None):
438+
# One of file, file_comment, or the combination of channel and timestamp
439+
# must be specified
440+
assert (file_ or file_comment) or (channel and timestamp)
441+
442+
return self.post('reactions.remove',
443+
params={
444+
'name': name,
445+
'file': file_,
446+
'file_comment': file_comment,
447+
'channel': channel,
448+
'timestamp': timestamp,
449+
})
450+
451+
399452
class OAuth(BaseAPI):
400453
def access(self, client_id, client_secret, code, redirect_uri=None):
401454
return self.post('oauth.access',
@@ -440,4 +493,5 @@ def __init__(self, token, incoming_webhook_url=None):
440493
self.groups = Groups(token=token)
441494
self.channels = Channels(token=token)
442495
self.presence = Presence(token=token)
496+
self.reactions = Reactions(token=token)
443497
self.incomingwebhook = IncomingWebhook(url=incoming_webhook_url)

0 commit comments

Comments
 (0)