Class

MitGob

MitGob(apiKey)

MitGob Class Represents a client for interacting with the MIT (Ministerio de Trabajo de la República Dominicana) API, providing methods for retrieving open data. This class extends the FetchService class and focuses on accessing data related to various services using specified parameters and formats.

Full API specs: https://webapi.mt.gob.do
Constructor

# new MitGob(apiKey)

Create an instance of OpenData service.
Parameters:
Name Type Description
apiKey string The API key for authentication.

View Source services/gob.do/mit.js, line 15

Extends

  • FetchService

Methods

# async createEmpresa(postData) → {Promise}

Creates a new Empresa using the API.
Parameters:
Name Type Description
postData Object The data to be sent for creating a new Empresa.

View Source services/gob.do/mit.js, line 368

A promise that resolves to the created Empresa data.
Promise
Example
async function createMITEmpresa(postData) {
  try {
    const mitData = await mitGob.createEmpresa(postData);
    console.log('MIT Created Empresa:', mitData);
  } catch (error) {
    console.error('Error creating MIT Empresa:', error);
  }
}
createMITEmpresa({ name: 'New Empresa', industry: 'IT' });

# createPuesto(postData) → {Promise}

Creates a new Puesto using the API.
Parameters:
Name Type Description
postData Object The data to be sent for creating a new Puesto.

View Source services/gob.do/mit.js, line 304

A promise that resolves to the created Puesto data.
Promise
Example
async function createMITPuesto(postData) {
  try {
    const mitData = await mitGob.createPuesto(postData);
    console.log('MIT Created Puesto:', mitData);
  } catch (error) {
    console.error('Error creating MIT Puesto:', error);
  }
}
createMITPuesto({ name: 'New Puesto', department: 'HR' });

# deleteHoliday(id) → {Promise}

Deletes a specific holiday by ID from the API.
Parameters:
Name Type Description
id string The ID of the holiday to delete.

View Source services/gob.do/mit.js, line 215

A promise that resolves when the holiday is successfully deleted.
Promise
Example
async function deleteMITHoliday() {
  try {
    const holidayId = '123';
    await mitGob.deleteHoliday(holidayId);
    console.log('MIT Holiday Deleted Successfully');
  } catch (error) {
    console.error('Error deleting MIT Holiday:', error);
  }
}
deleteMITHoliday();

# deletePuestoById(id) → {Promise}

Deletes a Puesto by ID using the API.
Parameters:
Name Type Description
id string The ID of the Puesto to be deleted.

View Source services/gob.do/mit.js, line 347

A promise that resolves to the deleted Puesto data.
Promise
Example
async function deleteMITPuestoById(puestoId) {
  try {
    const mitData = await mitGob.deletePuestoById(puestoId);
    console.log('MIT Deleted Puesto:', mitData);
  } catch (error) {
    console.error('Error deleting MIT Puesto:', error);
  }
}
deleteMITPuestoById('123');

# getAvailableYears() → {Promise}

Retrieves available years for holidays from the API.

View Source services/gob.do/mit.js, line 81

A promise that resolves to the fetched available years for holidays.
Promise
Example
async function getMITAvailableYears() {
  try {
    const mitData = await mitGob.getAvailableYears();
    console.log('MIT Available Years:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Available Years:', error);
  }
}
getMITAvailableYears();

# getBeeById(doc) → {Promise}

Retrieves data for a specific Bee by ID from the API.
Parameters:
Name Type Description
doc string The document ID of the Bee.

View Source services/gob.do/mit.js, line 393

A promise that resolves to the fetched Bee data.
Promise
Example
async function getMITBeeById(docId) {
  try {
    const mitData = await mitGob.getBeeById(docId);
    console.log('MIT Bee by ID:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Bee by ID:', error);
  }
}
getMITBeeById('456');

# getConsulta(documento) → {Promise}

Retrieves consulta information from the API based on the specified document.
Parameters:
Name Type Description
documento string The document to retrieve consulta information.

View Source services/gob.do/mit.js, line 237

A promise that resolves to the fetched consulta information.
Promise
Example
async function getMITConsulta() {
  try {
    const documento = '123456789';
    const mitData = await mitGob.getConsulta(documento);
    console.log('MIT Consulta:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Consulta:', error);
  }
}
getMITConsulta();

# getDivisiones() → {Promise}

Retrieves Divisiones from the API.

View Source services/gob.do/mit.js, line 61

A promise that resolves to the fetched Divisiones data.
Promise
Example
async function getMITDivisiones() {
  try {
    const mitData = await mitGob.getDivisiones();
    console.log('MIT Divisiones:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Divisiones:', error);
  }
}
getMITDivisiones();

# getHolidayById(id) → {Promise}

Retrieves a specific holiday by ID from the API.
Parameters:
Name Type Description
id string The ID of the holiday to retrieve.

