Escolar Documentos
Profissional Documentos
Cultura Documentos
Token de comunicação 3
Rotas existentes 3
/device_register 3
/orders 3
/order_create 6
/mark_synced 6
Notas 7
Exemplos curl 7
KVS 7
/home/pi/Desktop/Kitchen_Video/bin/start_app.sh 7
/home/pi/Desktop/Kitchen_Video/etc/config.ini 8
Sem ip redirect por tipo de produto 8
Com ip redirect por tipo de produto 8
Token de comunicação
Todas as rotas da API necessitam de um token para “autorizar” o uso da API.
f780d3b4f48353171786563c63f420cb
Rotas existentes
/device_register
http://apis_v2.net-bo.com/kvs/device_register
Serve para registar um dispositivo KVS. Esta rota é usada pelo KVS quando se ativa um
token para utilizar a Cloud API.
Parametros a receber:
{
'token' => 'f780d3b4f48353171786563c63f420cb',
'hardlock' => '82b630a1'
}
Resultado:
{
success: 1
}
/orders
http://apis_v2.net-bo.com/kvs/orders
Parametros a receber:
sync Devolve pedidos que já foram (1) ou não (0) sincronizados com o KVS
Resultado:
{
'success' => {
'9' => {
'order_id' => '9',
'date_created' => '2020-05-12 17:43:06',
'customer_aux' => '',
'customer_code' => '200',
'pickup_datetime' => '2020-05-12 10:23:10',
'customer_phone' => '+351936272176',
'order_type' => 'TAKE-AWAY',
'table_number' => '20',
'remote_code' => 'xpto123',
'order_total' => '10',
'customer_name' => 'Miguel Manso'
'products' => [
{
'quantity' => '10',
'name' => 'Coca-Cola',
'type' => 'drink',
'code' => '',
'price' => '0',
'vat' => '0'
},
{
'type' => 'drink',
'code' => '',
'name' => '7Up',
'quantity' => '10',
'price' => '0',
},
{
'quantity' => '10',
'name' => 'Hot-Dog',
'type' => 'food',
'code' => '',
'price' => '0',
'vat' => '0'
}
]
/order_create
http://apis_v2.net-bo.com/kvs/order_create
Parametros a receber:
{
'token' => 'f780d3b4f48353171786563c63f420cb',
'hardlock' => '82b630a1',
'order_code' => '10001',
'order_type' => 'TAKE-AWAY',
'table_number' => '20',
'remote_code' => 'xpto123',
'pickup_datetime' => '2020-05-12 10:23:10',
'order_total' => '10',
'customer_code' => '200',
'customer_name' => 'Miguel Manso',
'customer_phone' => '+351936272176',
'customer_aux' => '',
'products' => [
{
'quantity' => '10',
'name' => 'Coca-Cola',
'type' => 'drink',
'code' => '1',
'price' => '5',
'vat' => '23'
},
{
'quantity' => '4',
'name' => 'Burguer',
'type' => food,
'code' => '2',
'price' => '10',
'vat' => '13'
}
]
}
/mark_synced
http://apis_v2.net-bo.com/kvs/mark_synced
{
'token' => 'f780d3b4f48353171786563c63f420cb',
'hardlock' => '82b630a1',
'orders' => [1, 2, 3, 4],
}
Notas
Todas as rtas da API retornam respostas com content-type text/json. Sempre que
por algum motivo alguma rota devolver um erro, a resposta terá uma key do género:
{
error: 'Invalid token...'
}
Exemplos curl
curl \
-H "Content-Type: application/json" \
-X POST \
-d '{"token":"f780d3b4f48353171786563c63f420cb","hardlock":"82b630a1",
"remote_code":"xpto123","order_code":"1001",
"order_type":"TAKE-AWAY","order_total":"10",
"pickup_datetime":"2020-05-12 10:23:10","table_number":"10",
"customer_code":"200","customer_name":"Miguel Manso",
"customer_phone":"+351936272176","customer_aux":"",
"customer_code":"200","customer_name":"Miguel Manso",
"products":[{"name":"Coca-Cola","quantity":"10","type":"drink"}]}' \
http://apis_v2.net-bo.com/kvs/order_create
KVS
/home/pi/Desktop/Kitchen_Video/bin/start_app.sh
/home/pi/Desktop/Kitchen_Video/bin/ping_server.sh
ps -ef | grep cloud_api | grep -v grep | awk '{print $2}'| sudo xargs
kill -9 2> /dev/null
/home/pi/Desktop/Kitchen_Video/bin/cloud_api.pl &
CLOUD_API_KEY=f780d3b4f48353171786563c63f420cb
CLOUD_API_KEY=f780d3b4f48353171786563c63f420cb|food=127.0.0.1,drink=127.0.0.1