/* 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 {
  AbsenceDecisionRequest,
  AbsenceResponse,
  AbsenceResponsePagedResponse,
  CreateAbsenceRequest,
  UpdateAbsenceRequest,
} from '../models/index';
import {
    AbsenceDecisionRequestFromJSON,
    AbsenceDecisionRequestToJSON,
    AbsenceResponseFromJSON,
    AbsenceResponseToJSON,
    AbsenceResponsePagedResponseFromJSON,
    AbsenceResponsePagedResponseToJSON,
    CreateAbsenceRequestFromJSON,
    CreateAbsenceRequestToJSON,
    UpdateAbsenceRequestFromJSON,
    UpdateAbsenceRequestToJSON,
} from '../models/index';

export interface ApiAbsencesGetRequest {
    status?: string;
    type?: string;
    employeeId?: string;
    page?: number;
    pageSize?: number;
}

export interface ApiAbsencesIdDecisionPostRequest {
    id: string;
    absenceDecisionRequest?: AbsenceDecisionRequest;
}

export interface ApiAbsencesIdDeleteRequest {
    id: string;
}

export interface ApiAbsencesIdGetRequest {
    id: string;
}

export interface ApiAbsencesIdPutRequest {
    id: string;
    updateAbsenceRequest?: UpdateAbsenceRequest;
}

export interface ApiAbsencesPostRequest {
    createAbsenceRequest?: CreateAbsenceRequest;
}

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

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

        if (requestParameters['status'] != null) {
            queryParameters['status'] = requestParameters['status'];
        }

        if (requestParameters['type'] != null) {
            queryParameters['type'] = requestParameters['type'];
        }

        if (requestParameters['employeeId'] != null) {
            queryParameters['employeeId'] = requestParameters['employeeId'];
        }

        if (requestParameters['page'] != null) {
            queryParameters['page'] = requestParameters['page'];
        }

        if (requestParameters['pageSize'] != null) {
            queryParameters['pageSize'] = requestParameters['pageSize'];
        }

        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/absences`;

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

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

    /**
     */
    async apiAbsencesGet(requestParameters: ApiAbsencesGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AbsenceResponsePagedResponse> {
        const response = await this.apiAbsencesGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

        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/absences/{id}/decision`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));

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

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

    /**
     */
    async apiAbsencesIdDecisionPost(requestParameters: ApiAbsencesIdDecisionPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AbsenceResponse> {
        const response = await this.apiAbsencesIdDecisionPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiAbsencesIdDeleteRaw(requestParameters: ApiAbsencesIdDeleteRequest, 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 apiAbsencesIdDelete().'
            );
        }

        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/absences/{id}`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));

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

        return new runtime.VoidApiResponse(response);
    }

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

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

        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/absences/{id}`;
        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) => AbsenceResponseFromJSON(jsonValue));
    }

    /**
     */
    async apiAbsencesIdGet(requestParameters: ApiAbsencesIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AbsenceResponse> {
        const response = await this.apiAbsencesIdGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

        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/absences/{id}`;
        urlPath = urlPath.replace(`{${"id"}}`, encodeURIComponent(String(requestParameters['id'])));

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

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

    /**
     */
    async apiAbsencesIdPut(requestParameters: ApiAbsencesIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AbsenceResponse> {
        const response = await this.apiAbsencesIdPutRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiAbsencesPostRaw(requestParameters: ApiAbsencesPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AbsenceResponse>> {
        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/absences`;

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

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

    /**
     */
    async apiAbsencesPost(requestParameters: ApiAbsencesPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AbsenceResponse> {
        const response = await this.apiAbsencesPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
