Skip to content

Commit

Permalink
implemented basic channel history endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jadolg committed Feb 24, 2017
1 parent 71e5201 commit 439ce36
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
16 changes: 16 additions & 0 deletions rocketchat/api.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from rocketchat.calls.chat.send_message import SendMessage
from rocketchat.calls.channels.get_public_rooms import GetPublicRooms
from rocketchat.calls.channels.get_room_info import GetRoomInfo
from rocketchat.calls.channels.get_history import GetRoomHistory
from rocketchat.calls.auth.get_me import GetMe


Expand Down Expand Up @@ -42,6 +43,21 @@ def get_room_info(self, room_id, **kwargs):
**kwargs
)

def get_room_history(self, room_id, oldest = None,**kwargs):
"""
Get various history of specific channel/room
:param room_id:
:param kwargs:
:return:
"""
return GetRoomHistory(settings=self.settings, **kwargs).call(
room_id=room_id,
oldest=oldest,
**kwargs
)


def get_my_info(self, **kwargs):

return GetMe(settings=self.settings, **kwargs).call(**kwargs)
25 changes: 25 additions & 0 deletions rocketchat/calls/channels/get_history.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import logging

from rocketchat.calls.base import RocketChatBase

logger = logging.getLogger(__name__)


class GetRoomHistory(RocketChatBase):
endpoint = '/api/v1/channels.history'

def build_endpoint(self, **kwargs):
if kwargs.has_key('oldest'):
return '{endpoint}?roomId={room_id}&oldest={oldest}'.format(
endpoint=self.endpoint,
oldest=kwargs.get('oldest'),
room_id=kwargs.get('room_id')
)
else:
return '{endpoint}?roomId={room_id}'.format(
endpoint=self.endpoint,
room_id=kwargs.get('room_id')
)

def post_response(self, result):
return result

0 comments on commit 439ce36

Please sign in to comment.