revbits-cip-integration
Version:
This package will integrate CIP with any product
73 lines (72 loc) • 3.51 kB
JavaScript
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
const jwt_client_1 = require("../services/jwt.client");
const api_config_1 = require("./api.config");
const base_api_1 = require("./base.api");
class RolesApi extends base_api_1.BaseApi {
constructor(baseUrl, platform, privKey, options, actor = null) {
super(baseUrl, options, platform, () => {
const jwtClient = new jwt_client_1.JWTClient(platform, privKey, actor);
return jwtClient.getJWT();
});
this.baseUrl = baseUrl;
this.platform = platform;
this.privKey = privKey;
this.options = options;
}
getAll(data) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.GET_ALL, data, 'Unable to get Roles.');
});
}
getOne(id) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.GET_ONE, { id }, `Unable to get Role against id ${id}.`);
});
}
create(data) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.CREATE, data, 'Unable to create Role.');
});
}
createBulk(data) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.CREATE_BULK, data, 'Unable to create bulk Roles.');
});
}
update(data) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.UPDATE, data, `Unable to update Role against id ${data.id}.`);
});
}
bulkUpdate(data) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.BULK_UPDATE, data, `Unable to update bulk Roles.`);
});
}
delete(id) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.DELETE, { id }, `Unable to delete Role against id ${id}.`);
});
}
checkRolesExistenceByNames(names) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.CHECK_ROLES_EXISTENCE_BY_NAMES, { names }, `Unable to check existence of roles against given names list.`);
});
}
checkRolesExistenceByIds(ids) {
return __awaiter(this, void 0, void 0, function* () {
return this.sendApiRequest(api_config_1.API_ENDPOINTS.ROLE.CHECK_ROLES_EXISTENCE_BY_IDS, { ids }, `Unable to check existence of roles against given ids list.`);
});
}
}
exports.default = RolesApi;