import { EnvironmentConfig, SessionRole } from '../types'; export interface ApiServiceOptions { environmentConfig: EnvironmentConfig; token?: string | null; onTokenUpdate?: (token: string) => void; onTokenClear?: () => void; } export interface FetchOptions { method?: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH'; body?: any; headers?: Record; params?: Record; skipAuth?: boolean; captureErrors?: boolean; } export interface AnonymousTokenResponse { token: string; sessionId: string; storeId: string; accountId: string; customerId: string; role: 'anonymous'; } export interface SessionInitResponse { locale: string; messages: Record; store: { id: string; name: string; domain: string; currency: string; locale: string; integrations?: any[]; }; customer?: { id: string; email?: string; firstName?: string; lastName?: string; phone?: string; isAuthenticated: boolean; role: SessionRole; }; } export declare class ApiService { private config; private token; private onTokenUpdate?; private onTokenClear?; constructor(options: ApiServiceOptions); updateToken(token: string | null): void; getCurrentToken(): string | null; updateConfig(config: EnvironmentConfig): void; /** * Store the store ID in localStorage (deprecated - use usePluginConfig instead) * @deprecated Use usePluginConfig hook to get storeId */ storeStoreId(storeId: string): void; /** * Get the store ID from localStorage (deprecated - use usePluginConfig instead) * @deprecated Use usePluginConfig hook to get storeId */ getStoredStoreId(): string | null; /** * Make an authenticated request to the API */ fetch(endpoint: string, options?: FetchOptions): Promise; /** * Create an anonymous token for the given store */ createAnonymousToken(storeId: string): Promise; /** * Initialize a CMS session with device info and user data */ initializeSession(sessionData: { storeId: string; accountId: string; customerId: string; role: SessionRole; browserLocale?: string; queryLocale?: string; queryCurrency?: string; utmSource?: string; utmMedium?: string; utmCampaign?: string; browser?: string; browserVersion?: string; os?: string; osVersion?: string; deviceType?: string; deviceModel?: string; screenWidth?: number; screenHeight?: number; timeZone?: string; }): Promise; /** * Get customer profile */ getCustomerProfile(customerId: string): Promise; /** * Get session status */ getSessionStatus(sessionId: string): Promise; /** * Update customer information (email, marketing preferences) */ updateCustomer(customerId: string, data: { email: string; acceptsMarketing?: boolean; }): Promise; /** * Update customer and checkout session information in one request */ updateCustomerAndSessionInfo(checkoutSessionId: string, data: { customerData: { email: string; acceptsMarketing?: boolean; }; shippingAddress: { firstName: string; lastName: string; address1: string; city: string; country: string; state: string; postal: string; phone: string; }; billingAddress: { firstName: string; lastName: string; address1: string; city: string; country: string; state: string; postal: string; phone: string; }; differentBillingAddress: boolean; }): Promise<{ success: boolean; errors?: Record; shippingCountryChanged: boolean; billingCountryChanged: boolean; }>; /** * Update shipping address only (no email required) * Useful for fetching shipping rates before email is entered */ updateShippingAddressOnly(checkoutSessionId: string, shippingAddress: { firstName?: string; lastName?: string; address1?: string; city?: string; country: string; state?: string; postal?: string; phone?: string; }): Promise<{ success: boolean; countryChanged: boolean; errors?: Record; }>; /** * Clear the authentication token */ clearToken(): void; }