/* 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 {
  CreateOrderRequest,
  OrderResponse,
  OrderResponsePagedResponse,
  UpdateOrderRequest,
} from '../models/index';
import {
    CreateOrderRequestFromJSON,
    CreateOrderRequestToJSON,
    OrderResponseFromJSON,
    OrderResponseToJSON,
    OrderResponsePagedResponseFromJSON,
    OrderResponsePagedResponseToJSON,
    UpdateOrderRequestFromJSON,
    UpdateOrderRequestToJSON,
} from '../models/index';

export interface ApiOrdersGetRequest {
    search?: string;
    statusId?: string;
    facilityId?: string;
    priority?: string;
    requiredQualification?: string;
    shiftType?: string;
    page?: number;
    pageSize?: number;
}

export interface ApiOrdersIdDeleteRequest {
    id: string;
}

export interface ApiOrdersIdGetRequest {
    id: string;
}

export interface ApiOrdersIdPutRequest {
    id: string;
    updateOrderRequest?: UpdateOrderRequest;
}

export interface ApiOrdersPostRequest {
    createOrderRequest?: CreateOrderRequest;
}

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

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

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

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

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

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

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

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

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

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

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

    /**
     */
    async apiOrdersGet(requestParameters: ApiOrdersGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrderResponsePagedResponse> {
        const response = await this.apiOrdersGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiOrdersIdDeleteRaw(requestParameters: ApiOrdersIdDeleteRequest, 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 apiOrdersIdDelete().'
            );
        }

        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/orders/{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 apiOrdersIdDelete(requestParameters: ApiOrdersIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiOrdersIdDeleteRaw(requestParameters, initOverrides);
    }

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

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

    /**
     */
    async apiOrdersIdGet(requestParameters: ApiOrdersIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrderResponse> {
        const response = await this.apiOrdersIdGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

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

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

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

    /**
     */
    async apiOrdersIdPut(requestParameters: ApiOrdersIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrderResponse> {
        const response = await this.apiOrdersIdPutRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiOrdersPostRaw(requestParameters: ApiOrdersPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<OrderResponse>> {
        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/orders`;

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

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

    /**
     */
    async apiOrdersPost(requestParameters: ApiOrdersPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<OrderResponse> {
        const response = await this.apiOrdersPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
