/* 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 {
  ContractResponse,
  ContractResponsePagedResponse,
  CreateContractRequest,
  UpdateContractRequest,
} from '../models/index';
import {
    ContractResponseFromJSON,
    ContractResponseToJSON,
    ContractResponsePagedResponseFromJSON,
    ContractResponsePagedResponseToJSON,
    CreateContractRequestFromJSON,
    CreateContractRequestToJSON,
    UpdateContractRequestFromJSON,
    UpdateContractRequestToJSON,
} from '../models/index';

export interface ApiContractsGetRequest {
    search?: string;
    status?: string;
    employeeId?: string;
    facilityId?: string;
    page?: number;
    pageSize?: number;
}

export interface ApiContractsIdDeleteRequest {
    id: string;
}

export interface ApiContractsIdGetRequest {
    id: string;
}

export interface ApiContractsIdPutRequest {
    id: string;
    updateContractRequest?: UpdateContractRequest;
}

export interface ApiContractsPostRequest {
    createContractRequest?: CreateContractRequest;
}

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

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

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

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

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

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

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

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

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

    /**
     */
    async apiContractsGet(requestParameters: ApiContractsGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ContractResponsePagedResponse> {
        const response = await this.apiContractsGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiContractsIdDeleteRaw(requestParameters: ApiContractsIdDeleteRequest, 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 apiContractsIdDelete().'
            );
        }

        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/contracts/{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 apiContractsIdDelete(requestParameters: ApiContractsIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiContractsIdDeleteRaw(requestParameters, initOverrides);
    }

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

        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/contracts/{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) => ContractResponseFromJSON(jsonValue));
    }

    /**
     */
    async apiContractsIdGet(requestParameters: ApiContractsIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ContractResponse> {
        const response = await this.apiContractsIdGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

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

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

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

    /**
     */
    async apiContractsIdPut(requestParameters: ApiContractsIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ContractResponse> {
        const response = await this.apiContractsIdPutRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiContractsPostRaw(requestParameters: ApiContractsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ContractResponse>> {
        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/contracts`;

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

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

    /**
     */
    async apiContractsPost(requestParameters: ApiContractsPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ContractResponse> {
        const response = await this.apiContractsPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
