/* 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 {
  CreateTimeEntryRequest,
  TimeEntryDecisionRequest,
  TimeEntryResponse,
  TimeEntryResponsePagedResponse,
  UpdateTimeEntryRequest,
} from '../models/index';
import {
    CreateTimeEntryRequestFromJSON,
    CreateTimeEntryRequestToJSON,
    TimeEntryDecisionRequestFromJSON,
    TimeEntryDecisionRequestToJSON,
    TimeEntryResponseFromJSON,
    TimeEntryResponseToJSON,
    TimeEntryResponsePagedResponseFromJSON,
    TimeEntryResponsePagedResponseToJSON,
    UpdateTimeEntryRequestFromJSON,
    UpdateTimeEntryRequestToJSON,
} from '../models/index';

export interface ApiTimeEntriesGetRequest {
    statusId?: string;
    employeeId?: string;
    orderId?: string;
    page?: number;
    pageSize?: number;
}

export interface ApiTimeEntriesIdDecisionPostRequest {
    id: string;
    timeEntryDecisionRequest?: TimeEntryDecisionRequest;
}

export interface ApiTimeEntriesIdDeleteRequest {
    id: string;
}

export interface ApiTimeEntriesIdGetRequest {
    id: string;
}

export interface ApiTimeEntriesIdPutRequest {
    id: string;
    updateTimeEntryRequest?: UpdateTimeEntryRequest;
}

export interface ApiTimeEntriesIdSubmitPostRequest {
    id: string;
}

export interface ApiTimeEntriesPostRequest {
    createTimeEntryRequest?: CreateTimeEntryRequest;
}

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

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

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

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

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

        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/time-entries`;

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

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

    /**
     */
    async apiTimeEntriesGet(requestParameters: ApiTimeEntriesGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimeEntryResponsePagedResponse> {
        const response = await this.apiTimeEntriesGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

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

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

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

    /**
     */
    async apiTimeEntriesIdDecisionPost(requestParameters: ApiTimeEntriesIdDecisionPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimeEntryResponse> {
        const response = await this.apiTimeEntriesIdDecisionPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiTimeEntriesIdDeleteRaw(requestParameters: ApiTimeEntriesIdDeleteRequest, 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 apiTimeEntriesIdDelete().'
            );
        }

        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/time-entries/{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 apiTimeEntriesIdDelete(requestParameters: ApiTimeEntriesIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiTimeEntriesIdDeleteRaw(requestParameters, initOverrides);
    }

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

        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/time-entries/{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) => TimeEntryResponseFromJSON(jsonValue));
    }

    /**
     */
    async apiTimeEntriesIdGet(requestParameters: ApiTimeEntriesIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimeEntryResponse> {
        const response = await this.apiTimeEntriesIdGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

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

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

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

    /**
     */
    async apiTimeEntriesIdPut(requestParameters: ApiTimeEntriesIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimeEntryResponse> {
        const response = await this.apiTimeEntriesIdPutRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

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

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

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

    /**
     */
    async apiTimeEntriesIdSubmitPost(requestParameters: ApiTimeEntriesIdSubmitPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimeEntryResponse> {
        const response = await this.apiTimeEntriesIdSubmitPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiTimeEntriesPostRaw(requestParameters: ApiTimeEntriesPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<TimeEntryResponse>> {
        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/time-entries`;

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

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

    /**
     */
    async apiTimeEntriesPost(requestParameters: ApiTimeEntriesPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<TimeEntryResponse> {
        const response = await this.apiTimeEntriesPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
