Skip to content
Open

Polls #179

Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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(...)
Expand All @@ -102,6 +104,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(...)
Expand Down
42 changes: 42 additions & 0 deletions tests/zoomus/components/meeting/test_add_registrant.py
Original file line number Diff line number Diff line change
@@ -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()
36 changes: 36 additions & 0 deletions tests/zoomus/components/meeting/test_list_registrants.py
Original file line number Diff line number Diff line change
@@ -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()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you run black to check for formatting? Looks like some files are missing a newline at the end.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

42 changes: 42 additions & 0 deletions tests/zoomus/components/webinar/test_add_panelists.py
Original file line number Diff line number Diff line change
@@ -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"}])

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make this a more human readable email? Maybemary@test.com?

self.assertEqual(
response.request.body, '{panelists: [{"name": "Mary", "email": "maryjkdfdsgfshdgf@jdfdkjdglfk.jkfgdj"}]}'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above

)

def test_requires_panelists(self):
with self.assertRaisesRegexp(ValueError, "'panelists' must be set"):
self.component.add_panelists()


if __name__ == "__main__":
unittest.main()
40 changes: 40 additions & 0 deletions tests/zoomus/components/webinar/test_delete_panelists.py
Original file line number Diff line number Diff line change
@@ -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"}]}'

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous comment regarding email

)

def test_requires_panelists(self):
with self.assertRaisesRegexp(ValueError, "'panelists' must be set"):
self.component.delete_panelists()


if __name__ == "__main__":
unittest.main()
23 changes: 23 additions & 0 deletions tests/zoomus/components/webinar/test_list_panelists.py
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion zoomus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@


__all__ = ["API_VERSION_1", "API_VERSION_2", "ZoomClient"]
__version__ = "1.1.3"
__version__ = "1.1.4"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert this change and leave it as 1.1.3 -- I'll update it to the appropriate version when I cut the next release (which likely will be 1.1.6).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure Did it

12 changes: 12 additions & 0 deletions zoomus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
}

Expand Down Expand Up @@ -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")
2 changes: 1 addition & 1 deletion zoomus/components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add the poll in the correct alphabetical order? I.e. after phone. Thanks!

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure! Did the same

10 changes: 10 additions & 0 deletions zoomus/components/meeting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
63 changes: 63 additions & 0 deletions zoomus/components/poll.py
Original file line number Diff line number Diff line change
@@ -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"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like in some cases you are using f"...." and in others "...".format(). Since the rest of the library uses the "...".format() syntax, can you please switch it to that for consistency's sake?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I have changed the f"...."and in this "...".format()

)

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)
18 changes: 18 additions & 0 deletions zoomus/components/webinar.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
)