import * as http from '@microsoft/teams.common/http';

type SchemaVersion = 'beta' | 'v1.0';
/**
 * Configuration options for the `call` method
 * @see {@link Client.call}
 */
type CallOptions = {
    /** HTTP request configuration */
    requestConfig?: http.RequestConfig;
};
type ParamDefs = Partial<Record<'query' | 'header' | 'path', string[]>>;
type EndpointRequest<TResponse> = {
    ver?: SchemaVersion;
    method: 'get' | 'post' | 'patch' | 'delete' | 'put';
    path: string;
    paramDefs?: ParamDefs;
    params?: Record<string, any>;
    body?: any;
    config?: http.RequestConfig;
    responseType?: TResponse;
};

/**
 * Error thrown when a Graph API request fails.
 * Surfaces the response body from the Graph API for easier debugging.
 */
declare class GraphError extends Error {
    /** HTTP status code */
    readonly statusCode: number;
    /** Graph API error code (e.g. "Authorization_RequestDenied") */
    readonly code?: string;
    /** The full response body from the Graph API */
    readonly body: unknown;
    /** The underlying error that caused this GraphError (e.g. the Axios error) */
    readonly source?: unknown;
    constructor(statusCode: number, body: unknown, method: string, url: string, source?: unknown);
}
type Options = (http.Client | http.ClientOptions) & {
    /** Graph service root. By default, the global commercial URL "https://graph.microsoft.com" is used,
     * but certain tenants may wish to override this to direct Graph API calls to a different cloud instance.
     */
    baseUrlRoot?: string;
};
/** Graph-specific client options. */
type GraphOptions = {
    /** Graph service root override for routing Graph calls to sovereign cloud. */
    baseUrlRoot?: string;
};
/**
 * /
 * Provides an entry point for invoking Microsoft Graph APIs.
 */
declare class Client {
    protected baseUrlRoot: string;
    protected _http: http.Client;
    protected betaHttp?: http.Client;
    /**
     * The underlying HTTP client, pre-configured with Graph base URL and headers.
     * Use for raw Graph API requests not covered by endpoint functions.
     */
    get http(): http.Client;
    /**
     * Creates a Graph client.
     *
     * @param options - The HTTP client to use; an existing {@link http.Client} will be cloned,
     * or an {@link http.ClientOptions} bag will be used to build a new one.
     * HTTP-level settings like headers, interceptors, and timeouts belong here.
     * @param graphOptions - Graph-specific options. Takes precedence over `options.baseUrlRoot`
     * when both are set.
     *
     * @example
     * // Public cloud (default)
     * new Client({ token });
     *
     * @example
     * // Sovereign cloud (GCCH)
     * new Client(httpClient, { baseUrlRoot: 'https://graph.microsoft.us' });
     */
    constructor(options?: Options, graphOptions?: GraphOptions);
    /**
     * Executes a Graph API endpoint function with optional HTTP configuration
     *
     * @param func - The endpoint function to execute
     * @param args - Arguments for the endpoint function, optionally followed by {@link CallConfig}
     * @returns Promise resolving to the endpoint's response data
     *
     * @example
     * ```typescript
     * // Simple call
     * const user = await client.call(endpoints.users.get, 'user-id');
     *
     * // With HTTP configuration
     * const user = await client.call(endpoints.users.get, 'user-id', {
     *   requestConfig: {
     *     timeout: 5000
     *   }
     * });
     * ```
     */
    call<F extends (...args: any[]) => EndpointRequest<any>, R = ReturnType<F> extends EndpointRequest<infer T> ? T : never>(func: F, ...args: [...Parameters<F>, CallOptions?]): Promise<R>;
    private getHttpClient;
}

export { type CallOptions, Client, type EndpointRequest, GraphError, type SchemaVersion };
