// This file was auto-generated by Fern from our API Definition.

import { AnnotationsClient } from "./api/resources/annotations/client/Client.js";
import { ApiKeysClient } from "./api/resources/apiKeys/client/Client.js";
import { HealthClient } from "./api/resources/health/client/Client.js";
import { ProjectsClient } from "./api/resources/projects/client/Client.js";
import { ScoresClient } from "./api/resources/scores/client/Client.js";
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient.js";
import * as core from "./core/index.js";

export declare namespace LatitudeApiClient {
    export type Options = BaseClientOptions;

    export interface RequestOptions extends BaseRequestOptions {}
}

export class LatitudeApiClient {
    protected readonly _options: NormalizedClientOptionsWithAuth<LatitudeApiClient.Options>;
    protected _health: HealthClient | undefined;
    protected _projects: ProjectsClient | undefined;
    protected _scores: ScoresClient | undefined;
    protected _annotations: AnnotationsClient | undefined;
    protected _apiKeys: ApiKeysClient | undefined;

    constructor(options: LatitudeApiClient.Options = {}) {
        this._options = normalizeClientOptionsWithAuth(options);
    }

    public get health(): HealthClient {
        return (this._health ??= new HealthClient(this._options));
    }

    public get projects(): ProjectsClient {
        return (this._projects ??= new ProjectsClient(this._options));
    }

    public get scores(): ScoresClient {
        return (this._scores ??= new ScoresClient(this._options));
    }

    public get annotations(): AnnotationsClient {
        return (this._annotations ??= new AnnotationsClient(this._options));
    }

    public get apiKeys(): ApiKeysClient {
        return (this._apiKeys ??= new ApiKeysClient(this._options));
    }

    /**
     * Make a passthrough request using the SDK's configured auth, retry, logging, etc.
     * This is useful for making requests to endpoints not yet supported in the SDK.
     * The input can be a URL string, URL object, or Request object. Relative paths are resolved against the configured base URL.
     *
     * @param {Request | string | URL} input - The URL, path, or Request object.
     * @param {RequestInit} init - Standard fetch RequestInit options.
     * @param {core.PassthroughRequest.RequestOptions} requestOptions - Per-request overrides (timeout, retries, headers, abort signal).
     * @returns {Promise<Response>} A standard Response object.
     */
    public async fetch(
        input: Request | string | URL,
        init?: RequestInit,
        requestOptions?: core.PassthroughRequest.RequestOptions,
    ): Promise<Response> {
        return core.makePassthroughRequest(
            input,
            init,
            {
                baseUrl: this._options.baseUrl ?? this._options.environment,
                headers: this._options.headers,
                timeoutInSeconds: this._options.timeoutInSeconds,
                maxRetries: this._options.maxRetries,
                fetch: this._options.fetch,
                logging: this._options.logging,
                getAuthHeaders: async () => (await this._options.authProvider.getAuthRequest()).headers,
            },
            requestOptions,
        );
    }
}
