UNPKG

@trycourier/courier-js

Version:

A browser-safe API wrapper

55 lines (54 loc) 2.24 kB
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'; 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/reference/auth/issue-token */ jwt?: string; /** Public API key for testing (use JWTs in prod) */ publicApiKey?: string; /** Inbox Websocket connection ID */ connectionId?: 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; } export interface CourierClientOptions { /** JWT token for authentication: More info at https://www.courier.com/docs/reference/auth/issue-token */ 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; } export declare class CourierClient extends Client { readonly tokens: TokenClient; readonly brands: BrandClient; readonly preferences: PreferenceClient; readonly inbox: InboxClient; readonly lists: ListClient; readonly tracking: TrackingClient; constructor(props: CourierProps); }