UNPKG

@microsoft/teams.graph

Version:

<p> <a href="https://www.npmjs.com/package/@microsoft/teams.graph" target="_blank"> <img src="https://img.shields.io/npm/v/@microsoft/teams.graph/latest" /> </a> <a href="https://www.npmjs.com/package/@microsoft/teams.graph?activeTab=c

64 lines (60 loc) 2.13 kB
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; }; 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; }; /** * / * Provides an entry point for invoking Microsoft Graph APIs. */ declare class Client { protected baseUrlRoot: string; protected http: http.Client; protected betaHttp?: http.Client; constructor(options?: Options); /** * 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, type SchemaVersion };