The third use case in the Eventbrite business scenario is used for managing attendees. This page describes the related tasks and the operations you use in the Eventbrite connector and the other ESB connectors.
Overview
The flow for managing attendees is illustrated in the following diagram. The ESB connectors for GoToWebinar will be used to connect to each service.
...
- Retrieve event attendees from the Eventbrite API for selected events using the eventAttendees operation.
- Create Registrants in the GoToWebinar API using the createRegistrant operation.
Eventbrite operations
eventAttendees
GoToWebinar operations
Samples
Code Block | ||||
---|---|---|---|---|
| ||||
<?xml version="1.0" encoding="UTF-8"?> <proxy xmlns="http://ws.apache.org/ns/synapse" name="eventbrite_retrieveAttendeesAndCreateRegistrants" transports="https,http" statistics="disable" trace="disable" startOnLoad="true"> <target> <inSequence onError="faultHandlerSeq"> <!-- GoToWebinar Properties --> <property name="gotowebinar.apiUrl" expression="json-eval($.gotowebinarApiUrl)"/> <property name="gotowebinar.accessToken" expression="json-eval($.gotowebinarAccessToken)"/> <property name="gotowebinar.organizerKey" expression="json-eval($.gotowebinarOrganizerKey)"/> <!-- Eventbrite Properties --> <property name="eventbrite.apiUrl" expression="json-eval($.eventbriteApiUrl)" /> <property name="eventbrite.accessToken" expression="json-eval($.eventbriteAccessToken)" /> <!-- Operation Properties --> <property name="eventbrite.eventCount" expression="count(//events)" scope="operation" /> <property name="eventbrite.eventIndex" value="0" scope="operation" /> <property name="eventbrite.attendeesIndex" value="0" scope="operation" /> <property name="eventbrite.attendeesCount" value="0" scope="operation" /> <!-- FOR EACH Event: BEGIN --> <iterate continueParent="true" id="events" expression="//events" sequential="true"> <target> <sequence> <property name="eventbrite.eventId" expression="//events/eventId/text()"/> <property name="gotowebinar.webinarKey" expression="//events/webinarKey/text()"/> <property name="event.idObject" expression="fn:concat('event_id:',get-property('eventbrite.eventId'),',webinar_key:',get-property('gotowebinar.webinarKey'))"/> <!-- Retrieve event attendees. --> <eventbrite.init> <apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl> <accessToken>{$ctx:eventbrite.accessToken}</accessToken> </eventbrite.init> <eventbrite.eventAttendees> <EventID>{$ctx:eventbrite.eventId}</EventID> <status>attending</status> </eventbrite.eventAttendees> <property name="eventbrite.noOfAttendees" expression="json-eval($.pagination.object_count)"/> <property name="eventbrite.eventIndex" expression="get-property('operation','eventbrite.eventIndex') + 1" scope="operation" /> <!-- Remove unused headers by calling a sequence template. --> <sequence key="removeResponseHeaders" /> <!-- Check if there are any attendees for the event. --> <filter xpath="get-property('eventbrite.noOfAttendees') = 0"> <then> <property name="status" value="Skipped"/> <property name="message" value="No attendees for the event."/> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:event.idObject}"/> <with-param name="status" value="{$ctx:status}"/> <with-param name="message" value="{$ctx:message}"/> </call-template> </then> <else> <property name="eventbrite.attendeesCount" expression="get-property('operation','eventbrite.attendeesCount') + get-property('eventbrite.noOfAttendees')" scope="operation"/> <!-- FOR EACH Attendee: BEGIN --> <iterate continueParent="true" id="attendees" expression="//attendees" sequential="true"> <target> <sequence> <property name="eventbrite.attendeeId" expression="json-eval($.attendees.id)"/> <property name="eventbrite.isDuplicate" expression="(fn:contains(get-property('eventbrite.attendeeId'),'-'))"/> <!-- If a duplicate attendee is in Eventbrite, the duplicate will be ignored. --> <filter source="get-property('eventbrite.isDuplicate')" regex="false"> <then> <property name="gotowebinar.email" expression="json-eval($.attendees.profile.email)"/> <property name="gotowebinar.firstName" expression="json-eval($.attendees.profile.first_name)"/> <property name="gotowebinar.lastName" expression="json-eval($.attendees.profile.last_name)"/> <property name="gotowebinar.idObject" expression="fn:concat('event_id:',get-property('eventbrite.eventId'),',webinar_key:',get-property('gotowebinar.webinarKey'),',user_email:',get-property('gotowebinar.email'))"/> <!-- Create registrants in GoToWebinar. --> <gotowebinar.init> <apiUrl>{$ctx:gotowebinar.apiUrl}</apiUrl> <accessToken>{$ctx:gotowebinar.accessToken}</accessToken> <organizerKey>{$ctx:gotowebinar.organizerKey}</organizerKey> </gotowebinar.init> <gotowebinar.createRegistrant> <lastName>{$ctx:gotowebinar.lastName}</lastName> <firstName>{$ctx:gotowebinar.firstName}</firstName> <email>{$ctx:gotowebinar.email}</email> <webinarKey>{$ctx:gotowebinar.webinarKey}</webinarKey> </gotowebinar.createRegistrant> <property name="gotowebinar.registrantKey" expression="json-eval($.registrantKey)"/> <!-- Check the status code to create the response. --> <switch source="$axis2:HTTP_SC"> <case regex="201"> <property name="status" value="Success"/> <property name="message" expression="fn:concat('User has been registered to Webinar with the Registration key [',get-property('gotowebinar.registrantKey'),']')"/> </case> <case regex="409"> <property name="status" value="Skipped"/> <property name="message" expression="fn:concat('User has been already added to this Webinar with Registration key [',get-property('gotowebinar.registrantKey'),']')"/> </case> <case regex="500"> <property name="status" value="Error"/> <property name="message" value="GoToWebinar - Internal server error."/> </case> <default> <property name="status" value="Error"/> <property name="message" expression="json-eval($.)"/> </default> </switch> <!-- Remove unused headers by calling a sequence template. --> <sequence key="removeResponseHeaders" /> <call-template target="responseHandlerTemplate"> <with-param name="id" value="{$ctx:gotowebinar.idObject}"/> <with-param name="status" value="{$ctx:status}"/> <with-param name="message" value="{$ctx:message}"/> </call-template> </then> </filter> <property name="eventbrite.attendeesIndex" expression="get-property('operation','eventbrite.attendeesIndex') + 1" scope="operation"/> </sequence> </target> </iterate> <!-- FOR EACH Attendee: END --> </else> </filter> </sequence> </target> </iterate> <!-- FOR EACH Event: END --> <filter xpath="(get-property('operation','eventbrite.eventCount') = get-property('operation','eventbrite.eventIndex')) and (get-property('operation','eventbrite.attendeesCount') = get-property('operation','eventbrite.attendeesIndex'))"> <then> <loopback /> </then> </filter> </inSequence> <outSequence> <payloadFactory media-type="json"> <format>{ "Response":{ "activity":"Eventbrite-retreiveAttendeesAndCreateRegistrants", "activityResponse":[$1] } }</format> <args> <arg expression="get-property('operation','responseString')" /> </args> </payloadFactory> <property name="messageType" value="application/json" scope="axis2" /> <send /> </outSequence> </target> <description /> </proxy> |
...