How to use API integrations with Eventbrite
Need to get some of your Eventbrite data into UI5 application? My latest tutorial series (start with creating a destination) guides you through creating a table with Slack messages for your application. The same table can be used to display an Eventbrite event.
To better understand how we can use an Eventbrite event in place of the Slack message, take a look at the Eventbrite API documentation for the Event object.
Based on the structure of the Event object, you will have to update some of your bindings in your view. In my example, I used the name, icon, date, status, and capacity attributes from the users owned event method call on the main view of the application. This method call returns all the events owned by a specific user in Eventbrite. In my application’s case, this is our SAP CodeJam admin. Update the XML view table bindings to the Eventbrite event properties you want to display. In your controller, you will need to update your AJAX call as well. Eventbrite can handle a “TOKEN” parameter in the request, or you can use the “HEADERS” method I discussed in the API Call tutorial (see Step 9) for your authentication. I also updated my model to create a new data structure using a JSON Model that only has the properties I need from the API response. Since the Eventbrite event has some nested JSON and my main table model contains multiple API call, I found this easier to manage. However, you do not need to do it this way.
Because there are several different statuses for events and our team puts on a lot of CodeJams, I added an Icon Tab filter at the top to view events by status. Selecting a different status calls the Eventbrite service with that status’s filter applied. You will need to add a new function in your main controller to handle the Icon Tab press. My Icon Tab Filter function calls my main loadEvents function. To accomplish this, I added a new parameter for status to my main loadEvents function. This status is preset based on which Icon Tab I want my app to start on when the page initializes, so you need to updated your onInit function to initialize the selected tab attribute in the Icon Tab Filter as well as call the initial status version of the API call.
My detail view uses the Event ID to complete the navigation. In order to replace the array index with the event id in the navigation functions in your controller, I updated the navTo parameter to be a property from my model. The model that is bound to the table is available by using the getBindingContext(“modelName”) function on the event source. Since I have the Event ID available in the detail view by retrieving the argument in the onRouteMatched function, I can query the API for more specific information about that event. Using the Eventbrite event get by id method, I can receive data specifically for that event. You can also use the Event ID to get ticket and attendee information that may be beneficial to display on the Detail page. I updated my detail view to contain an ObjectHeader, a Text field, and a SimpleForm to display all my event information. Make sure to update the model in the detail controller to be the data from the API response.