import { Config, ContactFormData, EmailSubscriptionOptions } from './types'; import { EventService } from './services/eventService'; import { ApiResponse, SendBulkMessagesPayload, PublishEventPayload, CreateCustomerRequest, ScheduleInfo, MessagesApi } from '@towncryerio/towncryer-js-api-client'; /** * Towncryer SDK contract implemented by {@link Towncryer}. Consumers who want * to substitute a fake/mock SDK in their own tests can depend on this * interface instead of the concrete class. */ export interface ITowncryer { createCustomer(customer: CreateCustomerRequest): Promise; publishEvent(event: PublishEventPayload): Promise; sendMessages(messages: SendBulkMessagesPayload): Promise; submitContactForm(formData: ContactFormData): Promise; subscribeToEmails(email: string, options?: EmailSubscriptionOptions): Promise; setAccessToken(token: string): void; setRefreshToken(token: string): void; setCustomerId(customerId: string): void; getEventService(): EventService; getMessagesApi(): MessagesApi; getCustomerId(): string; } /** * Towncryer SDK - Main class for interacting with the Towncryer API */ export declare class Towncryer implements ITowncryer { private apiService; private eventService; private customerService; private messageService; private utilityService; private customerId; private readyPromise; /** * Initialize the Towncryer SDK * @param config Configuration options */ constructor(config: Config); private initializeWithToken; private initializeWithApiKey; /** * Waits for any async setup started by the constructor (e.g. exchanging * an API key for an access token) to finish before a request goes out. * Every public request method awaits this internally, so callers never * need to think about it. */ private ensureReady; /** * Create a new customer * @param customer Customer data */ createCustomer(customer: CreateCustomerRequest): Promise; /** * Publish an event to Towncryer * @param event Event data */ publishEvent(event: PublishEventPayload): Promise; /** * Send bulk messages (emails, push notifications, SMS) * @param messages Message options */ sendMessages(messages: SendBulkMessagesPayload): Promise; /** * Submit contact form data * @param formData Contact form data including name, email, subject, and message */ submitContactForm(formData: ContactFormData): Promise; /** * Subscribe an email address to communications * @param email Email address to subscribe * @param options Additional subscription options like preferences and source */ subscribeToEmails(email: string, options?: EmailSubscriptionOptions): Promise; /** * Set or update the access token after initialization * @param token The access token to use for API requests */ setAccessToken(token: string): void; /** * Set or update the refresh token after initialization * @param token The refresh token to use for token refresh */ setRefreshToken(token: string): void; setCustomerId(customerId: string): void; /** * Get the event service, for building environment-specific extensions * (e.g. browser push notification support) on top of the core SDK. */ getEventService(): EventService; /** * Get the underlying messages API client, for building environment-specific * extensions (e.g. browser push notification support) on top of the core SDK. */ getMessagesApi(): MessagesApi; /** * Get the currently configured customer ID. */ getCustomerId(): string; }