 # @param [string] id
 # @param [function] onError
 # @param [function] onSuccess
-getEvents = (eventQuery) ->
-	mu.getEvents
-		event_id: eventQuery.ids
+# @private
+_getEvents = (eventQuery) ->
+	if eventQuery.ids?
+		muQuery = event_id: eventQuery.ids
+	if eventQuery.name?
+		muQuery = group_urlname: eventQuery.name
+
+	mu.getEvents(
+		muQuery
 		(error, events) ->
 			if error
 				eventQuery.onError error
 			else
-				eventQuery.onSuccess events.results
+				eventQuery.onSuccess events.results)
 
 
 # Get Meetup group by group 'urlname'


# Parse a Meetup event JSON object
# @param [object] event
parseEvent = (event) ->
	title: event.name
	source: event.event_url
	date: new Date(event.time)

# @option query [object] event
# @option query [function] onSuccess
# @option query [function] onError
# @private
_handleEvent = (query) ->
	id = (muRegex.exec query.url)[1]
	_getEvents
		ids: [id]
		onError: (error) ->
			query.onError
				error: error
				module: 'meetup'
		onSuccess: (muEvents) ->
			event = _parseEvent muEvents[0]
			db.set
				events: [event]
				onSuccess: query.onSuccess
				onError: query.onError


# Handle Meetup group events
# @param [object] query
# @option query [object] event
# @option query [function] onSuccess
# @option query [function] onError
# @private
_handleGroupEvents = (query) ->
	_getEvents
		name: query.name
		onError: (error) ->
			query.onError
				error: error
				module: 'meetup'
		onSuccess: (muEvents) ->
			events = []
			for event in muEvents
				events.push _parseEvent event
			db.set
				events: events
				onSuccess: query.onSuccess
				onError: query.onError

