/* 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 {
  CreateValueListItemRequest,
  UpdateValueListItemRequest,
  ValueListItemResponse,
  ValueListResponse,
  ValueListTransitionRequest,
  ValueListTransitionResponse,
  ValueListUsageResponse,
} from '../models/index';
import {
    CreateValueListItemRequestFromJSON,
    CreateValueListItemRequestToJSON,
    UpdateValueListItemRequestFromJSON,
    UpdateValueListItemRequestToJSON,
    ValueListItemResponseFromJSON,
    ValueListItemResponseToJSON,
    ValueListResponseFromJSON,
    ValueListResponseToJSON,
    ValueListTransitionRequestFromJSON,
    ValueListTransitionRequestToJSON,
    ValueListTransitionResponseFromJSON,
    ValueListTransitionResponseToJSON,
    ValueListUsageResponseFromJSON,
    ValueListUsageResponseToJSON,
} from '../models/index';

export interface ApiValueListsKeyItemsGetRequest {
    key: string;
}

export interface ApiValueListsKeyItemsIdDeleteRequest {
    key: string;
    id: string;
}

export interface ApiValueListsKeyItemsIdPutRequest {
    key: string;
    id: string;
    updateValueListItemRequest?: UpdateValueListItemRequest;
}

export interface ApiValueListsKeyItemsIdUsagesGetRequest {
    key: string;
    id: string;
}

export interface ApiValueListsKeyItemsPostRequest {
    key: string;
    createValueListItemRequest?: CreateValueListItemRequest;
}

export interface ApiValueListsKeyTransitionsGetRequest {
    key: string;
}

export interface ApiValueListsKeyTransitionsPutRequest {
    key: string;
    valueListTransitionRequest?: Array<ValueListTransitionRequest>;
}

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

    /**
     */
    async apiValueListsGetRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ValueListResponse>>> {
        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/value-lists`;

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

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

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

    /**
     */
    async apiValueListsKeyItemsGetRaw(requestParameters: ApiValueListsKeyItemsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ValueListItemResponse>>> {
        if (requestParameters['key'] == null) {
            throw new runtime.RequiredError(
                'key',
                'Required parameter "key" was null or undefined when calling apiValueListsKeyItemsGet().'
            );
        }

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

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

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

    /**
     */
    async apiValueListsKeyItemsGet(requestParameters: ApiValueListsKeyItemsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ValueListItemResponse>> {
        const response = await this.apiValueListsKeyItemsGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiValueListsKeyItemsIdDeleteRaw(requestParameters: ApiValueListsKeyItemsIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['key'] == null) {
            throw new runtime.RequiredError(
                'key',
                'Required parameter "key" was null or undefined when calling apiValueListsKeyItemsIdDelete().'
            );
        }

        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling apiValueListsKeyItemsIdDelete().'
            );
        }

        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/value-lists/{key}/items/{id}`;
        urlPath = urlPath.replace(`{${"key"}}`, encodeURIComponent(String(requestParameters['key'])));
        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 apiValueListsKeyItemsIdDelete(requestParameters: ApiValueListsKeyItemsIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiValueListsKeyItemsIdDeleteRaw(requestParameters, initOverrides);
    }

    /**
     */
    async apiValueListsKeyItemsIdPutRaw(requestParameters: ApiValueListsKeyItemsIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ValueListItemResponse>> {
        if (requestParameters['key'] == null) {
            throw new runtime.RequiredError(
                'key',
                'Required parameter "key" was null or undefined when calling apiValueListsKeyItemsIdPut().'
            );
        }

        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling apiValueListsKeyItemsIdPut().'
            );
        }

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

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

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

    /**
     */
    async apiValueListsKeyItemsIdPut(requestParameters: ApiValueListsKeyItemsIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ValueListItemResponse> {
        const response = await this.apiValueListsKeyItemsIdPutRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiValueListsKeyItemsIdUsagesGetRaw(requestParameters: ApiValueListsKeyItemsIdUsagesGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ValueListUsageResponse>>> {
        if (requestParameters['key'] == null) {
            throw new runtime.RequiredError(
                'key',
                'Required parameter "key" was null or undefined when calling apiValueListsKeyItemsIdUsagesGet().'
            );
        }

        if (requestParameters['id'] == null) {
            throw new runtime.RequiredError(
                'id',
                'Required parameter "id" was null or undefined when calling apiValueListsKeyItemsIdUsagesGet().'
            );
        }

        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/value-lists/{key}/items/{id}/usages`;
        urlPath = urlPath.replace(`{${"key"}}`, encodeURIComponent(String(requestParameters['key'])));
        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) => jsonValue.map(ValueListUsageResponseFromJSON));
    }

    /**
     */
    async apiValueListsKeyItemsIdUsagesGet(requestParameters: ApiValueListsKeyItemsIdUsagesGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ValueListUsageResponse>> {
        const response = await this.apiValueListsKeyItemsIdUsagesGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiValueListsKeyItemsPostRaw(requestParameters: ApiValueListsKeyItemsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ValueListItemResponse>> {
        if (requestParameters['key'] == null) {
            throw new runtime.RequiredError(
                'key',
                'Required parameter "key" was null or undefined when calling apiValueListsKeyItemsPost().'
            );
        }

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

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

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

    /**
     */
    async apiValueListsKeyItemsPost(requestParameters: ApiValueListsKeyItemsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ValueListItemResponse> {
        const response = await this.apiValueListsKeyItemsPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiValueListsKeyTransitionsGetRaw(requestParameters: ApiValueListsKeyTransitionsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<ValueListTransitionResponse>>> {
        if (requestParameters['key'] == null) {
            throw new runtime.RequiredError(
                'key',
                'Required parameter "key" was null or undefined when calling apiValueListsKeyTransitionsGet().'
            );
        }

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

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

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

    /**
     */
    async apiValueListsKeyTransitionsGet(requestParameters: ApiValueListsKeyTransitionsGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<ValueListTransitionResponse>> {
        const response = await this.apiValueListsKeyTransitionsGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiValueListsKeyTransitionsPutRaw(requestParameters: ApiValueListsKeyTransitionsPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<void>> {
        if (requestParameters['key'] == null) {
            throw new runtime.RequiredError(
                'key',
                'Required parameter "key" was null or undefined when calling apiValueListsKeyTransitionsPut().'
            );
        }

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

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

        return new runtime.VoidApiResponse(response);
    }

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

}
