Access the device token through the device_id

Access the device token through the device_id

Hey guys.

I'm trying to develop an analysis that captures all the devices I have at once. I was able to get the ID of all of them, but to access the variables, I need access to the token. But I'm not finding a way to access the token by ID. Is it possible to access the token through the ID and thus have access to the device variables? If anyone can help me.

Thanks.

This is my code:
//Essa análise faz a soma de todos os dados de acordo com o start date.
// Claro que definindo a variável que você deseja no campo variable em filto
// Não esqueça de setar seu token na aba Environment para que ele esteja comunicando corretamente.


const { Analysis, Resources, Account, Utils } = require("@tago-io/sdk");
 

async function listDevicesByTag(context) {


  const filter = {
    tags: [
      {
        key: "DLGG", // key definida no dispositivo
        value: "sensor", // valor da key
      },
    ],
  };

 
  const dispositivos  = await Resources.devices.list({
    page: 1,
    fields: ["name","id"],
    filter,
    amount: 100,
  });
  context.log(dispositivos);
  const filter_id = dispositivos.map((item) =>{
      return item.id;
  })

  const my_ids = JSON.stringify(filter_id);
  context.log(my_ids);

    const env_vars = Utils.envToJson(context.environment);
    const account = new Account({ token: env_vars.account_token });

    for (const device_id of my_ids) {
    const device = new Device({ token: account });
    const device_info = await device.info(device_id).catch(console.error);
    const device_token = device_info.token;
 
    // Aqui você tem o token do dispositivo e pode realizar operações adicionais
    console.log(`Token for device ${device_id}: ${device_token}`);
    }
}
module.exports = new Analysis(listDevicesByTag);


And error:

[2024-03-04 15:04:00] Analysis Called.
[2024-03-04 15:04:00] Analysis finished.
[2024-03-04 15:04:00] Duration: 1.3s Billed Duration: 2s.
[2024-03-04 15:04:00] undefined:40 const device = new Device({ token: account }); ^ ReferenceError: Device is not defined at Analysis.listDevicesByTag [as analysis] (eval at <anonymous> ([eval]:8:39), <anonymous>:40:20) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) Node.js v18.18.2
[2024-03-04 15:04:00] [ { name: 'Dispositivo 001', id: '65d87e3a5129c1000fe8efa0', tags: [ [Object] ] }, { name: 'Dispositivo 006', id: '65d8f476cfd54b0009b722e9', tags: [ [Object] ] } ]
[2024-03-04 15:04:00] ["65d87e3a5129c1000fe8efa0","65d8f476cfd54b0009b722e9"]
[2024-03-04 15:04:00] > TagoIO-SDK: No region or env defined, using fallback as usa-1.
[2024-03-04 15:03:59] Starting Analysis...