This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, visit https://wso2.com/documentation/.

Initiating Event in Eventbrite

The first use case in the Eventbrite business scenario is used for initiating an event. This page describes the relevant tasks and the operations you use in the Eventbrite connector and the other ESB connectors.

Overview

The flow for initiating an event is illustrated in the following diagram. The ESB connectors for GoToWebinar will be used to connect to each service. 

  1. In this use case, events and tickets will be created. Webinars are created in GoToWebinar as an offline process of the ESB.

  2. Retrieve selected Webinars from the GoToWebinar API using the getWebinarById operation and create events in the Eventbrite API using the createEvent operation.
  3. Create tickets in the Eventbrite API for the above created events using the createTicketClass operation.
  4. Publish the above events in the Eventbrite API using the publishEvent operation.
GoToWebinar operations
Eventbrite operations

Samples

Sample Template for Creating Eventbrite Events and Event Tickets, and Publishing Events
<?xml version="1.0" encoding="UTF-8"?>
<!-- This template is responsible for creating Eventbrite Events and Event Tickets and publishing Events. -->
<template xmlns="http://ws.apache.org/ns/synapse"
          name="createEventAndPublish">
		<parameter name="eventbrite.apiUrl" description="URL of the eventbrite API."/>
		<parameter name="eventbrite.accessToken" description="Access token to eventbrite API."/>
		<parameter name="eventbrite.currency" description="Currency code for the event ticket."/>
		<parameter name="eventbrite.venueId" description="Event venue id."/>
		<parameter name="eventbrite.ticketQty" description="Event ticket quantity."/>
		<parameter name="eventbrite.price" description="Event ticket price."/>	
		<parameter name="event.timezone" description="Event time zone (Olson format)."/>
		<parameter name="event.endTime" description="End time of the event."/>
		<parameter name="event.startTime" description="Start time of the event."/>
		<parameter name="event.name" description="Name of the event."/>
		<parameter name="event.description" description="Description about the event."/>
		<parameter name="event.idObject" description="Id as Key value pair(s) for response handler (Ex. id1:value1,id2:value2)."/>
		
   
	<sequence>
   
		<!-- Eventbrite Properties -->
		<property name="eventbrite.apiUrl" expression="$func:eventbrite.apiUrl"/>
		<property name="eventbrite.accessToken" expression="$func:eventbrite.accessToken"/>
		<property name="eventbrite.currency" expression="$func:eventbrite.currency"/>
		<property name="eventbrite.venueId" expression="$func:eventbrite.venueId"/>
		<property name="eventbrite.ticketQty" expression="$func:eventbrite.ticketQty"/>
		<property name="eventbrite.price" expression="$func:eventbrite.price"/>
        <property name="eventbrite.onlineEvent" value="false"/>
		<property name="eventbrite.isFree" value="false"/>
		
		<!-- Common Properties -->
		<property name="event.timezone" expression="$func:event.timezone"/>
		<property name="event.endTime" expression="$func:event.endTime"/>
		<property name="event.startTime" expression="$func:event.startTime"/>
		<property name="event.name" expression="$func:event.name"/>
		<property name="event.description" expression="$func:event.description"/>
		<property name="event.idObject" expression="$func:event.idObject"/>
		
		<!-- Operation status flags -->
		<property name="eventbrite.isSuccess" value="false"/>
		
        
		<!-- Process Eventbrite operations, only if Eventbrite accessToken is provided. -->
		<filter source="boolean(get-property('eventbrite.accessToken'))" regex="true">
			<then>
				<filter source="boolean(get-property('eventbrite.venueId'))" regex="false">
					<then>
						<property name="eventbrite.onlineEvent" value="true"/>
					</then>
				</filter>
				
				<!-- Call the Eventbrite connector createEvent method. -->
				<eventbrite.init>
					<accessToken>{$ctx:eventbrite.accessToken}</accessToken>
					<apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl>
				</eventbrite.init>
				<eventbrite.createEvent>
					<startTimezone>{$ctx:event.timezone}</startTimezone>
					<endTimezone>{$ctx:event.timezone}</endTimezone>
					<endTime>{$ctx:event.endTime}</endTime>
					<currency>{$ctx:eventbrite.currency}</currency>
					<startTime>{$ctx:event.startTime}</startTime>
					<name>{$ctx:event.name}</name>
					<venueId>{$ctx:eventbrite.venueId}</venueId>
					<description>{$ctx:event.description}</description>
					<onlineEvent>{$ctx:eventbrite.onlineEvent}</onlineEvent>
				</eventbrite.createEvent> 
				<sequence key="removeResponseHeaders" />
						
				<property name="eventbriteEventId" expression="json-eval($.id)" />
				
				<filter source="boolean(get-property('eventbriteEventId'))" regex="false">
					<then>
						<property name="status" value="Error" />
						<property name="message" expression="json-eval($.)" />
					</then>
					<else>
						<property name="status" value="Success" />
						<property name="message" expression="fn:concat('Event has been created successfully with the Event Id ',get-property('eventbriteEventId'),' .')" />
					</else>
				</filter>
				<call-template target="responseHandlerTemplate">
					<with-param name="id" value="{$ctx:event.idObject}" />
					<with-param name="activity" value="eventbrite_createEvent" />
					<with-param name="status" value="{$ctx:status}" />
					<with-param name="message" value="{$ctx:message}" />
				</call-template>
				
		
						
				<!-- Create Event Ticket, only if the Event is created. -->
				<filter source="boolean(get-property('eventbriteEventId'))" regex="true">
					<then>
						<filter source="boolean(get-property('eventbrite.price'))" regex="false">
							<then>
								<property name="eventbrite.isFree" value="true"/>
								<property name="eventbrite.currency" value=" "/>
							</then>
						</filter>
						<eventbrite.init>
							<accessToken>{$ctx:eventbrite.accessToken}</accessToken>
							<apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl>
						</eventbrite.init>
						<eventbrite.createTicketClass>
							<eventId>{$ctx:eventbriteEventId}</eventId>
							<className>{$ctx:event.name}</className>
							<classDescription>{$ctx:event.name}</classDescription>
							<quantityTotal>{$ctx:eventbrite.ticketQty}</quantityTotal>
							<costCurrency>{$ctx:eventbrite.currency}</costCurrency>
							<costValue>{$ctx:eventbrite.price}</costValue>
							<isFree>{$ctx:eventbrite.isFree}</isFree>
						</eventbrite.createTicketClass>
						
						<!-- Remove custom headers from the Eventbrite response. -->
						
						<sequence key="removeResponseHeaders" />
						
						<property name="eventbriteTicketId" expression="json-eval($.id)" />
						
						<filter source="boolean(get-property('eventbriteTicketId'))" regex="false">
							<then>
								<property name="status" value="Error" />
								<property name="message" expression="json-eval($.)" />
							</then>
							<else>
								<property name="status" value="Success" />
								<property name="message" expression="fn:concat('Ticket has been created successfully with the Ticket Id ',get-property('eventbriteTicketId'),' .')" />
							</else>
						</filter>
						
						<call-template target="responseHandlerTemplate">
							<with-param name="id" value="{$ctx:event.idObject}" />
							<with-param name="activity" value="eventbrite_createEventTicket" />
							<with-param name="status" value="{$ctx:status}" />
							<with-param name="message" value="{$ctx:message}" />
						</call-template>
						
						
						<!-- Publish the Event, only if the Event Ticket is created. -->
						<filter source="boolean(get-property('eventbriteTicketId'))" regex="true">
							<then>
								<eventbrite.init>
									<accessToken>{$ctx:eventbrite.accessToken}</accessToken>
									<apiUrl>{$ctx:eventbrite.apiUrl}</apiUrl>
								</eventbrite.init>
								<eventbrite.publishEvent>
									<eventId>{$ctx:eventbriteEventId}</eventId>
								</eventbrite.publishEvent>	
								<!-- Remove custom headers from the Eventbrite response. -->
								
								<sequence key="removeResponseHeaders" />
								<property name="eventPublished" expression="json-eval($.published)" />
						
								<filter source="boolean(get-property('eventPublished'))" regex="false">
									<then>
										<property name="status" value="Error" />
										<property name="message" expression="json-eval($.)" />
									</then>
									<else>
										<property name="status" value="Success" />
										<property name="message" expression="fn:concat('Event [',get-property('eventbriteEventId'),'] has been published.')" />
										<property name="eventbrite.isSuccess" value="true"/>
									</else>
								</filter>
								<call-template target="responseHandlerTemplate">
									<with-param name="id" value="{$ctx:event.idObject}" />
									<with-param name="activity" value="eventbrite_publishEvent" />
									<with-param name="status" value="{$ctx:status}" />
									<with-param name="message" value="{$ctx:message}" />
								</call-template>
								
								
							</then>
							
						</filter>
						
					</then>
				</filter> 
			</then>
		</filter>
		
	</sequence>
