Skip to content

Epitech-ops/node-eurecia

Repository files navigation

node-eurecia

Node wrapper for the Eurecia API

Installation

npm install node-eurecia --save

Usage

const eurecia = require('node-eurecia');

async function main() {
  try {
    const eureciaInstance = new eurecia();
    await eureciaInstance.authenticate(process.env['EURECIA_TOKEN']);
    const allEmployees = await eureciaInstance.getAllEmployees();
    for (const employee of allEmployees) {
      try {
        const employeeData = await eureciaInstance.getEmployeeById(employee.id);
        console.log(employeeData);
      } catch (error) {
        console.error(error);
      }
    }
  } catch (error) {
    console.error(error);
  }
}

API reference

authenticate(token)

// Authenticates with Eurecia API (mandatory before any call)
eureciaInstance.authenticate(token);

getCompanies(page)

// Gets a page of companies
await eureciaInstance.getCompanies();
await eureciaInstance.getCompanies(0);
...
await eureciaInstance.getCompanies(42);

getAllCompanies()

// Gets all pages of companies
await eureciaInstance.getAllCompanies();

getEmployees(page, active)

// Gets a page of employees
await eureciaInstance.getEmployees();
await eureciaInstance.getEmployees(0, true);
...
await eureciaInstance.getEmployees(42, false);

getAllEmployees(active)

// Gets all pages of employees
await eureciaInstance.getAllEmployees();
await eureciaInstance.getAllEmployees(true);
await eureciaInstance.getAllEmployees(false);

getEmployeeById(id)

// Gets an employee by its id
await eureciaInstance.getEmployeeById('id');

getDepartments()

// Gets all departments
await eureciaInstance.getDepartments();

getStructures()

// Gets all structures
await eureciaInstance.getStructures();

getPayrollGrids()

// Gets all payroll grids
await eureciaInstance.getPayrollGrids();

License

MIT