From 5d7db6f761c8bceffc76c106628f19f90e4c1e7d Mon Sep 17 00:00:00 2001 From: Chirag Choudhary Date: Tue, 18 Aug 2020 22:25:33 +0530 Subject: [PATCH 1/6] add registrant --- README.md | 2 + .../components/meeting/test_add_registrant.py | 42 +++++++++++++++++++ .../meeting/test_list_registrants.py | 36 ++++++++++++++++ zoomus/components/meeting.py | 10 +++++ 4 files changed, 90 insertions(+) create mode 100644 tests/zoomus/components/meeting/test_add_registrant.py create mode 100644 tests/zoomus/components/meeting/test_list_registrants.py diff --git a/README.md b/README.md index d3e3062..558b43a 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,8 @@ with ZoomClient('API_KEY', 'API_SECRET') as client: * client.meeting.delete(...) * client.meeting.list(...) * client.meeting.update(...) +* client.meeting.add_registrant(...) +* client.meeting.list_registrants(...) * client.report.get_account_report(...) * client.report.get_user_report(...) diff --git a/tests/zoomus/components/meeting/test_add_registrant.py b/tests/zoomus/components/meeting/test_add_registrant.py new file mode 100644 index 0000000..bda2d5f --- /dev/null +++ b/tests/zoomus/components/meeting/test_add_registrant.py @@ -0,0 +1,42 @@ +import datetime +import unittest + +from zoomus import components, util +import responses + + +def suite(): + """Define all the tests of the module.""" + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(AddRegistrantV2TestCase)) + return suite + + +class AddRegistrantV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.meeting.MeetingComponentV2( + base_uri="http://foo.com", + config={ + "api_key": "KEY", + "api_secret": "SECRET", + "version": util.API_VERSION_2, + }, + ) + + @responses.activate + def test_can_add_registrant(self): + responses.add( + responses.POST, "http://foo.com/meetings/ID/registrants", + ) + response = self.component.add_registrant(id="ID", email="EMAIL", last_name="LAST_NAME", first_name="FIRST_NAME") + self.assertEqual( + response.request.body, '{"id": "ID", "email": "TOPIC", "last_name": "LAST_NAME", "first_name": "FIRST_NAME"}' + ) + + def test_requires_meeting_id(self): + with self.assertRaisesRegexp(ValueError, "'id' must be set"): + self.component.add_registrant() + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/tests/zoomus/components/meeting/test_list_registrants.py b/tests/zoomus/components/meeting/test_list_registrants.py new file mode 100644 index 0000000..6d096ba --- /dev/null +++ b/tests/zoomus/components/meeting/test_list_registrants.py @@ -0,0 +1,36 @@ +import unittest + +from zoomus import components, util +import responses + + +def suite(): + """Define all the tests of the module.""" + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(ListRegistrantsV2TestCase)) + return suite + + +class ListRegistrantsV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.meeting.MeetingComponentV2( + base_uri="http://foo.com", + config={ + "api_key": "KEY", + "api_secret": "SECRET", + "version": util.API_VERSION_2, + }, + ) + + @responses.activate + def test_can_list_registrants(self): + responses.add(responses.GET, "http://foo.com/meetings/ID") + self.component.list_registrants(id="ID") + + def test_requires_id(self): + with self.assertRaisesRegexp(ValueError, "'id' must be set"): + self.component.list_registrants() + + +if __name__ == "__main__": + unittest.main() \ No newline at end of file diff --git a/zoomus/components/meeting.py b/zoomus/components/meeting.py index c6f9e81..c6ea17b 100644 --- a/zoomus/components/meeting.py +++ b/zoomus/components/meeting.py @@ -70,3 +70,13 @@ def delete(self, **kwargs): return self.delete_request( "/meetings/{}".format(kwargs.get("id")), params=kwargs ) + + def add_registrant(self, **kwargs): + util.require_keys(kwargs, "id") + return self.post_request( + "/meetings/{}/registrants".format(kwargs.get("id")), data=kwargs + ) + + def list_registrants(self, **kwargs): + util.require_keys(kwargs, "id") + return self.get_request("/meetings/{}/registrants".format(kwargs.get("id")), params=kwargs) From 410994ae3fb29e81e1c50a8381d29a55a97f1df7 Mon Sep 17 00:00:00 2001 From: Chirag Choudhary Date: Fri, 9 Oct 2020 15:31:28 +0530 Subject: [PATCH 2/6] add panelist APIs --- README.md | 3 ++ .../components/webinar/test_add_panelists.py | 42 +++++++++++++++++++ .../webinar/test_delete_panelists.py | 40 ++++++++++++++++++ .../components/webinar/test_list_panelists.py | 23 ++++++++++ zoomus/components/webinar.py | 18 ++++++++ 5 files changed, 126 insertions(+) create mode 100644 tests/zoomus/components/webinar/test_add_panelists.py create mode 100644 tests/zoomus/components/webinar/test_delete_panelists.py create mode 100644 tests/zoomus/components/webinar/test_list_panelists.py diff --git a/README.md b/README.md index d3e3062..9993302 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,9 @@ with ZoomClient('API_KEY', 'API_SECRET') as client: * client.webinar.get(...) * client.webinar.end(...) * client.webinar.register(...) +* client.webinar.add_panelists(...) +* client.webinar.list_panelists(...) +* client.webinar.remove_panelists(...) * client.phone.call_logs(...) * client.phone.calling_plans(...) diff --git a/tests/zoomus/components/webinar/test_add_panelists.py b/tests/zoomus/components/webinar/test_add_panelists.py new file mode 100644 index 0000000..03b1c05 --- /dev/null +++ b/tests/zoomus/components/webinar/test_add_panelists.py @@ -0,0 +1,42 @@ +from datetime import datetime +import unittest + +from zoomus import components +import responses + + +def suite(): + """Define all the tests of the module.""" + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(AddPanelistsV2TestCase)) + return suite + + +class AddPanelistsV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.webinar.WebinarComponentV2( + base_uri="http://foo.com", + config={ + "api_key": "KEY", + "api_secret": "SECRET", + "version": util.API_VERSION_2, + }, + ) + + @responses.activate + def test_can_add_panelists(self): + responses.add( + responses.POST, "http://foo.com/webinar/ID/panelists", + ) + response = self.component.add_panelists(panelists=[{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]) + self.assertEqual( + response.request.body, '{panelists: [{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]}' + ) + + def test_requires_panelists(self): + with self.assertRaisesRegexp(ValueError, "'panelists' must be set"): + self.component.add_panelists() + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/zoomus/components/webinar/test_delete_panelists.py b/tests/zoomus/components/webinar/test_delete_panelists.py new file mode 100644 index 0000000..007d26b --- /dev/null +++ b/tests/zoomus/components/webinar/test_delete_panelists.py @@ -0,0 +1,40 @@ +import unittest + +from zoomus import components, util +import responses + +def suite(): + """Define all the tests of the module.""" + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(DeleteV2TestCase)) + return suite + + +class DeleteV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.meeting.MeetingComponentV2( + base_uri="http://foo.com", + config={ + "api_key": "KEY", + "api_secret": "SECRET", + "version": util.API_VERSION_2, + }, + ) + + @responses.activate + def test_can_delete_panelists(self): + responses.add( + responses.POST, "http://foo.com/webinar/ID/panelists", + ) + response = self.component.delete_panelists(panelists=[{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]) + self.assertEqual( + response.request.body, '{panelists: [{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]}' + ) + + def test_requires_panelists(self): + with self.assertRaisesRegexp(ValueError, "'panelists' must be set"): + self.component.delete_panelists() + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/zoomus/components/webinar/test_list_panelists.py b/tests/zoomus/components/webinar/test_list_panelists.py new file mode 100644 index 0000000..eb9aa2a --- /dev/null +++ b/tests/zoomus/components/webinar/test_list_panelists.py @@ -0,0 +1,23 @@ +from datetime import datetime +import unittest + +from zoomus import components +import responses + + +def suite(): + """Define all the tests of the module.""" + suite = unittest.TestSuite() + suite.addTest(unittest.makeSuite(ListPanelistsV2TestCase)) + return suite + + +class ListPanelistsV2TestCase(unittest.TestCase): + def setUp(self): + self.component = components.webinar.WebinarComponentV2( + base_uri="http://foo.com", config={"api_key": "KEY", "api_secret": "SECRET"} + ) + + +if __name__ == "__main__": + unittest.main() diff --git a/zoomus/components/webinar.py b/zoomus/components/webinar.py index e8eeb8d..ca4317b 100644 --- a/zoomus/components/webinar.py +++ b/zoomus/components/webinar.py @@ -104,3 +104,21 @@ def get_absentees(self, **kwargs): return self.get_request( "/past_webinars/{}/absentees".format(kwargs.get("id")), params=kwargs ) + + def add_panelists(self, **kwargs): + util.require_keys(kwargs, "id") + return self.post_request( + "/webinars/{}/panelists".format(kwargs.get("id")), data=kwargs + ) + + def list_panelists(self, **kwargs): + util.require_keys(kwargs, "id") + return self.get_request( + "/webinars/{}/panelists".format(kwargs.get("id")), params=kwargs + ) + + def remove_panelists(self, **kwargs): + util.require_keys(kwargs, "id") + return self.delete_request( + "/webinars/{}/panelists".format(kwargs.get("id")), params=kwargs + ) From 935e9f59b4586f9a7436b79de6d7606f68c1cfdc Mon Sep 17 00:00:00 2001 From: Chirag Choudhary Date: Fri, 9 Oct 2020 15:32:13 +0530 Subject: [PATCH 3/6] bump up version --- zoomus/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zoomus/__init__.py b/zoomus/__init__.py index 21a8d00..8c63df1 100644 --- a/zoomus/__init__.py +++ b/zoomus/__init__.py @@ -7,4 +7,4 @@ __all__ = ["API_VERSION_1", "API_VERSION_2", "ZoomClient"] -__version__ = "1.1.3" +__version__ = "1.1.4" From fa5805fcc873dc7d9ec5ee0beb7fd88aeb6f8a7b Mon Sep 17 00:00:00 2001 From: Vishnu Date: Fri, 12 Mar 2021 11:11:27 +0530 Subject: [PATCH 4/6] Add poll feature for meeting and webinar --- zoomus/client.py | 12 +++++++ zoomus/components/__init__.py | 2 +- zoomus/components/poll.py | 63 +++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 zoomus/components/poll.py diff --git a/zoomus/client.py b/zoomus/client.py index d08e125..61bb237 100644 --- a/zoomus/client.py +++ b/zoomus/client.py @@ -28,6 +28,8 @@ "webinar": components.webinar.WebinarComponentV2, "recording": components.recording.RecordingComponentV2, "phone": components.phone.PhoneComponentV2, + "webinar_poll": components.poll.WebinarPollComponentV2, + "meeting_poll": components.poll.MeetingsPollComponentV2, }, } @@ -137,3 +139,13 @@ def recording(self): def phone(self): """Get the phone component""" return self.components.get("phone") + + @property + def webinar_poll(self): + """Get the phone component""" + return self.components.get("webinar_poll") + + @property + def meeting_poll(self): + """Get the phone component""" + return self.components.get("meeting_poll") diff --git a/zoomus/components/__init__.py b/zoomus/components/__init__.py index 0a7ef3d..b2f68a3 100644 --- a/zoomus/components/__init__.py +++ b/zoomus/components/__init__.py @@ -2,4 +2,4 @@ from __future__ import absolute_import -from . import meeting, metric, past_meeting, phone, recording, report, user, webinar +from . import meeting, metric, past_meeting, phone, recording, report, user, webinar, poll diff --git a/zoomus/components/poll.py b/zoomus/components/poll.py new file mode 100644 index 0000000..923ed4d --- /dev/null +++ b/zoomus/components/poll.py @@ -0,0 +1,63 @@ +"""Zoom.us REST API Python Client -- Recording component""" +from zoomus import util +from zoomus.components import base + + +class PollComponentV2(base.BaseComponent): + def __init__(self, *args, **kwargs): + util.require_keys(kwargs, "type") + self.type = kwargs.get('type') + super().__init__(*args, **kwargs) + + + def list(self, **kwargs): + util.require_keys(kwargs, "id") + return self.get_request( + f"/{self.type}/{kwargs.get('id')}/polls" + ) + + def create(self, **kwargs): + util.require_keys(kwargs, "id") + util.require_keys(kwargs, "data") + return self.post_request( + f"/{self.type}/{kwargs.get('id')}/polls", + data=kwargs.get('data') + ) + + def get(self, **kwargs): + util.require_keys(kwargs, "id") + util.require_keys(kwargs, "poll_id") + return self.get_request( + f"/{self.type}/{kwargs.get('id')}/polls/{kwargs.get('poll_id')}" + ) + + def update(self, **kwargs): + util.require_keys(kwargs, "id") + util.require_keys(kwargs, "poll_id") + util.require_keys(kwargs, "data") + return self.patch_request( + f"/{self.type}/{kwargs.get('id')}/polls/{kwargs.get('poll_id')}", + data=kwargs.get('data') + ) + + def delete(self, **kwargs): + util.require_keys(kwargs, "id") + util.require_keys(kwargs, "poll_id") + return self.delete_request( + f"/{self.type}/{kwargs.get('id')}/polls/{kwargs.get('poll_id')}" + ) + + class Meta: + abstract = True + + +class WebinarPollComponentV2(PollComponentV2): + def __init__(self, *args, **kwargs): + kwargs['type'] = 'webinars' + super().__init__(*args, **kwargs) + + +class MeetingsPollComponentV2(PollComponentV2): + def __init__(self, *args, **kwargs): + kwargs['type'] = 'meetings' + super().__init__(*args, **kwargs) From ac412e4d81ef6304386ee88d37de60ded5fef6d5 Mon Sep 17 00:00:00 2001 From: Vishnu Date: Sun, 14 Mar 2021 15:09:30 +0530 Subject: [PATCH 5/6] Implement feedback --- zoomus/__init__.py | 2 +- zoomus/components/__init__.py | 2 +- zoomus/components/poll.py | 21 +++++++++++++++------ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/zoomus/__init__.py b/zoomus/__init__.py index 8c63df1..21a8d00 100644 --- a/zoomus/__init__.py +++ b/zoomus/__init__.py @@ -7,4 +7,4 @@ __all__ = ["API_VERSION_1", "API_VERSION_2", "ZoomClient"] -__version__ = "1.1.4" +__version__ = "1.1.3" diff --git a/zoomus/components/__init__.py b/zoomus/components/__init__.py index b2f68a3..c6ba80c 100644 --- a/zoomus/components/__init__.py +++ b/zoomus/components/__init__.py @@ -2,4 +2,4 @@ from __future__ import absolute_import -from . import meeting, metric, past_meeting, phone, recording, report, user, webinar, poll +from . import meeting, metric, past_meeting, phone, poll, recording, report, user, webinar diff --git a/zoomus/components/poll.py b/zoomus/components/poll.py index 923ed4d..01ba762 100644 --- a/zoomus/components/poll.py +++ b/zoomus/components/poll.py @@ -9,18 +9,21 @@ def __init__(self, *args, **kwargs): self.type = kwargs.get('type') super().__init__(*args, **kwargs) - def list(self, **kwargs): util.require_keys(kwargs, "id") return self.get_request( - f"/{self.type}/{kwargs.get('id')}/polls" + "/{}/{}/polls".format( + self.type, kwargs.get("id") + ) ) def create(self, **kwargs): util.require_keys(kwargs, "id") util.require_keys(kwargs, "data") return self.post_request( - f"/{self.type}/{kwargs.get('id')}/polls", + "/{}/{}/polls".format( + self.type, kwargs.get('id') + ), data=kwargs.get('data') ) @@ -28,7 +31,9 @@ def get(self, **kwargs): util.require_keys(kwargs, "id") util.require_keys(kwargs, "poll_id") return self.get_request( - f"/{self.type}/{kwargs.get('id')}/polls/{kwargs.get('poll_id')}" + "/{}/{kwargs.get('id')}/polls/{}".format( + self.type, kwargs.get('poll_id') + ) ) def update(self, **kwargs): @@ -36,7 +41,9 @@ def update(self, **kwargs): util.require_keys(kwargs, "poll_id") util.require_keys(kwargs, "data") return self.patch_request( - f"/{self.type}/{kwargs.get('id')}/polls/{kwargs.get('poll_id')}", + "/{}/{kwargs.get('id')}/polls/{}".format( + self.type, kwargs.get('poll_id') + ), data=kwargs.get('data') ) @@ -44,7 +51,9 @@ def delete(self, **kwargs): util.require_keys(kwargs, "id") util.require_keys(kwargs, "poll_id") return self.delete_request( - f"/{self.type}/{kwargs.get('id')}/polls/{kwargs.get('poll_id')}" + "/{}/{kwargs.get('id')}/polls/{}".format( + self.type, kwargs.get('poll_id') + ) ) class Meta: From 920448a1af60f346e387b0243bbc68e1a76eebdd Mon Sep 17 00:00:00 2001 From: Vishnu Date: Mon, 15 Mar 2021 10:26:36 +0530 Subject: [PATCH 6/6] add content type on put request --- zoomus/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/zoomus/util.py b/zoomus/util.py index 6cf791b..0e7022e 100644 --- a/zoomus/util.py +++ b/zoomus/util.py @@ -182,7 +182,10 @@ def put_request(self, endpoint, params=None, data=None, headers=None, cookies=No if data and not is_str_type(data): data = json.dumps(data) if headers is None and self.config.get("version") == API_VERSION_2: - headers = {"Authorization": "Bearer {}".format(self.config.get("token"))} + headers = { + "Authorization": "Bearer {}".format(self.config.get("token")), + "Content-Type": "application/json", + } return requests.put( self.url_for(endpoint), params=params,