@trycourier/courier-js
Version:
A browser-safe API wrapper
79 lines (78 loc) • 3.2 kB
TypeScript
import { CourierApiUrls } from '../types/courier-api-urls';
import { Logger } from '../utils/logger';
import { BrandClient } from './brand-client';
import { InboxClient } from './inbox-client';
import { PreferenceClient } from './preference-client';
import { TokenClient } from './token-client';
import { Client } from './client';
import { ListClient } from './list-client';
import { TrackingClient } from './tracking-client';
import { CourierUserAgent } from '../utils/courier-user-agent';
export interface CourierProps {
/** User ID for the client. Normally matches the UID in your system */
userId: string;
/** JWT token for authentication: More info at https://www.courier.com/docs/api-reference/authentication/create-jwt */
jwt?: string;
/** Public API key for testing (use JWTs in prod) */
publicApiKey?: string;
/** Tenant ID. Used for multi-tenant apps */
tenantId?: string;
/** Flag to control logging. Logs are prefixed with [COURIER]. */
showLogs?: boolean;
/** Custom API URLs */
apiUrls?: CourierApiUrls;
/**
* Optional: The name of the SDK calling courier-js methods.
*
* This is an internal prop, intended to be set by other Courier SDKs.
* If undefined, this defaults to "courier-js".
* @internal
*/
courierUserAgentName?: string;
/**
* Optional: The version of the SDK calling courier-js methods.
*
* This is an internal prop, intended to be set by other Courier SDKs.
* If undefined, this defaults to this package's version.
* @internal
*/
courierUserAgentVersion?: string;
}
export interface CourierClientOptions {
/** JWT token for authentication: More info at https://www.courier.com/docs/api-reference/authentication/create-jwt */
readonly jwt?: string;
/** Public API key for testing (use JWTs in prod) */
readonly publicApiKey?: string;
/** User ID for the client. Normally matches the UID in your system */
readonly userId: string;
/** Inbox Websocket connection ID */
readonly connectionId: string;
/** Tenant ID. Used for multi-tenant apps */
readonly tenantId?: string;
/** Flag to control logging. Logs are prefixed with [COURIER]. */
readonly showLogs?: boolean;
/** Combined authentication token (jwt or publicApiKey) */
readonly accessToken?: string;
/** Logger instance */
readonly logger: Logger;
/** Final API URLs configuration */
readonly apiUrls: CourierApiUrls;
/** User agent describing Courier SDK and browser UA. */
readonly courierUserAgent: CourierUserAgent;
}
export declare class CourierClient extends Client {
/** User-agent reporting name of the courier-js package. */
private static readonly COURIER_JS_NAME;
/**
* User agent reporting version of the courier-js package.
* Inlined from package.json at build time.
*/
private static readonly COURIER_JS_VERSION;
readonly tokens: TokenClient;
readonly brands: BrandClient;
readonly preferences: PreferenceClient;
readonly inbox: InboxClient;
readonly lists: ListClient;
readonly tracking: TrackingClient;
constructor(props: CourierProps);
}