/* tslint:disable */
/* eslint-disable */
/**
 * OmsorgCore.Api
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 1.0
 * 
 *
 * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
 * https://openapi-generator.tech
 * Do not edit the class manually.
 */


import * as runtime from '../runtime';
import type {
  AddUserPermissionOverrideRequest,
  CreateUserRequest,
  ResetUserPasswordRequest,
  UpdateUserRequest,
  UserPermissionOverrideResponse,
  UserResponse,
} from '../models/index';
import {
    AddUserPermissionOverrideRequestFromJSON,
    AddUserPermissionOverrideRequestToJSON,
    CreateUserRequestFromJSON,
    CreateUserRequestToJSON,
    ResetUserPasswordRequestFromJSON,
    ResetUserPasswordRequestToJSON,
    UpdateUserRequestFromJSON,
    UpdateUserRequestToJSON,
    UserPermissionOverrideResponseFromJSON,
    UserPermissionOverrideResponseToJSON,
    UserResponseFromJSON,
    UserResponseToJSON,
} from '../models/index';

export interface ApiUsersIdPermissionOverridesGetRequest {
    id: string;
}

export interface ApiUsersIdPermissionOverridesOverrideIdDeleteRequest {
    id: string;
    overrideId: string;
}

export interface ApiUsersIdPermissionOverridesPostRequest {
    id: string;
    addUserPermissionOverrideRequest?: AddUserPermissionOverrideRequest;
}

export interface ApiUsersIdPutRequest {
    id: string;
    updateUserRequest?: UpdateUserRequest;
}

export interface ApiUsersIdResetPasswordPostRequest {
    id: string;
    resetUserPasswordRequest?: ResetUserPasswordRequest;
}

export interface ApiUsersPostRequest {
    createUserRequest?: CreateUserRequest;
}

/**
 * 
 */
export class UsersApi extends runtime.BaseAPI {

    /**
     */
    async apiUsersGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<UserResponse>>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("Bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/api/users`;

        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UserResponseFromJSON));
    }

    /**
     */
    async apiUsersGet(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<UserResponse>> {
        const response = await this.apiUsersGetRaw(initOverrides);
        return await response.value();
    }

    /**
     */
    async apiUsersIdPermissionOverridesGetRaw(requestParameters: ApiUsersIdPermissionOverridesGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<UserPermissionOverrideResponse>>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling apiUsersIdPermissionOverridesGet().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("Bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/api/users/{id}/permission-overrides`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));

        const response = await this.request({
            path: urlPath,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => jsonValue.map(UserPermissionOverrideResponseFromJSON));
    }

    /**
     */
    async apiUsersIdPermissionOverridesGet(requestParameters: ApiUsersIdPermissionOverridesGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<UserPermissionOverrideResponse>> {
        const response = await this.apiUsersIdPermissionOverridesGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiUsersIdPermissionOverridesOverrideIdDeleteRaw(requestParameters: ApiUsersIdPermissionOverridesOverrideIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling apiUsersIdPermissionOverridesOverrideIdDelete().'
            );
        }

        if (requestParameters['overrideId'] == null) {
            throw new runtime.RequiredError(
                'overrideId',
                'Required parameter "overrideId" was null or undefined when calling apiUsersIdPermissionOverridesOverrideIdDelete().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("Bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/api/users/{id}/permission-overrides/{overrideId}`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));
        urlPath = urlPath.replace(`{${"overrideId"}}`, encodeURIComponent(String(requestParameters['overrideId'])));

        const response = await this.request({
            path: urlPath,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     */
    async apiUsersIdPermissionOverridesOverrideIdDelete(requestParameters: ApiUsersIdPermissionOverridesOverrideIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiUsersIdPermissionOverridesOverrideIdDeleteRaw(requestParameters, initOverrides);
    }

    /**
     */
    async apiUsersIdPermissionOverridesPostRaw(requestParameters: ApiUsersIdPermissionOverridesPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserPermissionOverrideResponse>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling apiUsersIdPermissionOverridesPost().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("Bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/api/users/{id}/permission-overrides`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));

        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: AddUserPermissionOverrideRequestToJSON(requestParameters['addUserPermissionOverrideRequest']),
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => UserPermissionOverrideResponseFromJSON(jsonValue));
    }

    /**
     */
    async apiUsersIdPermissionOverridesPost(requestParameters: ApiUsersIdPermissionOverridesPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserPermissionOverrideResponse> {
        const response = await this.apiUsersIdPermissionOverridesPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiUsersIdPutRaw(requestParameters: ApiUsersIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling apiUsersIdPut().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("Bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/api/users/{id}`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));

        const response = await this.request({
            path: urlPath,
            method: 'PUT',
            headers: headerParameters,
            query: queryParameters,
            body: UpdateUserRequestToJSON(requestParameters['updateUserRequest']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     */
    async apiUsersIdPut(requestParameters: ApiUsersIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiUsersIdPutRaw(requestParameters, initOverrides);
    }

    /**
     */
    async apiUsersIdResetPasswordPostRaw(requestParameters: ApiUsersIdResetPasswordPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling apiUsersIdResetPasswordPost().'
            );
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("Bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/api/users/{id}/reset-password`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));

        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: ResetUserPasswordRequestToJSON(requestParameters['resetUserPasswordRequest']),
        }, initOverrides);

        return new runtime.VoidApiResponse(response);
    }

    /**
     */
    async apiUsersIdResetPasswordPost(requestParameters: ApiUsersIdResetPasswordPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiUsersIdResetPasswordPostRaw(requestParameters, initOverrides);
    }

    /**
     */
    async apiUsersPostRaw(requestParameters: ApiUsersPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<UserResponse>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        if (this.configuration && this.configuration.accessToken) {
            const token = this.configuration.accessToken;
            const tokenString = await token("Bearer", []);

            if (tokenString) {
                headerParameters["Authorization"] = `Bearer ${tokenString}`;
            }
        }

        let urlPath = `/api/users`;

        const response = await this.request({
            path: urlPath,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: CreateUserRequestToJSON(requestParameters['createUserRequest']),
        }, initOverrides);

        return new runtime.JSONApiResponse(response, (jsonValue) => UserResponseFromJSON(jsonValue));
    }

    /**
     */
    async apiUsersPost(requestParameters: ApiUsersPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<UserResponse> {
        const response = await this.apiUsersPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
