Repository URL to install this package:
|
Version:
2.0.0-rc.7 ▾
|
'use strict';
const fetch = require('fetch-everywhere');
const {
errorHandler,
responseHandler
} = require('./helpers/fetch');
/**
* Delete a user's mandator by the mandatorId.
*
* @note that this is a "soft" delete which will simply remove the mandator
* from the list of the user's mandator(s), but the mandator remains in the database
* so that nobody else can use it. If you want to permantly remove it from the
* database then you need to use `permanentlyDeleteMandator()`.
*
* @param {string} accessToken - The user's access-token
* @param {string} mandatorId - The user's mandator Id
* @returns {Promise<object>}
*/
function deleteMandator(accessToken, mandatorId) {
if (typeof accessToken !== 'string') {
throw new TypeError(`accessToken param must be a string, got ${typeof accessToken}`);
}
if (typeof mandatorId !== 'number') {
throw new TypeError(`mandatorId param must be a number, got ${typeof mandatorId}`);
}
const url = `${process.env.MONOLITH_API_BASE_URL}/api/v3.0/mandators/${mandatorId}`;
const headers = {
'Content-Type': 'application/json',
Authorization: `Bearer ${accessToken}`,
Accept: 'application/json'
};
return fetch(url, {
method: 'DELETE',
headers
}).then(responseHandler).catch(errorHandler);
}
module.exports = deleteMandator;
//# sourceMappingURL=deleteMandator.js.map