Skip to content

Commit ddb23bb

Browse files
author
Steven Cummings
committed
Added event attendees
1 parent 116a8bf commit ddb23bb

File tree

6 files changed

+107
-2
lines changed

6 files changed

+107
-2
lines changed

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,8 @@ Example Usage
2929
u'Monthly Meetup: Google App Engine'
3030
>>> last_meetup.time
3131
datetime.datetime(2011, 7, 9, 14, 0, tzinfo=tzoffset(None, -18000))
32+
>>> an_attendee = meetups.get_event_attendees(last_meetup.id)[0]
33+
>>> an_attendee.name
34+
u'Steven Cummings'
35+
>>> an_attendee.photo.thumb_url
36+
u'http://photos1.meetupstatic.com/photos/member/2/e/f/5/thumb_16212021.jpeg'

docs/changelog.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ Changelog
44
Releases
55
--------
66

7+
* `Release 0.0.2 - TBD`_
78
* `Release 0.0.1 - August 7, 2011`_
89

10+
Release 0.0.2 - TBD
11+
-------------------
12+
13+
* Added ``PythonKCMeetups.get_event_attendees``
14+
915
Release 0.0.1 - August 7, 2011
1016
------------------------------
1117

pythonkc_meetups/client.py

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,16 @@
1111
from pythonkc_meetups.exceptions import PythonKCMeetupsNotJson
1212
from pythonkc_meetups.exceptions import PythonKCMeetupsRateLimitExceeded
1313
from pythonkc_meetups.parsers import parse_event
14+
from pythonkc_meetups.parsers import parse_member_from_rsvp
1415
import httplib2
1516
import json
1617
import mimeparse
1718
import urllib
1819

1920

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'
2124
GROUP_URLNAME = 'pythonkc'
2225

2326

@@ -101,6 +104,35 @@ def get_past_events(self):
101104
events = data['results']
102105
return [parse_event(event) for event in events]
103106

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+
104136
def _http_get_json(self, url):
105137
"""
106138
Make an HTTP GET request to the specified URL, check that it returned a

pythonkc_meetups/parsers.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
from dateutil.tz import tzoffset
1010
from dateutil.tz import tzutc
1111
from pythonkc_meetups.types import MeetupEvent
12+
from pythonkc_meetups.types import MeetupMember
13+
from pythonkc_meetups.types import MeetupMemberPhoto
1214
from pythonkc_meetups.types import MeetupVenue
1315
import datetime
1416

@@ -63,6 +65,41 @@ def parse_venue(data):
6365
)
6466

6567

68+
def parse_member_from_rsvp(data):
69+
"""
70+
Parse a ``MeetupMember`` from the given RSVP response data.
71+
72+
Returns
73+
-------
74+
A ``pythonkc_meetups.types.MeetupMember``.
75+
76+
"""
77+
return MeetupMember(
78+
id=data['member'].get('member_id', None),
79+
name=data['member'].get('name', None),
80+
photo=parse_member_photo(data.get('member_photo', None))
81+
)
82+
83+
84+
def parse_member_photo(data):
85+
"""
86+
Parse a ``MeetupMemberPhoto`` from the given response data.
87+
88+
Returns
89+
-------
90+
A `pythonkc_meetups.types.`MeetupMemberPhoto`` if non-empty data is given,
91+
otherwise ``None``.
92+
93+
"""
94+
if data:
95+
return MeetupMemberPhoto(
96+
id=data.get('id', None),
97+
url=data.get('photo_link', None),
98+
highres_url=data.get('highres_link', None),
99+
thumb_url=data.get('thumb_link', None)
100+
)
101+
102+
66103
def parse_datetime(utc_timestamp_ms, utc_offset_ms):
67104
"""
68105
Create a timezone-aware ``datetime.datetime`` from the given UTC timestamp

pythonkc_meetups/types.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@
5656
lon
5757
Geographical longitude.
5858
59+
MeetupMember
60+
------------
61+
id
62+
Meetup.com ID for the member.
63+
name
64+
Full name (first & last) of the member.
65+
photo
66+
A ``MeetupMemberPhoto`` containing URLs to this member's photo resources.
67+
68+
MeetupMemberPhoto
69+
-----------------
70+
id
71+
Meetup.com ID for the member photo.
72+
url
73+
URL of the member photo resource.
74+
highres_url
75+
URL of the high-resolution version of the member photo.
76+
thumb_url
77+
URL of the thumbnail version of the member photo.
78+
5979
"""
6080

6181

@@ -69,3 +89,8 @@
6989
MeetupVenue = namedtuple('MeetupVenue',
7090
['id', 'name', 'address_1', 'address_2', 'address_3', 'city', 'state',
7191
'zip', 'country', 'lat', 'lon'])
92+
93+
MeetupMember = namedtuple('MeetupMember', ['id', 'name', 'photo'])
94+
95+
MeetupMemberPhoto = namedtuple('MeetupMemberPhoto',
96+
['id', 'url', 'highres_url', 'thumb_url'])

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
setup(
99
name='pythonkc-meetups',
10-
version='0.0.1',
10+
version='0.0.2',
1111
description='Provides PythonKC Meetup.com events.',
1212
license='MIT',
1313
url='https://github.com/estebistec/pythonkc-meetups',

0 commit comments

Comments
 (0)