View Source services/gob.do/mit.js, line 123

A promise that resolves to the fetched holiday data.
Promise
Example
async function getMITHolidayById() {
  try {
    const holidayId = '123';
    const mitData = await mitGob.getHolidayById(holidayId);
    console.log('MIT Holiday:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Holiday:', error);
  }
}
getMITHolidayById();

# getHolidays() → {Promise}

Retrieves holidays from the API.

View Source services/gob.do/mit.js, line 101

A promise that resolves to the fetched holidays data.
Promise
Example
async function getMITHolidays() {
  try {
    const mitData = await mitGob.getHolidays();
    console.log('MIT Holidays:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Holidays:', error);
  }
}
getMITHolidays();

# getHolidaysByRange(from, count) → {Promise}

Retrieves holidays based on a specified range from the API.
Parameters:
Name Type Description
from string The start date of the range.
count number The number of holidays to retrieve.

View Source services/gob.do/mit.js, line 147

A promise that resolves to the fetched holidays data within the specified range.
Promise
Example
async function getMITHolidaysByRange() {
  try {
    const from = '2023-01-01';
    const count = 5;
    const mitData = await mitGob.getHolidaysByRange(from, count);
    console.log('MIT Holidays:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Holidays:', error);
  }
}
getMITHolidaysByRange();

# getPuestoById(id) → {Promise}

Retrieves a specific Puesto by ID from the API.
Parameters:
Name Type Description
id string The ID of the Puesto to retrieve.

View Source services/gob.do/mit.js, line 283

A promise that resolves to the fetched Puesto data.
Promise
Example
async function getMITPuestoById() {
  try {
    const puestoId = '123';
    const mitData = await mitGob.getPuestoById(puestoId);
    console.log('MIT Puesto:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Puesto:', error);
  }
}
getMITPuestoById();

# getPuestos(from, limit) → {Promise}

Retrieves Puestos information from the API based on the specified parameters.
Parameters:
Name Type Description
from string The start index of the Puestos data.
limit number The number of Puestos data to retrieve.

View Source services/gob.do/mit.js, line 261

A promise that resolves to the fetched Puestos data.
Promise
Example
async function getMITPuestos() {
  try {
    const from = '0';
    const limit = 10;
    const mitData = await mitGob.getPuestos(from, limit);
    console.log('MIT Puestos:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Puestos:', error);
  }
}
getMITPuestos();

# getTiposDivision() → {Promise}

Retrieves Division Types from the API.

View Source services/gob.do/mit.js, line 40

A promise that resolves to the fetched Division Types.
Promise
Example
async function getMITTiposDivision() {
  try {
    const mitData = await mitGob.getTiposDivision();
    console.log('MIT Division Types:', mitData);
  } catch (error) {
    console.error('Error retrieving MIT Division Types:', error);
  }
}
getMITTiposDivision();

# postHoliday(holidayData) → {Promise}

Posts a new holiday to the API.
Parameters:
Name Type Description
holidayData Object The data of the holiday to post.

View Source services/gob.do/mit.js, line 169

A promise that resolves to the posted holiday data.
Promise
Example
async function postMITHoliday() {
  try {
    const newHoliday = { name: 'New Year', date: '2023-01-01' };
    const mitData = await mitGob.postHoliday(newHoliday);
    console.log('MIT Posted Holiday:', mitData);
  } catch (error) {
    console.error('Error posting MIT Holiday:', error);
  }
}
postMITHoliday();

# putHoliday(id, updatedData) → {Promise}

Updates a specific holiday by ID in the API.
Parameters:
Name Type Description
id string The ID of the holiday to update.
updatedData Object The updated data for the holiday.

View Source services/gob.do/mit.js, line 193

A promise that resolves to the updated holiday data.
Promise
Example
async function putMITHoliday() {
  try {
    const holidayId = '123';
    const updatedData = { name: 'Updated Year', date: '2023-01-01' };
    const mitData = await mitGob.putHoliday(holidayId, updatedData);
    console.log('MIT Updated Holiday:', mitData);
  } catch (error) {
    console.error('Error updating MIT Holiday:', error);
  }
}
putMITHoliday();

# updatePuesto(id, updateData) → {Promise}

Updates an existing Puesto using the API.
Parameters:
Name Type Description
id string The ID of the Puesto to be updated.
updateData Object The data to be sent for updating the Puesto.

View Source services/gob.do/mit.js, line 326

A promise that resolves to the updated Puesto data.
Promise
Example
async function updateMITPuesto(puestoId, updateData) {
  try {
    const mitData = await mitGob.updatePuesto(puestoId, updateData);
    console.log('MIT Updated Puesto:', mitData);
  } catch (error) {
    console.error('Error updating MIT Puesto:', error);
  }
}
updateMITPuesto('123', { name: 'Updated Puesto' });