Skip to content

Commit da7d090

Browse files
Merge pull request #44 from sshpilevsky-sugarcrm/CAS-561
CAS-561: Add support of chats
2 parents 9bb200b + 7c039b0 commit da7d090

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

office365_api/v2/client.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
from .factories.user_factory import UserServicesFactory
5-
from .services import BatchService, SubscriptionService
5+
from .services import BatchService, ChatService, SubscriptionService
66

77

88
class MicrosoftGraphClient(object):
@@ -13,6 +13,7 @@ def __init__(self, session):
1313
self.users = UserServicesFactory(self)
1414
self.me = self.users('me')
1515
self.subscription = SubscriptionService(self, '')
16+
self.chats = ChatService(self, '')
1617

1718
def new_batch_request(self, beta=True):
1819
return BatchService(client=self, beta=beta)

office365_api/v2/services/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from .batch import BatchService
55
from .calendar import CalendarService
66
from .calendar_view import CalendarViewService
7+
from .chat import ChatService
78
from .contact import ContactService
89
from .contact_folder import ContactFolderService
910
from .event import EventService
@@ -25,6 +26,7 @@
2526
"BatchService",
2627
"CalendarService",
2728
"CalendarViewService",
29+
"ChatService",
2830
"ContactService",
2931
"ContactFolderService",
3032
"EventService",

office365_api/v2/services/chat.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import urllib.parse
2+
from typing import Any, Dict, Optional, Tuple
3+
4+
from .base import BaseService
5+
6+
7+
class ChatService(BaseService):
8+
base_path = 'chats'
9+
10+
def messages(self, chat_id: str, max_entries: int = 50) -> Tuple[Dict[str, Any], Optional[str]]:
11+
path = f'{self.base_path}/{urllib.parse.quote(chat_id, safe="")}/messages'
12+
query_params: Dict[str, Any] = {'$top': max_entries}
13+
resp = self.execute_request('get', path, query_params=query_params)
14+
next_link = resp.get('@odata.nextLink')
15+
return resp, next_link

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from setuptools import find_packages, setup
33

44
setup(name='office365-rest-client',
5-
version='3.5.2',
6-
description='Python api wrapper for Office365 API v3.5.2',
5+
version='3.5.3',
6+
description='Python api wrapper for Office365 API v3.5.3',
77
author='SugarCRM',
88
packages=find_packages(),
99
zip_safe=False)

0 commit comments

Comments
 (0)