/* tslint:disable */
/* eslint-disable */
/**
 * starchart
 * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
 *
 * The version of the OpenAPI document: 0.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 {
  DiscoveryLog,
  Star,
} from '../models';
import {
    DiscoveryLogFromJSON,
    DiscoveryLogToJSON,
    StarFromJSON,
    StarToJSON,
} from '../models';

export interface DiscoverRequest {
    discoveryLog: DiscoveryLog;
}

export interface VisitRequest {
    planetId: any;
}

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

    /**
     * the whole chart
     */
    async chartRaw(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<any>> {
        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        const response = await this.request({
            path: `/api/v1/stars/chart`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

        if (this.isJsonMime(response.headers.get('content-type'))) {
            return new runtime.JSONApiResponse<any>(response);
        } else {
            return new runtime.TextApiResponse(response) as any;
        }
    }

    /**
     * the whole chart
     */
    async chart(initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<any> {
        const response = await this.chartRaw(initOverrides);
        return await response.value();
    }

    /**
     * add a new planet
     */
    async discoverRaw(requestParameters: DiscoverRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Star>> {
        if (requestParameters.discoveryLog === null || requestParameters.discoveryLog === undefined) {
            throw new runtime.RequiredError('discoveryLog','Required parameter requestParameters.discoveryLog was null or undefined when calling discover.');
        }

        const queryParameters: any = {};

        const headerParameters: runtime.HTTPHeaders = {};

        headerParameters['Content-Type'] = 'application/json';

        const response = await this.request({
            path: `/api/v1/stars/discover`,
            method: 'POST',
            headers: headerParameters,
            query: queryParameters,
            body: DiscoveryLogToJSON(requestParameters.discoveryLog),
        }, initOverrides);

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

    /**
     * add a new planet
     */
    async discover(requestParameters: DiscoverRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Star> {
        const response = await this.discoverRaw(requestParameters, initOverrides);
        return await response.value();
    }

    /**
     * visit a single planet
     */
    async visitRaw(requestParameters: VisitRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<runtime.ApiResponse<Star>> {
        if (requestParameters.planetId === null || requestParameters.planetId === undefined) {
            throw new runtime.RequiredError('planetId','Required parameter requestParameters.planetId was null or undefined when calling visit.');
        }

        const queryParameters: any = {};

        if (requestParameters.planetId !== undefined) {
            queryParameters['planet_id'] = requestParameters.planetId;
        }

        const headerParameters: runtime.HTTPHeaders = {};

        const response = await this.request({
            path: `/api/v1/stars/visit/`,
            method: 'GET',
            headers: headerParameters,
            query: queryParameters,
        }, initOverrides);

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

    /**
     * visit a single planet
     */
    async visit(requestParameters: VisitRequest, initOverrides?: RequestInit | runtime.InitOverrideFunction): Promise<Star> {
        const response = await this.visitRaw(requestParameters, initOverrides);
        return await response.value();
    }

}
