src/Client.ts
Rama main · réplica de lectura del repositorio original.
// This file was auto-generated by Fern from our API Definition.
import { AccountsClient } from "./api/resources/accounts/client/Client.js";
import { AgentClient } from "./api/resources/agent/client/Client.js";
import { ApiKeysClient } from "./api/resources/apiKeys/client/Client.js";
import { AppsClient } from "./api/resources/apps/client/Client.js";
import { AuthClient } from "./api/resources/auth/client/Client.js";
import { DomainsClient } from "./api/resources/domains/client/Client.js";
import { DraftsClient } from "./api/resources/drafts/client/Client.js";
import { ForwardingClient } from "./api/resources/forwarding/client/Client.js";
import { InboxesClient } from "./api/resources/inboxes/client/Client.js";
import { ListsClient } from "./api/resources/lists/client/Client.js";
import { MetricsClient } from "./api/resources/metrics/client/Client.js";
import { OrganizationsClient } from "./api/resources/organizations/client/Client.js";
import { PodsClient } from "./api/resources/pods/client/Client.js";
import { ThreadsClient } from "./api/resources/threads/client/Client.js";
import { WebhooksClient } from "./api/resources/webhooks/client/Client.js";
import { WebsocketsClient } from "./api/resources/websockets/client/Client.js";
import type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
import { type NormalizedClientOptionsWithAuth, normalizeClientOptionsWithAuth } from "./BaseClient.js";
import * as core from "./core/index.js";
import * as environments from "./environments.js";
export declare namespace AgentMailClient {
export type Options = BaseClientOptions;
export interface RequestOptions extends BaseRequestOptions {}
}
export class AgentMailClient {
protected readonly _options: NormalizedClientOptionsWithAuth<AgentMailClient.Options>;
protected _inboxes: InboxesClient | undefined;
protected _pods: PodsClient | undefined;
protected _webhooks: WebhooksClient | undefined;
protected _accounts: AccountsClient | undefined;
protected _agent: AgentClient | undefined;
protected _apiKeys: ApiKeysClient | undefined;
protected _apps: AppsClient | undefined;
protected _auth: AuthClient | undefined;
protected _domains: DomainsClient | undefined;
protected _drafts: DraftsClient | undefined;
protected _forwarding: ForwardingClient | undefined;
protected _lists: ListsClient | undefined;
protected _metrics: MetricsClient | undefined;
protected _organizations: OrganizationsClient | undefined;
protected _threads: ThreadsClient | undefined;
protected _websockets: WebsocketsClient | undefined;
constructor(options: AgentMailClient.Options = {}) {
this._options = normalizeClientOptionsWithAuth(options);
}
public get inboxes(): InboxesClient {
return (this._inboxes ??= new InboxesClient(this._options));
}
public get pods(): PodsClient {
return (this._pods ??= new PodsClient(this._options));
}
public get webhooks(): WebhooksClient {
return (this._webhooks ??= new WebhooksClient(this._options));
}
public get accounts(): AccountsClient {
return (this._accounts ??= new AccountsClient(this._options));
}
public get agent(): AgentClient {
return (this._agent ??= new AgentClient(this._options));
}
public get apiKeys(): ApiKeysClient {
return (this._apiKeys ??= new ApiKeysClient(this._options));
}
public get apps(): AppsClient {
return (this._apps ??= new AppsClient(this._options));
}
public get auth(): AuthClient {
return (this._auth ??= new AuthClient(this._options));
}
public get domains(): DomainsClient {
return (this._domains ??= new DomainsClient(this._options));
}
public get drafts(): DraftsClient {
return (this._drafts ??= new DraftsClient(this._options));
}
public get forwarding(): ForwardingClient {
return (this._forwarding ??= new ForwardingClient(this._options));
}
public get lists(): ListsClient {
return (this._lists ??= new ListsClient(this._options));
}
public get metrics(): MetricsClient {
return (this._metrics ??= new MetricsClient(this._options));
}
public get organizations(): OrganizationsClient {
return (this._organizations ??= new OrganizationsClient(this._options));
}
public get threads(): ThreadsClient {
return (this._threads ??= new ThreadsClient(this._options));
}
public get websockets(): WebsocketsClient {
return (this._websockets ??= new WebsocketsClient(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 ??
(async () => {
const env = await core.Supplier.get(this._options.environment);
return typeof env === "string"
? env
: ((env as Record<string, string>)?.http ?? environments.AgentMailEnvironment.Prod.http);
}),
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,
);
}
}