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

const express = require('express');
const router = express.Router(); // eslint-disable-line
const selectTicket = require('../db/selectTicket');
const config = require('../config');
const dataLogIn = require('../server');
const got = require('got');
router.get('/:ticket', async(req, res) => {
const ticketId = req.params.ticket;
const ticket = selectTicket(ticketId);
await insertFlash(ticket);
res.json({message: 'SUCCESS'});
});
module.exports = router;
async function insertFlash(ticket) {
const info = await dataLogIn.dataLogIn;
const key = info.data.token;
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
}
});
}