Skip to main content

REST API: Stores 🏬

How to list, retrieve, and manage stores and their inventories.

Rest API: Managing stores

In this article we’ll see how to create, manage and delete stores.

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

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: Retrieve stores

To retrieve the stores:

GET: 
https://app.tspoonlab.com/recipes/api/listStoresPaged

You can pass the following request parameters:

  • start (int), the first row to return. Required.

  • rows (int), the number of rows. Required.

  • filter (String), a string to filter the ingredients. Optional.

It returns:

retorna una List<StoreEntry> 

StoreEntry {
String id;
String descr;
boolean defecte;
}

Where:

id is the store id.

descr is the store name.

defecte indicates whether it is a default store.

Rest API: Retrieve a store

GET: 
https://app.tspoonlab.com/recipes/api/store/{idStore}/inventory/{idInventory}/components/num/{numComponents}

Where:

idStore is the store id.

idInventory is the inventory you want to retrieve the data from.

null to retrieve all data since the last inventory.

numComponents indicates how many components you want to return.

It returns:

public class Store  {

String id; // Store id
String descr; // Store description
String comment; // Store comment
List<StoreComponent> listComponent; // Store components
}

public class StoreComponent {
String id; // store component id
String descr; // Component description
String idComponent; // Component id
private String idUse; // Use id
private String use; // Use description
private String unit; // unit
private String idUnit; // Unit id
private Double quantityInventory; // Last inventory quantity
private Double quantityInput; // Total quantity in
private Double quantityOutput; // Total quantity out
private Double quantityDesviation; // Quantity of detected deviations
}

To access more StoreComponents:

GET: 
https://app.tspoonlab.com/recipes/api/store/{idStore}/inventory/{idInventory}/components/paged

You can pass the following request parameters:

  • start (int). Required.

  • rows (int). Required.

  • filter (String), a string to filter the components. Optional.

It returns a list of StoreComponent.

Rest API: Create a store

To create a store:

POST: 
https://app.tspoonlab.com/recipes/api/store

Where in the request body you pass:

public class NewStore {

String descr; // Store description
String comment; // Comment
boolean defaultReception; // Default store for reception
boolean defaultProduction; // Default store for production
boolean defaultExpedition; // Default store for dispatch
}

Rest API: Delete a store

DELETE: 
https://app.tspoonlab.com/recipes/api/store/{idStore}

When you delete a store, all its inventories are deleted.

Rest API: Add a component to the store

PUT: 
https://app.tspoonlab.com/recipes/api/store/{idStore}/components

In the request body you pass:

public class NewStoreComponentsWrapper {
List<NewStoreComponent> components;
}

public class NewStoreComponent {

String id; // Null when adding
String idComponent; // Component id
String idUse; // Cut or breakdown id
}

Rest API: Remove a component from a store

To remove a product from the store:

DELETE: 
https://app.tspoonlab.com/recipes/api/store/{idStore}/component/{idStoreComponent}

Rest API: List locations

To list the locations of a store:

GET: 
https://app.tspoonlab.com/recipes/api/store/{idStore}/locations

It returns:

Retorna una List<StoreLocation>

public class StoreLocation {

String id; // Location id
String descr; // Location description
Integer countStoreComponents; // Number of components in the location
String comment;

Rest API: Create a location

To create a location in a store:

POST: 
https://app.tspoonlab.com/recipes/api/store/{idStore}/location

Passing:

public class NewStoreLocation {
String descr; // Location name
String comment;
}

It returns an IdWrapper with the id of the new location:

public class IdWrapper {

String id;
}

Rest API: Delete a location

To delete a location:

DELETE: 
https://app.tspoonlab.com/recipes/api/store/{idStore}/location/{idStoreLocation}

Rest API: List components within a location

GET: 
https://app.tspoonlab.com/recipes/api/storeLocation/{idStoreLocation}/storeComponents

It returns:

Retorna List<StoreLocationStoreComponent>


public class StoreLocationStoreComponent {
String id; // storelocationstorecomponent id
String descr; // Component description
String idComponent; // components id
String idUse; // Cut or breakdown id
String use; // Cut or breakdown description

Rest API: Add components to a location

To add storeComponents to a location you must pass a list of the storeComponents to add:

POST: 
https://app.tspoonlab.com/recipes/api/storeLocation/{idStoreLocation}/storeComponents/add

Passing in the request body a list of the idStoreComponents:

public class NewStoreLocationStoreComponentsWrapper {
List<NewStoreLocationStoreComponent> storeComponents;
}

public class NewStoreLocationStoreComponent {


private String id; // Null when adding
private String idStoreComponent; // storecomponent id
}

Rest API: Remove components from a location

To remove storeComponents from a location you must pass a list of the storeComponents to remove:

POST: 
https://app.tspoonlab.com/recipes/api/storeLocation/{idStoreLocation}/storeComponents/delete

Passing in the request body a list of the idStoreComponents:

public class NewStoreLocationStoreComponentsWrapper {
List<NewStoreLocationStoreComponent> storeComponents;
}

public class NewStoreLocationStoreComponent {


private String id; // Id to delete
private String idStoreComponent; // storecomponent id
}

Rest API: Move some components from one store to another

To move some storeComponents from one store to another you must:

PUT: 
https://app.tspoonlab.com/recipes/api/store/{idStore}/components/move/some/{idStoreDest}

idStore is the source store and idStoreDest the destination store. You pass the ids of the storeComponents you want to move to the other store.

public class NewListIds {
List<String> listIds; // Ids of the storecomponents to move
}

Rest API: List all inventories

To list all the inventories:

GET: 
https://app.tspoonlab.com/recipes/api/listInventoriesPaged

You can pass the following request parameters:

  • start (int). Required.

  • rows (int). Required.

  • filter (String), a string to filter the stores. Optional.

  • year (int), the year of the inventories to retrieve. Optional.

  • month (int), the month of the inventories to retrieve. Optional.

It returns:

retorna una List<EntityBaseData> 

EntityBaseDate {
String id; // Inventory id
String descr; // Store name
String idAux; // Store id
Integer year;
Integer month;
Date dateGenerated; // Inventory date
}

Where:

id is the inventory id.

idAux is the store id.

descr is the store name.

year and month the year and month of the inventory.

dateGenerated the inventory date.

The returned data is sorted by inventory date in descending order.

Rest API: Retrieve an inventory’s value

To retrieve an inventory’s value:

GET: 
https://app.tspoonlab.com/recipes/api/inventory/{idInventory}/total

It returns:

class DoubleWrapper  {
Double value;
}

Where value is the inventory valuation.

Rest API: Retrieve the quantities of each component

To retrieve the quantities entered in the inventory, call:

GET: 

https://app.tspoonlab.com/recipes/api/inventory/{idInventory}/components/paged?start=0&rows=50

Where idInventory is the inventory id. You can pass the following request parameters:

  • start (int). Required.

  • rows (int). Required.

  • filter (String), a string to filter the ingredients. Optional.

It returns:

class StoreComponent  {
String id; // Id of the product entry in the inventory
String descr; // Product name
String idComponent; // Product id

String idComponentType; // main category id
String componentType; // main category description

Double quantity; // Inventory quantity
Double cost; // Stock count cost
}

idComponentType is the id of the product’s main category and componentType its description. More information in the REST API: Categories article.

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?