</template>
Sample Proxy for Retrieving Selected Sets of Webinars from GoToWebinar and Creating and Publishing them as Events in Eventbrite
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="eventbrite_createWebinarAsEventAndPublish"
       transports="https http"
       startOnLoad="true"
       trace="disable">
   <description/>
   <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="gotowebinar.webinarCount" expression="count(//webinar/data)" scope="operation"/>
         <property name="gotowebinar.webinarIndex" value="0" scope="operation"/>
		 <property name="gotowebinar.sessionCount" value="0" scope="operation"/>
		 <property name="gotowebinar.sessionIndex" value="0" scope="operation"/>
		 
		 <!-- FOR EACH Webinar: BEGIN -->
         <iterate continueParent="true" id="webinars" expression="//webinar/data" sequential="true">
            <target>
               <sequence>
					  <property name="gotowebinar.webinarKey" expression="//data/webinarKey/text()"/>
					  <property name="eventbrite.price" expression="//data/price/text()"/>
					  <property name="eventbrite.currency" expression="//data/currency/text()"/>
					  <property name="eventbrite.timeZone" expression="//data/timeZone/text()"/>
					  <property name="eventbrite.ticketQty" expression="//data/ticketQty/text()"/>
				  
					<!-- Loop back the entire scenario for an invalid request. -->
					<filter source="boolean(get-property('gotowebinar.webinarKey'))" regex="false">
                     <then>
                        <property name="status" value="Error"/>
                        <property name="message" value="Bad Request."/>
						<property name="event.idObject" value="{}"/>
                        <call-template target="responseHandlerTemplate">
                           <with-param name="id" value="{$ctx:event.idObject}"/>
                           <with-param name="activity" value="eventbrite_createWebinarAsEventAndPublish"/>
                           <with-param name="status" value="{$ctx:status}"/>
                           <with-param name="message" value="{$ctx:message}"/>
                        </call-template>
						<loopback/>
                     </then>
					</filter>		
				  <!-- Retrieve  webinar details. -->
                  <gotowebinar.init>
                     <apiUrl>{$ctx:gotowebinar.apiUrl}</apiUrl>
                     <accessToken>{$ctx:gotowebinar.accessToken}</accessToken>
                     <organizerKey>{$ctx:gotowebinar.organizerKey}</organizerKey>
                  </gotowebinar.init>
                  <gotowebinar.getWebinarById>
                     <webinarKey>{$ctx:gotowebinar.webinarKey}</webinarKey>
                  </gotowebinar.getWebinarById>
				  <property name="gotowebinar.webinarIndex" expression="get-property('operation','gotowebinar.webinarIndex') + 1"
                            scope="operation"/>
                  <!-- Remove unused headers by calling a sequence template. -->
				  <sequence key="removeResponseHeaders" />
                  <property name="messageType" value="application/json" scope="axis2"/>
                  <property name="password" value="operation"/>
                  
                  <property name="webinarSubject" expression="json-eval($.subject)"/>
				  
				  <!-- Check if valid webinar. -->
                  <filter source="boolean(get-property('webinarSubject'))" regex="false">
                     <then>
                        <property name="status" value="Error"/>
                        <property name="message" expression="json-eval($.)"/>
                        <call-template target="responseHandlerTemplate">
                           <with-param name="id" value="{$ctx:event.idObject}"/>
                           <with-param name="activity" value="eventbrite_createWebinarAsEventAndPublish"/>
                           <with-param name="status" value="{$ctx:status}"/>
                           <with-param name="message" value="{$ctx:message}"/>
                        </call-template>
                     </then>
                     <else>
                        <property name="gotowebinar.webinarName" expression="json-eval($.subject)"/>
                        <property name="gotowebinar.description" expression="json-eval($.description)"/>
                        <property name="gotowebinar.idObject"
                                  expression="fn:concat('webinar_key:',get-property('gotowebinar.webinarKey'))"/>
								  
						<property name="gotowebinar.sessionCount" expression="get-property('operation','gotowebinar.sessionCount') + count(//times)" scope="operation"/>	  
						
						<!-- FOR EACH Webinar Session: BEGIN-->	
						<iterate continueParent="true" id="session" expression="//times" sequential="true">
							<target>
								<sequence>
								
									<property name="gotowebinar.webinarStartTime" expression="//times/startTime/text()"/>
									<property name="gotowebinar.webinarEndTime" expression="//times/endTime/text()"/>
									
									<!-- Call createEventAndTraining template to create and publish Event -->
									<call-template target="createEventAndPublish">
									   <with-param name="eventbrite.apiUrl" value="{$ctx:eventbrite.apiUrl}"/>
									   <with-param name="eventbrite.accessToken" value="{$ctx:eventbrite.accessToken}"/>
									   <with-param name="eventbrite.currency" value="{$ctx:eventbrite.currency}"/>
									   <with-param name="eventbrite.price" value="{$ctx:eventbrite.price}"/>
									   <with-param name="eventbrite.ticketQty" value="{$ctx:eventbrite.ticketQty}"/>
									   <with-param name="event.timezone" value="{$ctx:eventbrite.timeZone}"/>
									   <with-param name="event.endTime" value="{$ctx:gotowebinar.webinarEndTime}"/>
									   <with-param name="event.startTime" value="{$ctx:gotowebinar.webinarStartTime}"/>
									   <with-param name="event.name" value="{$ctx:gotowebinar.webinarName}"/>
									   <with-param name="event.description" value="{$ctx:gotowebinar.description}"/>
									   <with-param name="event.idObject" value="{$ctx:gotowebinar.idObject}"/>
									</call-template>
								
								<property name="gotowebinar.sessionIndex" expression="get-property('operation','gotowebinar.sessionIndex') + 1" scope="operation"/>
								</sequence>
							</target>
						</iterate>			
						<!-- FOR EACH Webinar Session: END -->
                     </else>
                  </filter>
               </sequence>
            </target>
         </iterate>
		 <!-- FOR EACH Webinar: END -->
         <filter xpath="(get-property('operation','gotowebinar.webinarCount') = get-property('operation','gotowebinar.webinarIndex')) and (get-property('operation','gotowebinar.sessionCount') = get-property('operation','gotowebinar.sessionIndex'))">
            <then>
				<loopback/>
            </then>
         </filter>
      </inSequence>
      <outSequence>
         <payloadFactory media-type="json">
            <format>{
					"Response":{
						"process":"Eventbrite-createWebinarAsEventAndPublish",
						"activityResponse":[$1]
					}
				}</format>
            <args>
               <arg evaluator="xml" expression="get-property('operation','responseString')"/>
            </args>
         </payloadFactory>
         <property name="messageType" value="application/json" scope="axis2"/>
         <send/>
      </outSequence>
   </target>
</proxy>                                                                               
Sample Request for Retrieving Selected Sets of Webinars from GoToWebinar and Creating and Publishing them as Events in Eventbrite
{ 
	"gotowebinarApiUrl": "https://api.citrixonline.com",
	"gotowebinarAccessToken": "ilcGbGSSoVIBHZafWLZlwGz4gljJ",
	"gotowebinarOrganizerKey": "512299114040876806",
	"webinar":{"data":[ 
    	                            { 
        	                                "webinarKey":"7607870960316259073", 
            	                            "price":"1000", 
                	                        "currency":"JPY", 
                    	                    "timeZone":"Asia/Colombo",
                        	                "ticketQty":"50" 
                            	    }
  	                      ] 
    	                    }, 
	"eventbriteApiUrl":"https://www.eventbriteapi.com", 
	"eventbriteAccessToken":"HBZYG2JXL5WMABCLV2SB" 
}