Rest API: Clients
Each cost center has a list of associated clients you make sales to. In this document weâll see how to retrieve all the clients and the information for each of them.
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: List all clients
There are two calls:
GET:
https://app.tspoonlab.com/recipes/api/listCustomersPaged
You can pass the following request parameters:
start (int), the first row to return. Required.
rows (int), the number of rows to return. Required.
filter (String), a string to filter the clients. Optional.
hidden (Boolean), returns only the hidden ones. Optional.
It returns:
retorna una List<TypeEntry>
TypeEntry {
String id;
String descr;
String codi;
boolean defecte;
String descrType;
String idType;
}
Where: id is the client identifier, descr the client name, codi the client code, defecte is true when it is the default client, and idType/descrType identify the client type. Each client can be grouped by type so you can classify them; the next section explains how it works.
Rest API: List all client types
To list the client types:
GET:
https://app.tspoonlab.com/recipes/api/listCustomerTypesPaged
You can pass the following request parameters:
start (int). Required.
rows (int). Required.
filter (String). Optional.
It returns:
retorna una List<EntityBaseBoolCodi>
EntityBaseBoolCodi {
String id;
String descr;
String codi;
}
Rest API: Get a clientâs data
To get a clientâs data:
GET:
https://app.tspoonlab.com/recipes/api/customer/{idCustomer}
idCustomer is the client identifier. It returns:
class Customer {
String id;
String descr;
Boolean defecte;
String nif;
String comment;
String web;
String mailcc;
String codi;
String address;
String city;
String cp;
String idCustomerType;
List<CustomerContact> listContact;
List<CustomerMail> listMail;
List<CustomerComponentGroup> listGroups;
}
Where:
id is the client identifier.
descr is the client name.
defecte whether it is the default client.
nif the clientâs tax ID
comment a comment about the client
mailcc the address that receives a copy when orders are emailed to the client
web the clientâs website URL
codi the client code, and address, city and cp the postal address.
idCustomerType is the client type it belongs to (null if you donât want to associate one).
listContact is the clientâs contact list.
listMail is all the contact emails for that client.
CustomerContact {
String id;
String descr;
String phone;
}
CustomerMail {
String id;
String descr;
}
In CustomerContact, descr is the contact name; in CustomerMail, descr is the email address. listGroups holds the list of product groups for that client:
public CustomerComponentGroup {
String id;
String idCustomerGroup;
String customerGroup;
String codiCustomerGroup;
String comment;
}
Rest API: Get the sale products
Within a group you can find the sale products. There may be sale products not associated with any group:
GET:
https://app.tspoonlab.com/recipes/api/customer/{idCustomer}/components/paged
You can pass the following request parameters:
start (int). Required.
rows (int). Required.
filter (String), a string to filter the clients. Optional.
idGroup (String), if you want the products of a group â null to get the products not associated with a group.
CustomerComponent {
String id;
Double cost;
Double costComponent;
Double percentCost;
String plu;
Double iva;
String currency;
Double quantity;
String unit;
String idUnit;
String idComponent;
String component;
String idMenu;
String menu;
}
Where:
id the sale product id.
cost the sale price including VAT (Value Added Tax).
costComponent the product cost.
percentCost the Food Cost %.
plu the product code on the POS (Point of Sale).
iva the VAT rate applied.
currency the currency.
quantity the sale quantity.
idUnit the sale-unit identifier.
unit the sale-unit description.
You can sell both products and menus.
For a product:
idComponent the product identifier.
component the product description.
For menus:
idMenu the menu identifier.
menu the menu description.
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.
