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

import { AnalyticsClient } from "./api/resources/analytics/client/Client.js";
import { AssistantsClient } from "./api/resources/assistants/client/Client.js";
import { CallsClient } from "./api/resources/calls/client/Client.js";
import { CampaignsClient } from "./api/resources/campaigns/client/Client.js";
import { ChatsClient } from "./api/resources/chats/client/Client.js";
import { EvalClient } from "./api/resources/eval/client/Client.js";
import { FilesClient } from "./api/resources/files/client/Client.js";
import { InsightClient } from "./api/resources/insight/client/Client.js";
import { ObservabilityScorecardClient } from "./api/resources/observabilityScorecard/client/Client.js";
import { PhoneNumbersClient } from "./api/resources/phoneNumbers/client/Client.js";
import { ProviderResourcesClient } from "./api/resources/providerResources/client/Client.js";
import { SessionsClient } from "./api/resources/sessions/client/Client.js";
import { SquadsClient } from "./api/resources/squads/client/Client.js";
import { StructuredOutputsClient } from "./api/resources/structuredOutputs/client/Client.js";
import { ToolsClient } from "./api/resources/tools/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 VapiClient {
    export type Options = BaseClientOptions;

    export interface RequestOptions extends BaseRequestOptions {}
}

export class VapiClient {
    protected readonly _options: NormalizedClientOptionsWithAuth<VapiClient.Options>;
    protected _assistants: AssistantsClient | undefined;
    protected _squads: SquadsClient | undefined;
    protected _calls: CallsClient | undefined;
    protected _chats: ChatsClient | undefined;
    protected _campaigns: CampaignsClient | undefined;
    protected _sessions: SessionsClient | undefined;
    protected _phoneNumbers: PhoneNumbersClient | undefined;
    protected _tools: ToolsClient | undefined;
    protected _files: FilesClient | undefined;
    protected _structuredOutputs: StructuredOutputsClient | undefined;
    protected _insight: InsightClient | undefined;
    protected _eval: EvalClient | undefined;
    protected _observabilityScorecard: ObservabilityScorecardClient | undefined;
    protected _providerResources: ProviderResourcesClient | undefined;
    protected _analytics: AnalyticsClient | undefined;

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

    public get assistants(): AssistantsClient {
        return (this._assistants ??= new AssistantsClient(this._options));
    }

    public get squads(): SquadsClient {
        return (this._squads ??= new SquadsClient(this._options));
    }

    public get calls(): CallsClient {
        return (this._calls ??= new CallsClient(this._options));
    }

    public get chats(): ChatsClient {
        return (this._chats ??= new ChatsClient(this._options));
    }

    public get campaigns(): CampaignsClient {
        return (this._campaigns ??= new CampaignsClient(this._options));
    }

    public get sessions(): SessionsClient {
        return (this._sessions ??= new SessionsClient(this._options));
    }

    public get phoneNumbers(): PhoneNumbersClient {
        return (this._phoneNumbers ??= new PhoneNumbersClient(this._options));
    }

    public get tools(): ToolsClient {
        return (this._tools ??= new ToolsClient(this._options));
    }

    public get files(): FilesClient {
        return (this._files ??= new FilesClient(this._options));
    }

    public get structuredOutputs(): StructuredOutputsClient {
        return (this._structuredOutputs ??= new StructuredOutputsClient(this._options));
    }

    public get insight(): InsightClient {
        return (this._insight ??= new InsightClient(this._options));
    }

    public get eval(): EvalClient {
        return (this._eval ??= new EvalClient(this._options));
    }

    public get observabilityScorecard(): ObservabilityScorecardClient {
        return (this._observabilityScorecard ??= new ObservabilityScorecardClient(this._options));
    }

    public get providerResources(): ProviderResourcesClient {
        return (this._providerResources ??= new ProviderResourcesClient(this._options));
    }

    public get analytics(): AnalyticsClient {
        return (this._analytics ??= new AnalyticsClient(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,
        );
    }
}
