/* 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 {
  CreateFacilityRequest,
  FacilityResponse,
  FacilityResponsePagedResponse,
  UpdateFacilityRequest,
} from '../models/index';
import {
    CreateFacilityRequestFromJSON,
    CreateFacilityRequestToJSON,
    FacilityResponseFromJSON,
    FacilityResponseToJSON,
    FacilityResponsePagedResponseFromJSON,
    FacilityResponsePagedResponseToJSON,
    UpdateFacilityRequestFromJSON,
    UpdateFacilityRequestToJSON,
} from '../models/index';

export interface ApiFacilitiesGetRequest {
    search?: string;
    crmStatus?: string;
    followUpDueOnly?: boolean;
    page?: number;
    pageSize?: number;
}

export interface ApiFacilitiesIdDeleteRequest {
    id: string;
}

export interface ApiFacilitiesIdGetRequest {
    id: string;
}

export interface ApiFacilitiesIdPutRequest {
    id: string;
    updateFacilityRequest?: UpdateFacilityRequest;
}

export interface ApiFacilitiesPostRequest {
    createFacilityRequest?: CreateFacilityRequest;
}

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

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

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

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

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

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

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

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

    /**
     */
    async apiFacilitiesGet(requestParameters: ApiFacilitiesGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FacilityResponsePagedResponse> {
        const response = await this.apiFacilitiesGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiFacilitiesIdDeleteRaw(requestParameters: ApiFacilitiesIdDeleteRequest, 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 apiFacilitiesIdDelete().'
            );
        }

        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/facilities/{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 apiFacilitiesIdDelete(requestParameters: ApiFacilitiesIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiFacilitiesIdDeleteRaw(requestParameters, initOverrides);
    }

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

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

    /**
     */
    async apiFacilitiesIdGet(requestParameters: ApiFacilitiesIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FacilityResponse> {
        const response = await this.apiFacilitiesIdGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

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

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

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

    /**
     */
    async apiFacilitiesIdPut(requestParameters: ApiFacilitiesIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FacilityResponse> {
        const response = await this.apiFacilitiesIdPutRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiFacilitiesPostRaw(requestParameters: ApiFacilitiesPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FacilityResponse>> {
        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/facilities`;

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

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

    /**
     */
    async apiFacilitiesPost(requestParameters: ApiFacilitiesPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FacilityResponse> {
        const response = await this.apiFacilitiesPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
