"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 });
exports.IccUserApi = void 0;
/**
 * iCure Data Stack API Documentation
 * The iCure Data Stack Application API is the native interface to iCure. This version is obsolete, please use v2.
 *
 * OpenAPI spec version: v1
 *
 *
 * NOTE: This class is auto generated by the swagger code generator program.
 * https://github.com/swagger-api/swagger-codegen.git
 * Do not edit the class manually.
 */
const XHR_1 = require("./XHR");
const DocIdentifier_1 = require("../model/DocIdentifier");
const PaginatedListUser_1 = require("../model/PaginatedListUser");
const TokenWithGroup_1 = require("../model/TokenWithGroup");
const Unit_1 = require("../model/Unit");
const User_1 = require("../model/User");
const UserGroup_1 = require("../model/UserGroup");
const AuthenticationProvider_1 = require("../../icc-x-api/auth/AuthenticationProvider");
const IccRestApiPath_1 = require("./IccRestApiPath");
const ListOfIds_1 = require("../model/ListOfIds");
class IccUserApi {
    constructor(host, headers, authenticationProvider, fetchImpl) {
        this.host = (0, IccRestApiPath_1.iccRestApiPath)(host);
        this.headers = Object.keys(headers).map((k) => new XHR_1.XHR.Header(k, headers[k]));
        this.authenticationProvider = !!authenticationProvider ? authenticationProvider : new AuthenticationProvider_1.NoAuthenticationProvider();
        this.fetchImpl = fetchImpl;
    }
    setHeaders(h) {
        this.headers = h;
    }
    handleError(e) {
        throw e;
    }
    /**
     * UserDto gets returned.
     * @summary Assign a healthcare party ID to current user
     * @param healthcarePartyId
     */
    assignHealthcareParty(healthcarePartyId) {
        let _body = null;
        const _url = this.host + `/user/current/hcparty/${encodeURIComponent(String(healthcarePartyId))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Check token validity
     * @param userId
     * @param token
     */
    checkTokenValidity(userId, token) {
        let _body = null;
        const _url = this.host + `/user/token/${encodeURIComponent(String(userId))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        token && (headers = headers.concat(new XHR_1.XHR.Header('token', token)));
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.parse(JSON.stringify(doc.body)))
            .catch((err) => this.handleError(err));
    }
    /**
     * Create a user. HealthcareParty ID should be set. Email or Login have to be set. If login hasn't been set, Email will be used for Login instead.
     * @summary Create a user
     * @param body
     */
    createUser(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/user` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Create a user. HealthcareParty ID should be set. Email has to be set and the Login has to be null. On server-side, Email will be used for Login.
     * @summary Create a user
     * @param body
     * @param groupId
     */
    createUserInGroup(groupId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/user/inGroup/${encodeURIComponent(String(groupId))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * @summary Creates a new admin user in the group of the current user.
     * @param body the user to create.
     * @return a promise that will resolve to the created user.
     */
    createAdminUser(body) {
        const _url = this.host + `/user/admin` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * @summary Creates a new admin user in a group of the current user.
     * @param body the user to create.
     * @param groupId the id of the group where to create the user.
     * @return a promise that will resolve to the created user.
     */
    createAdminUserInGroup(groupId, body) {
        const _url = this.host + `/user/admin/inGroup/${encodeURIComponent(String(groupId))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Delete a User based on his/her ID. The return value is an array containing the ID of deleted user.
     * @summary Delete a User based on his/her ID.
     * @param userId
     */
    deleteUser(userId) {
        let _body = null;
        const _url = this.host + `/user/${encodeURIComponent(String(userId))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('DELETE', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new DocIdentifier_1.DocIdentifier(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Delete a User based on his/her ID. The return value is an array containing the ID of deleted user.
     * @summary Delete a User based on his/her ID.
     * @param groupId
     * @param userId
     */
    deleteUserInGroup(groupId, userId) {
        let _body = null;
        const _url = this.host + `/user/inGroup/${encodeURIComponent(String(groupId))}/${encodeURIComponent(String(userId))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('DELETE', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new Unit_1.Unit(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @param password
     */
    encodePassword(password) {
        let _body = null;
        const _url = this.host + `/user/encodePassword` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        password && (headers = headers.concat(new XHR_1.XHR.Header('password', password)));
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.parse(JSON.stringify(doc.body)))
            .catch((err) => this.handleError(err));
    }
    filterUsersBy(startDocumentId, limit, body, collectTiming = false) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/user/filter` +
            '?ts=' +
            new Date().getTime() +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService(), undefined, false, collectTiming ? ['x-filter-timing-*'] : [])
            .then((doc) => Object.assign(new PaginatedListUser_1.PaginatedListUser(doc.body), collectTiming ? { responseHeaders: doc.responseHeaders } : {}))
            .catch((err) => this.handleError(err));
    }
    filterUsersInGroupBy(groupId, startDocumentId, limit, body, collectTiming = false) {
        let _body = null;
        _body = body;
        const _url = this.host +
            `/user/filter/inGroup/${encodeURIComponent(String(groupId))}` +
            '?ts=' +
            new Date().getTime() +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService(), undefined, false, collectTiming ? ['x-filter-timing-*'] : [])
            .then((doc) => Object.assign(new PaginatedListUser_1.PaginatedListUser(doc.body), collectTiming ? { responseHeaders: doc.responseHeaders } : {}))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Get the list of users by healthcare party id
     * @param id
     */
    findByHcpartyId(id) {
        let _body = null;
        const _url = this.host + `/user/byHealthcarePartyId/${encodeURIComponent(String(id))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => JSON.parse(JSON.stringify(it))))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Get the list of users by patient id
     * @param id
     */
    findByPatientId(id) {
        let _body = null;
        const _url = this.host + `/user/byPatientId/${encodeURIComponent(String(id))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => JSON.parse(JSON.stringify(it))))
            .catch((err) => this.handleError(err));
    }
    /**
     * Get current user.
     * @summary Get presently logged-in user.
     */
    getCurrentUser() {
        let _body = null;
        const _url = this.host + `/user/current` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Get current user.
     * @summary Get presently logged-in user.
     */
    getMatchingUsers() {
        let _body = null;
        const _url = this.host + `/user/matches` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new UserGroup_1.UserGroup(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Request a new temporary token for authentication
     * @param userId
     * @param key The token key. Only one instance of a token with a defined key can exist at the same time
     * @param tokenValidity The token validity in seconds
     * @param token
     */
    getToken(userId, key, tokenValidity, token) {
        let _body = null;
        const _url = this.host +
            `/user/token/${encodeURIComponent(String(userId))}/${encodeURIComponent(String(key))}` +
            '?ts=' +
            new Date().getTime() +
            (tokenValidity ? '&tokenValidity=' + encodeURIComponent(String(tokenValidity)) : '');
        let headers = this.headers;
        token && (headers = headers.concat(new XHR_1.XHR.Header('token', token)));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.parse(JSON.stringify(doc.body)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Require a new temporary token for authentication inside all groups
     * @param userIdentifier
     * @param key The token key. Only one instance of a token with a defined key can exist at the same time
     * @param token
     * @param tokenValidity The token validity in seconds
     */
    getTokenInAllGroups(userIdentifier, key, token, tokenValidity) {
        let _body = null;
        const _url = this.host +
            `/user/inAllGroups/token/${encodeURIComponent(String(userIdentifier))}/${encodeURIComponent(String(key))}` +
            '?ts=' +
            new Date().getTime() +
            (tokenValidity ? '&tokenValidity=' + encodeURIComponent(String(tokenValidity)) : '');
        let headers = this.headers;
        token && (headers = headers.concat(new XHR_1.XHR.Header('token', token)));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => doc.body.map((it) => new TokenWithGroup_1.TokenWithGroup(it)))
            .catch((err) => this.handleError(err));
    }
    /**
     *
     * @summary Require a new temporary token for authentication inside provided group
     * @param groupId
     * @param userId
     * @param key The token key. Only one instance of a token with a defined key can exist at the same time
     * @param token
     * @param tokenValidity The token validity in seconds
     */
    getTokenInGroup(groupId, userId, key, token, tokenValidity) {
        let _body = null;
        const _url = this.host +
            `/user/inGroup/${encodeURIComponent(String(groupId))}/token/${encodeURIComponent(String(userId))}/${encodeURIComponent(String(key))}` +
            '?ts=' +
            new Date().getTime() +
            (tokenValidity ? '&tokenValidity=' + encodeURIComponent(String(tokenValidity)) : '');
        let headers = this.headers;
        token && (headers = headers.concat(new XHR_1.XHR.Header('token', token)));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.parse(JSON.stringify(doc.body)))
            .catch((err) => this.handleError(err));
    }
    /**
     * General information about the user
     * @summary Get a user by his ID
     * @param userId
     */
    getUser(userId) {
        let _body = null;
        const _url = this.host + `/user/${encodeURIComponent(String(userId))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * @summary Sets the roles of a user to the ones passed as parameter.
     *
     * @param userId the Id of the user to update.
     * @param roleIds the ids of the roles to add to the user.
     */
    setRoles(userId, roleIds) {
        const _body = new ListOfIds_1.ListOfIds({ ids: roleIds });
        const _url = this.host + `/user/${encodeURIComponent(userId)}/roles/set?ts=${new Date().getTime()}'`;
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.parse(JSON.stringify(doc.body)))
            .catch((err) => this.handleError(err));
    }
    /**
     * @summary Sets the roles of a user in a group to the ones passed as parameter.
     *
     * @param userId the Id of the user to update.
     * @param groupId the Id of the group the user belongs to.
     * @param roleIds the ids of the roles to add to the user.
     */
    setRolesInGroup(userId, groupId, roleIds) {
        const _body = new ListOfIds_1.ListOfIds({ ids: roleIds });
        const _url = this.host + `/user/${encodeURIComponent(userId)}/inGroup/${encodeURIComponent(groupId)}/roles/set?ts=${new Date().getTime()}'`;
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.parse(JSON.stringify(doc.body)))
            .catch((err) => this.handleError(err));
    }
    /**
     * @summary Reset the roles of a user to the default ones for their type.
     *
     * @param userId the Id of the user to update.
     */
    resetRoles(userId) {
        const _url = this.host + `/user/${encodeURIComponent(userId)}/roles/reset?ts=${new Date().getTime()}'`;
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.parse(JSON.stringify(doc.body)))
            .catch((err) => this.handleError(err));
    }
    /**
     * @summary Reset the roles of a user in a group to the default ones for their type.
     *
     * @param userId the Id of the user to update.
     * @param groupId the Id of the group the user belongs to.
     */
    resetRolesInGroup(userId, groupId) {
        const _url = this.host + `/user/${encodeURIComponent(userId)}/inGroup/${encodeURIComponent(groupId)}/roles/reset?ts=${new Date().getTime()}'`;
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => JSON.parse(JSON.stringify(doc.body)))
            .catch((err) => this.handleError(err));
    }
    /**
     * General information about the user
     * @summary Get a user by his Email/Login
     * @param email
     */
    getUserByEmail(email) {
        let _body = null;
        const _url = this.host + `/user/byEmail/${encodeURIComponent(String(email))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * @summary Get a user by his phone number.
     * @param phoneNumber
     * @return a promise that resolves to the specified user.
     */
    getUserByPhoneNumber(phoneNumber) {
        let _body = null;
        const _url = this.host + `/user/byPhoneNumber/${encodeURIComponent(String(phoneNumber))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of users.
     * @summary List users with(out) pagination
     * @param startKey An user email
     * @param startDocumentId An user document ID
     * @param limit Number of rows
     * @param skipPatients Filter out patient users
     */
    listUsers(startKey, startDocumentId, limit, skipPatients) {
        let _body = null;
        const _url = this.host +
            `/user` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '') +
            (skipPatients !== undefined ? '&skipPatients=' + encodeURIComponent(String(skipPatients)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListUser_1.PaginatedListUser(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * Returns a list of users.
     * @summary List users with pagination
     * @param groupId
     * @param startKey An user login
     * @param startDocumentId An user document ID
     * @param limit Number of rows
     */
    listUsersInGroup(groupId, startKey, startDocumentId, limit) {
        let _body = null;
        const _url = this.host +
            `/user/inGroup/${encodeURIComponent(String(groupId))}` +
            '?ts=' +
            new Date().getTime() +
            (startKey ? '&startKey=' + encodeURIComponent(String(startKey)) : '') +
            (startDocumentId ? '&startDocumentId=' + encodeURIComponent(String(startDocumentId)) : '') +
            (limit ? '&limit=' + encodeURIComponent(String(limit)) : '');
        let headers = this.headers;
        return XHR_1.XHR.sendCommand('GET', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new PaginatedListUser_1.PaginatedListUser(doc.body))
            .catch((err) => this.handleError(err));
    }
    matchUsersBy(body, collectTiming = false) {
        let _body = null;
        _body = body;
        const _url = this.host + `/user/match` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService(), undefined, false, collectTiming ? ['x-filter-timing-*'] : [])
            .then((doc) => Object.assign(doc.body.map((it) => JSON.parse(JSON.stringify(it))), collectTiming ? { responseHeaders: doc.responseHeaders } : {}))
            .catch((err) => this.handleError(err));
    }
    /**
     * Modify a User properties based on his/her ID. The return value is the modified user.
     * @summary Modify a User property
     * @param body
     * @param userId
     */
    modifyProperties(userId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/user/${encodeURIComponent(String(userId))}/properties` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * No particular return value. It's just a message.
     * @summary Modify a user.
     * @param body
     */
    modifyUser(body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/user` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    /**
     * No particular return value. It's just a message.
     * @summary Modify a user.
     * @param body
     * @param groupId
     */
    modifyUserInGroup(groupId, body) {
        let _body = null;
        _body = body;
        const _url = this.host + `/user/inGroup/${encodeURIComponent(String(groupId))}` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('PUT', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    enable2fa(userId, secret) {
        let _body = { secret };
        const _url = this.host + `/user/${encodeURIComponent(String(userId))}/2fa` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then(() => { })
            .catch((err) => this.handleError(err));
    }
    enableFasAuthenticationForUser(fasJwtToken) {
        let _body = null;
        const _url = this.host + `/user/current/be.fas` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        fasJwtToken && (headers = headers.concat(new XHR_1.XHR.Header('fasJwtToken', fasJwtToken)));
        return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    revokeFasAuthenticationForUser(fasJwtToken) {
        let _body = null;
        const _url = this.host + `/user/current/be.fas` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        fasJwtToken && (headers = headers.concat(new XHR_1.XHR.Header('fasJwtToken', fasJwtToken)));
        return XHR_1.XHR.sendCommand('DELETE', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then((doc) => new User_1.User(doc.body))
            .catch((err) => this.handleError(err));
    }
    disable2fa(userId) {
        const _url = this.host + `/user/${encodeURIComponent(String(userId))}/2fa` + '?ts=' + new Date().getTime();
        let headers = this.headers;
        headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
        return XHR_1.XHR.sendCommand('DELETE', _url, headers, null, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
            .then(() => { })
            .catch((err) => this.handleError(err));
    }
    getUsers(body) {
        return __awaiter(this, void 0, void 0, function* () {
            let _body = null;
            _body = body;
            const _url = this.host + `/user/byIds` + '?ts=' + new Date().getTime();
            let headers = yield this.headers;
            headers = headers.filter((h) => h.header !== 'Content-Type').concat(new XHR_1.XHR.Header('Content-Type', 'application/json'));
            return XHR_1.XHR.sendCommand('POST', _url, headers, _body, this.fetchImpl, undefined, this.authenticationProvider.getAuthService())
                .then((doc) => doc.body.map((it) => new User_1.User(it)))
                .catch((err) => this.handleError(err));
        });
    }
}
exports.IccUserApi = IccUserApi;
//# sourceMappingURL=IccUserApi.js.map