/* 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 {
  CreateMyFacilityDistanceRequest,
  FacilityOptionResponse,
  MyFacilityDistanceResponse,
  UpdateMyFacilityDistanceRequest,
} from '../models/index';
import {
    CreateMyFacilityDistanceRequestFromJSON,
    CreateMyFacilityDistanceRequestToJSON,
    FacilityOptionResponseFromJSON,
    FacilityOptionResponseToJSON,
    MyFacilityDistanceResponseFromJSON,
    MyFacilityDistanceResponseToJSON,
    UpdateMyFacilityDistanceRequestFromJSON,
    UpdateMyFacilityDistanceRequestToJSON,
} from '../models/index';

export interface ApiMeFacilityDistancesIdPutRequest {
    id: string;
    updateMyFacilityDistanceRequest?: UpdateMyFacilityDistanceRequest;
}

export interface ApiMeFacilityDistancesPostRequest {
    createMyFacilityDistanceRequest?: CreateMyFacilityDistanceRequest;
}

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

    /**
     */
    async apiMeFacilityDistancesFacilitiesGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<FacilityOptionResponse>>> {
        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/me/facility-distances/facilities`;

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

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

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

    /**
     */
    async apiMeFacilityDistancesGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<MyFacilityDistanceResponse>>> {
        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/me/facility-distances`;

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

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

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

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

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

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

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

    /**
     */
    async apiMeFacilityDistancesIdPut(requestParameters: ApiMeFacilityDistancesIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MyFacilityDistanceResponse> {
        const response = await this.apiMeFacilityDistancesIdPutRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiMeFacilityDistancesPostRaw(requestParameters: ApiMeFacilityDistancesPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<MyFacilityDistanceResponse>> {
        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/me/facility-distances`;

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

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

    /**
     */
    async apiMeFacilityDistancesPost(requestParameters: ApiMeFacilityDistancesPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<MyFacilityDistanceResponse> {
        const response = await this.apiMeFacilityDistancesPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
