Skip to main content

REST API: Productions đŸ”Ș

Learn how to list batches, view productions, and create or update production records through the tSpoonLab REST API.

Rest API: How productions work

In this document we’ll see how to list the stations, the productions of each station, create a new production and list the ingredients of a production.

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 -H "content-type: application/x-www-form-urlencoded" --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

Rest API: Select a cost center/restaurant

The requests described in the following sections refer to a cost center, which in most cases corresponds to a restaurant. To retrieve the list of cost centers and their identifiers, see the REST API: Cost centers article.

The cost center identifier corresponds to the idOrderCenter field of the UserOrderCenter class.

Once you have the identifier, add it to the headers so it is used on subsequent calls:

echo -n 'order:351583444167656299610202XXXXXXXXXXXX' >> rememberme.txt

So in your request headers you must specify both the token returned by login and the cost center identifier:

rememberme:aGVucnkudXBzYWxsLmRAZXXXXXXXXXXXXXXXXXX
order:351583444167656299610202XXXXXXXXXXXX

Rest API: List all stations

GET
https://app.tspoonlab.com/recipes/api/listPartidesPaged?filter=&rows=50&start=0

filter lets you filter by description, start and rows handle pagination, and it returns a list of the stations:

retorna un List<EntityBaseDescr>

class EntityBaseDescr {

String id;
String descr;

}

Rest API: Retrieve the id of the daily productions

POST
https://app.tspoonlab.com/recipes/api/production/day/{year}/{month}/{day}

Where year, month, day are the year, month and day of the production you want the id for. If a day is requested for the first time, the id is created; on later requests it returns the same id.

retorna un IdWrapper

class IdWrapper {

String id;
}

Rest API: List a day’s productions by id

GET
https://app.tspoonlab.com/recipes/api/productionComponentList?id=IIIIIIIIII&idPartida=PPPPPPPPPPPPPPPPPPPP&

id is the production identifier obtained in the previous section.

idPartida is the station identifier, it returns only the recipes and dishes made by that station (this identifier is optional).

filter lets you filter by description, start and rows handle pagination, and it returns a list of the day’s productions.

retorna un ProductionDay

public class ProductionDay {

String id;
String date;
int year;
int month;
int day;

List<ProductionDayComponent> listComponents;
}

In ProductionDay, id is the production identifier and year, month, day its year, month and day. Date is the formatted date. listComponents is the list of productions for that day.

class ProductionDayComponent {

String id;
String idComponent;
String descr;
String comment;
String dateGeneratedFlat;
String lot;
ProductionComponentStatus status;
String idPartida;
String partida;
List<ComponentServiceProduction> listComponentService;
}

id is the identifier of a recipe or dish’s production. idComponent the recipe or dish identifier. descr the recipe or dish description. comment, dateGeneratedFlat, lot are the comment, production start time and batch.

partida and idPartida indicate the station the recipe or dish belongs to (useful if you didn’t filter by station when listing productions).

Productions can have the following statuses: Pending, Started and Finished, reflected in status.

ProductionComponentStatus {

private String dateGenerated;
private String dateStarted;
private String dateDone;
private boolean started;
private boolean done;
}

If the production has not started yet, started is false and done is false. If the production is started, started is true and done is false. Once finished, started is true and done is true. The quantity to produce is reflected in listComponentService.

 class ComponentServiceProduction {

String id;
String idUnit;
Double quantity;
String unit;

}

id is this entity’s identifier. idUnit, unit identify the unit. quantity the quantity.

Rest API: Start, finish and restart a production

To start a production:

PUT
https://app.tspoonlab.com/recipes/api/productionComponent/{idProductionComponent}/start/status

idProductionComponent is the identifier of the recipe or dish’s production. To finish a production:

PUT
https://app.tspoonlab.com/recipes/api/productionComponent/{idProductionComponent}/done

idProductionComponent is the identifier of the recipe or dish’s production. To restart an already-finished production:

PUT
https://app.tspoonlab.com/recipes/api/productionComponent/{idProductionComponent}/redo

idProductionComponent is the identifier of the recipe or dish’s production. They return an updated ProductionComponentStatus; this class’s fields are explained in the previous section.

Rest API: Create a new production

To create a production, first you must select a recipe or dish:

GET
https://app.tspoonlab.com/recipes/api/listComponentsPartidaPagedEx?filter=&filterType=recipeAndDish&partida={idPartida}&start=0&rows=50

Where:

filter is the search filter for the description.

filterType must always take the value recipeAndDish.

partida is the identifier of the active station.

start and rows are used for pagination.

Retorna 
class SearchResult {
String filter;
List<EntityBaseComponent> list;
}

EntityBaseComponent {
String id;
Short type;
String descr;
String codi;
}

id is the recipe or dish identifier (idComponent).

type is 1 for recipes and 3 for dishes.

descr and codi are the recipe or dish description and code.

Once you have selected the recipe or dish, you must retrieve the default quantities to produce.

GET
https://app.tspoonlab.com/recipes/api/component/{idComponent}/quantityUnit

idComponent is the recipe or dish identifier:

Retorna  List<QuantityUnit>
class QuantityUnit {

String id;
String descr;
Double quantity;
}

Where:

id and descr are the unit identifier and unit name.

quantity is the quantity to produce.

Once you have selected a recipe or dish and the quantity to produce, you create the production:

POST
https://app.tspoonlab.com/recipes/api/production/{idProduction}/component/{idComponent}/quantities/events

idProduction and idComponent are the production and recipe/dish identifiers. Pass the POST data with the header content-type: application/json:

class NewProductionComponentWithEvents {

List<NewProductionComponentEventQuantity> quantities;
}

class NewProductionComponentEventQuantity {

String idUnit;
Double quantity;
}
retorna un IdWrapper

class IdWrapper {

String id;
}

id is the identifier of the recipe or dish’s production (idProductionComponent).

Rest API: Delete a production

DELETE
https://app.tspoonlab.com/recipes/api/productionComponent/{idProductionComponent}

idProductionComponent is the identifier of the recipe or dish’s production.

Rest API: Create, start and finish a production

To create a production, start it and finish it in a single step, call:

POST
https://app.tspoonlab.com/recipes/api/production/component

In the request body you must pass:


class NewCreateProduction {
String idComponent;
double quantity;
Date date;
}

It returns an IdWrapper:


class IdWrapper {

String id;
}

id is the identifier of the recipe or dish’s production (idProductionComponent).

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?