import type { ProductListItem, Product, ShopCategory, ShopBrand, ShopCollection, ShippingMethod, PaymentMethodOption, CreateOrderRequest, ShopOrder, ShopOrderPaymentStatus, ShopOffer, ShopOfferListParams } from "./types/shop.js"; import type { ApiEvent, EventRegistrationSubmission, EventRegistrationResult, EventRegistration, EventRegistrationAccess, EventPaymentMethod, EventPaymentSessionRequest, EventPaymentSession, EventCommandOptions, EventPaymentStatus } from "./types/event.js"; import type { BookingService, TimeSlot, Booking, BookingDetail, BookingConfig, ResourceItem, CreateBookingRequest, BookingListParams, UpdateBookingInput } from "./types/booking.js"; import type { Member, CardSettings, PaymentMethod, PublicMembershipTier } from "./types/member.js"; import type { PromotionValidationRequest, PromotionValidationResponse } from "./types/promotion.js"; import type { Invoice, InvoiceDetail } from "./types/invoice.js"; import type { DocumentSigningData, DocumentSignaturePayload, DocumentSignatureResult } from "./types/document.js"; import type { SurveyPublicView, SurveyResponseResult, SurveyResponseSubmission } from "./types/survey.js"; import type { CmsPage, CmsPageSummary } from "./types/cms.js"; import type { BlogPost, BlogPostListItem } from "./types/blog.js"; import type { ProductReview, ReviewSummary, CreateReviewRequest, ReviewContext } from "./types/review.js"; import type { ServicePackageOrder } from "./types/service-package.js"; import type { ContactEnquirySubmission, ContactEnquiryResult } from "./types/contact.js"; import type { TutorCourseSummary, TutorCourseDetail, TutorCourseEnrollmentResult, TutorCourseMyEnrollment, TutorCoursePaymentInput, TutorCoursePaymentSession, TutorCoursePaymentStatusResult, TutorCourseLeaveRequest, TutorCourseLeaveRequestInput, TutorCourseTransferRequest, TutorCourseTransferRequestInput } from "./types/tutor-course.js"; import type { ApiGiftOffer, ApiGiftOfferList, ApiRewardRedemption, ApiRewardRedemptionList, RedemptionStatus } from "./types/gift.js"; import { AuthClient } from "./auth.js"; import { SupportClient } from "./support.js"; export interface FavCRMConfig { baseUrl: string; companyId: string; onUnauthorized?: () => void; fetch?: typeof globalThis.fetch; /** * Per-request timeout in milliseconds. Defaults to 30 000 ms. * Set to 0 to disable. Applied to every `request()`, `requestRaw()`, * and `fetchRaw()` call via an internally-managed AbortController that * is merged with any caller-supplied signal. */ timeoutMs?: number; } export interface CustomerAiChatInput { message: string; conversationId?: string; } export interface CustomerAiToolCallStatus { id: string; name: string; status: "running" | "completed" | "failed"; summary?: string; } export interface CustomerAiUsage { promptTokens?: number; completionTokens?: number; } export interface CustomerAiStreamHandlers { onMessageStart?: (event: { conversationId: string; }) => void; onContentDelta?: (event: { content: string; }) => void; onToolCallStart?: (event: { toolCall: CustomerAiToolCallStatus; }) => void; onToolCallResult?: (event: { toolCall: CustomerAiToolCallStatus; }) => void; onMessageEnd?: (event: { conversationId: string; usage?: CustomerAiUsage; }) => void; onError?: (event: { message: string; }) => void; } export interface CustomerAiConversation { id: string; title?: string | null; type?: string | null; createdAt?: string; updatedAt?: string; messages?: Array<{ id?: string; role: string; content: string | null; toolCalls?: unknown; createdAt?: string; }>; } export declare class FavCRMError extends Error { status: number; code?: string; constructor(status: number, message: string, code?: string); } type HttpMethod = "GET" | "POST" | "PATCH" | "DELETE"; interface RequestOptions { body?: unknown; params?: Record; idempotencyKey?: string; } export declare class FavCRM { private config; private jwt; private readonly base; readonly shop: ShopClient; readonly bookings: BookingsClient; readonly events: EventsClient; readonly tutorCourses: TutorCoursesClient; readonly members: MembersClient; readonly payments: PaymentsClient; readonly promotions: PromotionsClient; readonly invoices: InvoicesClient; readonly documents: DocumentsClient; readonly cms: CmsClient; readonly blog: BlogClient; readonly packages: PackagesClient; readonly tiers: TiersClient; readonly contact: ContactClient; readonly auth: AuthClient; readonly walletPasses: WalletPassesClient; readonly gifts: GiftsClient; readonly surveys: SurveysClient; readonly ai: CustomerAiClient; readonly support: SupportClient; constructor(config: FavCRMConfig); get companyId(): string; setToken(jwt: string): void; clearToken(): void; /** @internal — used by WalletPassesClient for binary downloads */ fetchRaw(path: string, opts?: { params?: Record; }): Promise; /** @internal — used by sub-clients */ request(method: HttpMethod, path: string, opts?: RequestOptions): Promise; private _requestOnce; /** @internal — used by CustomerAiClient for SSE streams */ requestRaw(method: HttpMethod, path: string, opts?: RequestOptions): Promise; } declare class CustomerAiClient { private sdk; constructor(sdk: FavCRM); chat(input: CustomerAiChatInput): Promise; streamChat(input: CustomerAiChatInput, handlers: CustomerAiStreamHandlers): Promise; listConversations(): Promise; getConversation(id: string): Promise; deleteConversation(id: string): Promise<{ deleted: boolean; }>; } export interface ProductListParams { category_slug?: string; category_id?: number; brand_slug?: string; collection_slug?: string; search?: string; sort?: 'name' | 'price_asc' | 'price_desc' | 'newest'; featured?: boolean; page?: number; limit?: number; } export interface CategoryListParams { featured?: boolean; } declare class ShopClient { private sdk; constructor(sdk: FavCRM); listProducts(params?: ProductListParams): Promise; getProduct(slug: string): Promise; getRelatedProducts(slug: string, limit?: number): Promise; listCategories(params?: CategoryListParams): Promise; listBrands(): Promise; getBrand(slug: string): Promise; listCollections(): Promise; getCollection(slug: string): Promise; listShippingMethods(orderAmount?: number): Promise; listPaymentMethods(): Promise; listOffers(params?: ShopOfferListParams): Promise; createOrder(data: CreateOrderRequest): Promise; listOrders(): Promise; getOrder(orderUuid: string): Promise; getOrderPaymentStatus(orderUuid: string): Promise; listProductReviews(slug: string): Promise<{ reviews: ProductReview[]; summary: ReviewSummary; }>; getReviewContext(token: string): Promise; submitProductReview(data: CreateReviewRequest): Promise; } export interface TimeSlotsParams { date: string; createQuotes?: boolean; accountId?: string; staffId?: string; resourceId?: string; } export interface TimeSlotsResponse { slots: TimeSlot[]; bookingConfig?: BookingConfig; } export interface StaffMember { memberId: string; memberName: string; } declare class BookingsClient { private sdk; constructor(sdk: FavCRM); listServices(): Promise; getService(serviceId: string): Promise; getStaff(serviceId: string): Promise; getResources(serviceId: string): Promise; getTimeSlots(serviceId: string, params: TimeSlotsParams): Promise; create(data: CreateBookingRequest): Promise; createGuest(data: CreateBookingRequest): Promise; list(params?: BookingListParams): Promise; get(bookingId: string): Promise; getAccessQr(bookingId: string): Promise<{ qrContent: string; expiresAt: string; bookingId: string; }>; cancel(bookingId: string, reason?: string): Promise; reschedule(bookingId: string, data: UpdateBookingInput): Promise; } declare class EventsClient { private sdk; constructor(sdk: FavCRM); list(): Promise; get(slug: string): Promise; register(data: EventRegistrationSubmission, options?: EventCommandOptions): Promise; listRegistrations(): Promise; createPaymentIntent(registrationId: string): Promise; listPaymentMethods(): Promise; createPaymentSession(registrationId: string, data: EventPaymentSessionRequest, options?: EventCommandOptions): Promise; getPaymentStatus(registrationId: string, transactionId?: string): Promise; /** * Create a payment intent and guarantee a Stripe `publishableKey`. * * `createPaymentIntent` may omit `publishableKey` depending on the * merchant's gateway configuration. This helper falls back to * `payments.getGateway()` so the caller always has the key needed to * mount Stripe Elements client-side. */ startPayment(registrationId: string): Promise; getAccess(registrationId: string): Promise; cancelRegistration(eventId: string, registrationId: string): Promise<{ cancelled: boolean; }>; } declare class TutorCoursesClient { private sdk; constructor(sdk: FavCRM); list(): Promise; get(courseId: string): Promise; enroll(courseId: string, data: { sectionId: string; }): Promise; listMyEnrollments(): Promise; createPayment(enrollmentId: string, data: TutorCoursePaymentInput): Promise; getPaymentStatus(enrollmentId: string, transactionId?: string): Promise; listLeaveRequests(enrollmentId: string): Promise; requestLeave(enrollmentId: string, data: TutorCourseLeaveRequestInput): Promise; cancelLeave(enrollmentId: string, requestId: string): Promise; listTransferRequests(enrollmentId: string): Promise; requestTransfer(enrollmentId: string, data: TutorCourseTransferRequestInput): Promise; cancelTransfer(enrollmentId: string, requestId: string): Promise; } declare class MembersClient { private sdk; constructor(sdk: FavCRM); getProfile(): Promise; updateProfile(data: Partial): Promise; getCardSettings(): Promise; listPaymentMethods(): Promise; addPaymentMethod(token: string): Promise; deletePaymentMethod(methodId: string): Promise; setDefaultPaymentMethod(methodId: string): Promise; enroll(tierId: string): Promise<{ membershipId: string; }>; enrollPaid(tierId: string, paymentIntentId: string): Promise<{ membershipId: string; }>; } declare class TiersClient { private sdk; constructor(sdk: FavCRM); list(): Promise; } export interface PaymentGateway { publishableKey: string; gateway: string; } export interface PaymentIntentRequest { amount: number; currency: string; bookingId?: string; tierId?: string; } export interface PaymentIntentResponse { clientSecret: string; paymentIntentId: string; publishableKey?: string; stripeAccount?: string; } declare class PaymentsClient { private sdk; constructor(sdk: FavCRM); getGateway(): Promise; createIntent(data: PaymentIntentRequest): Promise; getCreditBalance(): Promise<{ credits: string; currency: string; }>; } declare class PromotionsClient { private sdk; constructor(sdk: FavCRM); validate(data: PromotionValidationRequest): Promise; } declare class InvoicesClient { private sdk; constructor(sdk: FavCRM); list(): Promise; get(id: string): Promise; } declare class DocumentsClient { private sdk; constructor(sdk: FavCRM); getSigningToken(token: string): Promise; sign(token: string, data: DocumentSignaturePayload): Promise; } declare class SurveysClient { private sdk; constructor(sdk: FavCRM); get(slug: string): Promise; getByToken(token: string): Promise; submit(surveyId: string, data: SurveyResponseSubmission): Promise; submitByToken(token: string, data: SurveyResponseSubmission): Promise; } declare class CmsClient { private sdk; constructor(sdk: FavCRM); listPages(): Promise; getPage(slug: string): Promise; } export interface BlogListParams { type?: string; category?: string; categoryId?: string; search?: string; sort?: "createdAt" | "updatedAt" | "publishedAt" | "title" | "sortOrder"; order?: "asc" | "desc"; page?: number; limit?: number; } export interface PaginatedResult { items: T[]; pagination: { page: number; limit: number; total: number; totalPages: number; hasNext: boolean; hasPrev: boolean; }; } declare class PackagesClient { private sdk; constructor(sdk: FavCRM); listMyOrders(): Promise; getApplicable(serviceId: string): Promise; } declare class BlogClient { private sdk; constructor(sdk: FavCRM); list(params?: BlogListParams): Promise>; getBySlug(slug: string): Promise; } declare class ContactClient { private sdk; constructor(sdk: FavCRM); submit(data: ContactEnquirySubmission): Promise; } export interface WalletPassStatus { apple: { serialNumber: string; version: number; r2Key: string | null; createdAt: string; updatedAt: string; } | null; google: { objectId: string | null; saveUrl: string | null; createdAt: string; updatedAt: string; } | null; } declare class WalletPassesClient { private sdk; constructor(sdk: FavCRM); getStatus(): Promise; generate(type: "apple" | "google"): Promise<{ queued: boolean; }>; downloadAppleBlob(): Promise; getGoogleSaveUrl(): Promise<{ saveUrl: string | null; }>; } declare class GiftsClient { private sdk; constructor(sdk: FavCRM); listMyRedemptions(opts?: { status?: RedemptionStatus | Lowercase; limit?: number; offset?: number; }): Promise; getRedemption(id: string): Promise; fulfill(id: string): Promise; listOffers(opts?: { limit?: number; offset?: number; }): Promise; getOffer(id: string): Promise; redeemOffer(id: string): Promise; claimByCode(code: string): Promise; } export {}; //# sourceMappingURL=client.d.ts.map