Rest API: How transfers work
Users can record the transfers that take place in their restaurant. A transfer is a movement between stores. Normally the source store and the destination store are in different cost centers, but a transfer between stores within a single cost center can also be recorded. Each day the transfers made are recorded and valued at the cost of the product or recipe costing.
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 transfers
To retrieve the transfers:
https://app.tspoonlab.com/recipes/api/listTransferPaged?filter=&rows=50&start=0
filter lets you filter by description, start and rows handle pagination, and it returns a list of transfers:
retorna un List<TransferEntry>
class TransferEntry {
String id; // Transfer id
String descr; // Transfer description
String codi; // Transfer code
String date; // Formatted transfer date
Integer year; // Transfer year
Integer month; // Transfer month 1..12
String idOrderCenterDst; // Destination center id
String orderCenterDst; // Destination center
String idOrderCenterSrc; // Source center id
String orderCenterSrc; // Transfer source center
boolean output; // Whether it is outbound. From my center to another.
// If false, it is inbound.
boolean own; // Whether it is a transfer between stores of the same center
boolean locked; // Whether the transfer is locked
}
Rest API: Retrieve a transfer
To retrieve a transfer:
GET https://app.tspoonlab.com/recipes/api/transfer/{id}
id is the transfer identifier. It returns:
public class TransferData {
String id; // Transfer id
String descr; // Description
String codi; // Code
String dateFormatted; // Date for display
String comment; // Comment
Date dateGenerated; // Transfer date
Double cost; // Transfer cost
String currency; // Currency
String idOrderCenterDst; // Destination center id
String orderCenterDst; // Destination center
String idOrderCenterSrc; // Source center id
String orderCenterSrc; // Transfer source center
boolean output; // Whether it is outbound. From my center to another.
// If false, it is inbound.
boolean own; // Whether it is a transfer between stores of the same center
boolean locked; // Whether the transfer is locked
EntityBaseDescr businessLine; // Source business line
// of the transfer
EntityBaseDescr businessLineDst; // Destination business line of the
// transfer
List<TransferComponentData> listTransferComponents; // Components
// transferred
}
public class EntityBaseDescr {
String id; // Identifier
String descr, // Description
}
public class TransferComponentData {
String id; // Transfer movement id
String idComponent // Transferred component name
String idTransfer; // Transfer id
String descr; // Component name
// Quantity and unit
Double quantity;
String unit;
String idUnit;
// Comment
String comment;
Double cost; // Total cost
String currency; // Currency
String idUse; // Whether it is a cut or breakdown
String use; // Cut or breakdown name
String storeSrc; // Source store
String idStoreSrc; // source store id
String storeDst; // Destination store
String idStoreDst; // destination store id
}
Rest API: Retrieve a transfer summary
To check the total amounts of purchases by status over a period of time, call:
GET:
https://app.tspoonlab.com/recipes/api/integration/transfer/summary?startDate=YYYY-MM-DD&endDate=YYYY-MM-DD
You must pass the following request params:
startDate (String), the date from which data will be retrieved. Required.
endDate (String), the date up to which data will be retrieved. Required.
The date format must be YYYY-MM-DD and is inclusive of startDate and endDate (all data dated equal to startDate or endDate is returned).
It returns:
class TransferDataSummary {
String currency; // Currency
Double cost; // Cost; if in any transfer there is
// a product with no cost, returns null
List<TransferComponentDataSummary> listTransferComponents;
// Distinct components transferred in the time period
}
class TransferComponentDataSummary {
String id; // Transfer/component id
String descr; // Component name
String idComponent; // Component id
short type; // Transferred product type
Long color; // Component colour if it is an ingredient
Double quantity; // Total quantity transferred
String unit; // Transferred unit
String idUnit; // unit id
String comment; // Comment
// If a cut or breakdown was transferred, its id
// Usually null
String idUse;
String use;
// Component categories
String idComponentType; // The main one
String componentType;
List<TypeComponent> listTypesWithId; // All categories
// Source store
String storeSrc;
String idStoreSrc;
// Destination store
String storeDst;
String idStoreDst;
// Cost and cost date
Double cost;
String lastModified;
Date dateGenerated;
// Transfer batches
List<Lot> listLots;
}
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.
