/* 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 {
  AssignmentConflictResponse,
  AssignmentResponse,
  AssignmentResponsePagedResponse,
  CreateAssignmentRequest,
  UpdateAssignmentRequest,
} from '../models/index';
import {
    AssignmentConflictResponseFromJSON,
    AssignmentConflictResponseToJSON,
    AssignmentResponseFromJSON,
    AssignmentResponseToJSON,
    AssignmentResponsePagedResponseFromJSON,
    AssignmentResponsePagedResponseToJSON,
    CreateAssignmentRequestFromJSON,
    CreateAssignmentRequestToJSON,
    UpdateAssignmentRequestFromJSON,
    UpdateAssignmentRequestToJSON,
} from '../models/index';

export interface ApiAssignmentsCheckGetRequest {
    orderId?: string;
    employeeId?: string;
    startDate?: Date;
    endDate?: Date;
    excludeAssignmentId?: string;
}

export interface ApiAssignmentsGetRequest {
    orderId?: string;
    employeeId?: string;
    fromDate?: Date;
    toDate?: Date;
    page?: number;
    pageSize?: number;
}

export interface ApiAssignmentsIdDeleteRequest {
    id: string;
}

export interface ApiAssignmentsIdGetRequest {
    id: string;
}

export interface ApiAssignmentsIdPutRequest {
    id: string;
    updateAssignmentRequest?: UpdateAssignmentRequest;
}

export interface ApiAssignmentsPostRequest {
    createAssignmentRequest?: CreateAssignmentRequest;
}

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

    /**
     */
    async apiAssignmentsCheckGetRaw(requestParameters: ApiAssignmentsCheckGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<AssignmentConflictResponse>>> {
        const queryParameters: any = {};

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

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

        if (requestParameters['startDate'] != null) {
            queryParameters['startDate'] = (requestParameters['startDate'] as any).toISOString().substring(0,10);
        }

        if (requestParameters['endDate'] != null) {
            queryParameters['endDate'] = (requestParameters['endDate'] as any).toISOString().substring(0,10);
        }

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

        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/assignments/check`;

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

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

    /**
     */
    async apiAssignmentsCheckGet(requestParameters: ApiAssignmentsCheckGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Array<AssignmentConflictResponse>> {
        const response = await this.apiAssignmentsCheckGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

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

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

        if (requestParameters['fromDate'] != null) {
            queryParameters['fromDate'] = (requestParameters['fromDate'] as any).toISOString().substring(0,10);
        }

        if (requestParameters['toDate'] != null) {
            queryParameters['toDate'] = (requestParameters['toDate'] as any).toISOString().substring(0,10);
        }

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

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

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

    /**
     */
    async apiAssignmentsGet(requestParameters: ApiAssignmentsGetRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AssignmentResponsePagedResponse> {
        const response = await this.apiAssignmentsGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiAssignmentsIdDeleteRaw(requestParameters: ApiAssignmentsIdDeleteRequest, 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 apiAssignmentsIdDelete().'
            );
        }

        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/assignments/{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 apiAssignmentsIdDelete(requestParameters: ApiAssignmentsIdDeleteRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<void> {
        await this.apiAssignmentsIdDeleteRaw(requestParameters, initOverrides);
    }

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

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

    /**
     */
    async apiAssignmentsIdGet(requestParameters: ApiAssignmentsIdGetRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AssignmentResponse> {
        const response = await this.apiAssignmentsIdGetRaw(requestParameters, initOverrides);
        return await response.value();
    }

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

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

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

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

    /**
     */
    async apiAssignmentsIdPut(requestParameters: ApiAssignmentsIdPutRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AssignmentResponse> {
        const response = await this.apiAssignmentsIdPutRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async apiAssignmentsPostRaw(requestParameters: ApiAssignmentsPostRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<AssignmentResponse>> {
        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/assignments`;

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

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

    /**
     */
    async apiAssignmentsPost(requestParameters: ApiAssignmentsPostRequest = {}, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<AssignmentResponse> {
        const response = await this.apiAssignmentsPostRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
