Skip to main content

REST API: Creating events and menus đŸ±

Description of the REST interface that lets you create events and menus in tspoonlab

Rest API: Creating events

This REST interface lets external systems create events with their corresponding menus in tspoonlab. Each event must have a code and a description; this code is what lets you update the event on later calls. Each event has an associated dish group (starters, first courses, second courses, desserts) and their corresponding dishes, also with a code and description. If any of the dishes does not exist in tspoonlab, a new dish is created in the system with that code and description.

System login

To make calls to our APIs, the first thing you need is to authenticate through a login call. That call returns a token that you must then attach to every subsequent call.

This shell script shows how to authenticate using curl:

[email protected]
password=XXXXXXX

url=https://app.tspoonlab.com/recipes/api
authenticate='username='$username'&password='$password

echo -n 'rememberme:' > rememberme.txt
curl -v --data $authenticate $url/login >> rememberme.txt

On later calls, add the token received from the login call to your headers:

curl -X PUT -v -H "$(cat rememberme.txt)"  $url/integration/llamada

Creating/updating events

To create and/or update events, menus and dishes, make the following REST call:

POST: https://app.tspoonlab.com/recipes/api/integration/event

In the request body, attach the event with its data, represented by the Event class:

public class Event {

private String code; // Event code. Required
private String descr; // Event description. Required
private Integer pax; // Pax
private Date date; // Event date
private String codeClient; // Client code
private String descrClient; // Client description
private Short version; // Menu version, if sent several times.
private short state; // Event status: approved, cancelled, quoted, etc.
/*
public static final short offer = 0;
public static final short approved = 1;
public static final short cancelled = 2;
public static final short done = 3;
public static final short opportunity = 4;
public static final short rejected = 5;
*/
private List<EventMenuGroup> listGroups; // List of dish groups
}

The event is made up of groups corresponding to its different phases: starter, first course, second course, dessert:

public class EventMenuGroup {

private String descr; // Dish group. Starters, mains, desserts
private List<EventMenuGroupComponent> listComponents;
}

Each EventMenuGroup has its corresponding dishes:

public class EventMenuGroupComponent {

private String codi; // Dish code
private String descr; // Dish name
private Double quantity; // Dish name
}

Did you find this article helpful?

If you need further assistance, contact support by clicking the built-in Support Chat in the bottom-right corner of your screen.


Did this answer your question?