diff --git a/microsoftgraph/calendar.py b/microsoftgraph/calendar.py index c6c16b7..a583576 100644 --- a/microsoftgraph/calendar.py +++ b/microsoftgraph/calendar.py @@ -60,6 +60,9 @@ def create_event( location: str, calendar_id: str = None, content_type: str = "HTML", + attendees: list = None, + is_online_meeting: bool = False, + online_meeting_provider: str = 'teamsForBusiness', **kwargs, ) -> Response: """Create an event in the user's default calendar or specified calendar. @@ -102,7 +105,15 @@ def create_event( "timeZone": end_timezone, }, "location": {"displayName": location}, + "isOnlineMeeting": is_online_meeting, } + + if is_online_meeting: + body["onlineMeetingProvider"] = online_meeting_provider + + if attendees: + body["attendees"] = attendees + body.update(kwargs) url = "me/calendars/{}/events".format(calendar_id) if calendar_id is not None else "me/events" return self._client._post(self._client.base_url + url, json=body) diff --git a/microsoftgraph/client.py b/microsoftgraph/client.py index e42dbd8..ee43957 100644 --- a/microsoftgraph/client.py +++ b/microsoftgraph/client.py @@ -248,9 +248,12 @@ def _request(self, method, url, headers=None, **kwargs) -> Response: _headers = { "Accept": "application/json", } - _headers["Authorization"] = "Bearer " + self.token["access_token"] + if headers: _headers.update(headers) + + _headers["Authorization"] = "Bearer " + self.token["access_token"] + if self.requests_hooks: kwargs.update({"hooks": self.requests_hooks}) if "Content-Type" not in _headers: @@ -260,7 +263,7 @@ def _request(self, method, url, headers=None, **kwargs) -> Response: def _parse(self, response) -> Response: status_code = response.status_code r = Response(original=response) - if status_code in (200, 201, 202, 204, 206): + if status_code < 299: return r elif status_code == 400: raise exceptions.BadRequest(r.data) diff --git a/microsoftgraph/mail.py b/microsoftgraph/mail.py index c8a43b6..ffceb4c 100644 --- a/microsoftgraph/mail.py +++ b/microsoftgraph/mail.py @@ -29,7 +29,7 @@ def list_messages(self, folder_id: str = None, params: dict = None) -> Response: Returns: Response: Microsoft Graph Response. """ - url = "me/mailFolders/{id}/messages".format(folder_id) if folder_id else "me/messages" + url = "me/mailFolders/{}/messages".format(folder_id) if folder_id else "me/messages" return self._client._get(self._client.base_url + url, params=params) @token_required diff --git a/microsoftgraph/webhooks.py b/microsoftgraph/webhooks.py index f19b12b..b669c50 100644 --- a/microsoftgraph/webhooks.py +++ b/microsoftgraph/webhooks.py @@ -24,6 +24,7 @@ def create_subscription( resource: str, expiration_datetime: datetime, client_state: str = None, + **kwargs, ) -> Response: """Creates a subscription to start receiving notifications for a resource. @@ -50,6 +51,7 @@ def create_subscription( "expirationDateTime": expiration_datetime, "clientState": client_state, } + data.update(kwargs) return self._client._post(self._client.base_url + "subscriptions", json=data) @token_required diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..2d69aac --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,18 @@ +[tool.poetry] +name = "microsoftgraph-python" +version = "1.1.8.1" +description = "API wrapper for Microsoft Graph written in Python" +authors = ["Gearplug Team "] +license = "MIT" +readme = "README.md" +packages = [{include = "microsoftgraph"}] + +[tool.poetry.dependencies] +python = "^3.7" +requests = "^2.26.0" + + +[build-system] +requires = ["poetry-core"] +build-backend = "poetry.core.masonry.api" + diff --git a/setup.py b/setup.py deleted file mode 100644 index c114174..0000000 --- a/setup.py +++ /dev/null @@ -1,24 +0,0 @@ -import os -from setuptools import setup - - -def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() - - -setup( - name="microsoftgraph-python", - version="1.1.3", - description="API wrapper for Microsoft Graph written in Python", - long_description=read("README.md"), - url="https://github.com/GearPlug/microsoftgraph-python", - long_description_content_type="text/markdown", - author="Miguel Ferrer, Nerio Rincon, Yordy Gelvez", - author_email="ingferrermiguel@gmail.com", - license="MIT", - packages=["microsoftgraph"], - install_requires=[ - "requests", - ], - zip_safe=False, -)