/* tslint:disable */
/* eslint-disable */
/**
 * Montelo
 * Documentation for the Montelo API.
 *
 * 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 {
  DeleteSuccessDto,
  FullProjectDto,
  ProjectDto,
  SetCohereApiKeyInput,
  SetOpenaiApiKeyInput,
} from '../models/index';
import {
    DeleteSuccessDtoFromJSON,
    DeleteSuccessDtoToJSON,
    FullProjectDtoFromJSON,
    FullProjectDtoToJSON,
    ProjectDtoFromJSON,
    ProjectDtoToJSON,
    SetCohereApiKeyInputFromJSON,
    SetCohereApiKeyInputToJSON,
    SetOpenaiApiKeyInputFromJSON,
    SetOpenaiApiKeyInputToJSON,
} from '../models/index';

export interface ProjectControllerSetCohereAPIKeyRequest {
    setCohereApiKeyInput: SetCohereApiKeyInput;
}

export interface ProjectControllerSetOpenAIAPIKeyRequest {
    setOpenaiApiKeyInput: SetOpenaiApiKeyInput;
}

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

    /**
     */
    async projectControllerDeleteProjectRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<DeleteSuccessDto>> {
        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}`;
            }
        }
        const response = await this.request({
            path: `/project`,
            method: 'DELETE',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     */
    async projectControllerDeleteProject(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<DeleteSuccessDto> {
        const response = await this.projectControllerDeleteProjectRaw(initOverrides);
        return await response.value();
    }

    /**
     */
    async projectControllerGetAllProjectsRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Array<FullProjectDto>>> {
        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}`;
            }
        }
        const response = await this.request({
            path: `/project/all`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

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

    /**
     */
    async projectControllerGetProjectRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<FullProjectDto>> {
        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}`;
            }
        }
        const response = await this.request({
            path: `/project`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     */
    async projectControllerGetProject(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<FullProjectDto> {
        const response = await this.projectControllerGetProjectRaw(initOverrides);
        return await response.value();
    }

    /**
     */
    async projectControllerSetCohereAPIKeyRaw(requestParameters: ProjectControllerSetCohereAPIKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ProjectDto>> {
        if (requestParameters.setCohereApiKeyInput === null || requestParameters.setCohereApiKeyInput === undefined) {
            throw new runtime.RequiredError('setCohereApiKeyInput','Required parameter requestParameters.setCohereApiKeyInput was null or undefined when calling projectControllerSetCohereAPIKey.');
        }

        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}`;
            }
        }
        const response = await this.request({
            path: `/project/cohere-api-key`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: SetCohereApiKeyInputToJSON(requestParameters.setCohereApiKeyInput),
        }, initOverrides);

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

    /**
     */
    async projectControllerSetCohereAPIKey(requestParameters: ProjectControllerSetCohereAPIKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ProjectDto> {
        const response = await this.projectControllerSetCohereAPIKeyRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     */
    async projectControllerSetOpenAIAPIKeyRaw(requestParameters: ProjectControllerSetOpenAIAPIKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<ProjectDto>> {
        if (requestParameters.setOpenaiApiKeyInput === null || requestParameters.setOpenaiApiKeyInput === undefined) {
            throw new runtime.RequiredError('setOpenaiApiKeyInput','Required parameter requestParameters.setOpenaiApiKeyInput was null or undefined when calling projectControllerSetOpenAIAPIKey.');
        }

        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}`;
            }
        }
        const response = await this.request({
            path: `/project/openai-api-key`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: SetOpenaiApiKeyInputToJSON(requestParameters.setOpenaiApiKeyInput),
        }, initOverrides);

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

    /**
     */
    async projectControllerSetOpenAIAPIKey(requestParameters: ProjectControllerSetOpenAIAPIKeyRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<ProjectDto> {
        const response = await this.projectControllerSetOpenAIAPIKeyRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
