This repository has been archived on 2024-10-02. You can view files and clone it, but cannot push or open issues or pull requests.
smart-tag/methods/flashOn.js

37 lines
1.0 KiB
JavaScript
Raw Normal View History

2021-03-25 12:38:48 +00:00
const express = require('express');
const router = express.Router(); // eslint-disable-line
2022-04-01 12:17:36 +00:00
const selectTicket = require('../db/selectTicket');
const config = require('../config');
2022-04-01 12:17:36 +00:00
const dataLogIn = require('../server');
const got = require('got');
2021-03-25 12:38:48 +00:00
router.get('/:ticket', async(req, res) => {
2022-04-01 12:17:36 +00:00
const ticketId = req.params.ticket;
const ticket = selectTicket(ticketId);
await insertFlash(ticket);
2021-05-13 14:21:34 +00:00
res.json({message: 'SUCCESS'});
2021-03-25 12:38:48 +00:00
});
module.exports = router;
2022-04-01 12:17:36 +00:00
async function insertFlash(ticket) {
const info = await dataLogIn.dataLogIn;
const key = info.data.token;
2021-03-25 12:38:48 +00:00
2022-04-01 12:17:36 +00:00
await got.post('http://app.etiquetaselectronicas.com:9999/led/excuteLed', { // eslint-disable-line
json: {
storeId: config.storeId,
lightCololr: 8,
lightTime: 30,
targetExecution: ticket[0].shelvingFk + ticket[0].level + '/tagWithTicket',
lightFrequency: 1
},
responseType: 'json',
headers: {
'Authorization': key
}
});
2021-03-25 12:38:48 +00:00
}