|
11 | 11 | from pythonkc_meetups.exceptions import PythonKCMeetupsNotJson |
12 | 12 | from pythonkc_meetups.exceptions import PythonKCMeetupsRateLimitExceeded |
13 | 13 | from pythonkc_meetups.parsers import parse_event |
| 14 | +from pythonkc_meetups.parsers import parse_member_from_rsvp |
14 | 15 | import httplib2 |
15 | 16 | import json |
16 | 17 | import mimeparse |
17 | 18 | import urllib |
18 | 19 |
|
19 | 20 |
|
20 | | -EVENTS_URL = 'https://api.meetup.com/2/events.json' |
| 21 | +MEETUP_API_HOST = 'https://api.meetup.com' |
| 22 | +EVENTS_URL = MEETUP_API_HOST + '/2/events.json' |
| 23 | +RSVPS_URL = MEETUP_API_HOST + '/2/rsvps.json' |
21 | 24 | GROUP_URLNAME = 'pythonkc' |
22 | 25 |
|
23 | 26 |
|
@@ -101,6 +104,35 @@ def get_past_events(self): |
101 | 104 | events = data['results'] |
102 | 105 | return [parse_event(event) for event in events] |
103 | 106 |
|
| 107 | + def get_event_attendees(self, event_id): |
| 108 | + """ |
| 109 | + Get the attendees of the identified event. |
| 110 | +
|
| 111 | + Parameters |
| 112 | + ---------- |
| 113 | + event_id |
| 114 | + ID of the event to get attendees for. |
| 115 | +
|
| 116 | + Returns |
| 117 | + ------- |
| 118 | + List of ``pythonkc_meetups.types.MeetupMember``. |
| 119 | +
|
| 120 | + Exceptions |
| 121 | + ---------- |
| 122 | + * PythonKCMeetupsBadJson |
| 123 | + * PythonKCMeetupsBadResponse |
| 124 | + * PythonKCMeetupsMeetupDown |
| 125 | + * PythonKCMeetupsNotJson |
| 126 | + * PythonKCMeetupsRateLimitExceeded |
| 127 | +
|
| 128 | + """ |
| 129 | + query = urllib.urlencode({'key': self._api_key, |
| 130 | + 'event_id': event_id}) |
| 131 | + url = '{0}?{1}'.format(RSVPS_URL, query) |
| 132 | + data = self._http_get_json(url) |
| 133 | + rsvps = data['results'] |
| 134 | + return [parse_member_from_rsvp(rsvp) for rsvp in rsvps] |
| 135 | + |
104 | 136 | def _http_get_json(self, url): |
105 | 137 | """ |
106 | 138 | Make an HTTP GET request to the specified URL, check that it returned a |
|
0 commit comments