import { IANATimezone, VenueId } from '@getmicdrop/svelte-components'; import { ApiRequestOptions } from './client.js'; import { Result } from './result.js'; /** * Request payload for creating a gift card purchase */ export interface GiftCardPurchaseRequest { venueId: number | VenueId; amount: number; recipientEmail: string; recipientName: string; personalMessage?: string; purchaserEmail: string; purchaserName: string; scheduledDeliveryAt?: string | null; } /** * Response from gift card purchase creation */ export interface GiftCardPurchaseResponse { giftCardUUID: string; clientSecret: string; amount: number; stripePublishableKey: string; } /** * Venue information needed for gift card purchase */ export interface VenueInfo { id: VenueId; name: string; slug: string; stripePublishableKey?: string; /** * The venue's IANA timezone. REQUIRED, and never empty — see the mapping in * getVenueBySlugResult. * * This is the zone a scheduled gift-card delivery is meant in (MIC-4033). It * is not optional because the one thing a consumer must never do is fall back * to the buyer's browser zone, and an optional field invites exactly that. * * BRANDED, not `string`, because the mapping below already produces the brand: * `venueTimeZone()` returns an `IANATimezone`, and declaring the field as a * bare `string` threw that away one line later — which is how the route page * that hands this to DeliveryScheduler (whose `timeZone` prop IS an * `IANATimezone`) came out red while the value it passes was correct all * along. Keeping the brand here is what carries "this has been normalised and * is never empty" from the projection to every consumer, instead of asking * each of them to re-assert it. */ timeZone: IANATimezone; } /** * Create a gift card purchase and get Stripe client secret * @param req - Gift card purchase request details * @returns Gift card UUID and Stripe client secret, or null on failure */ export declare function createGiftCardPurchase(req: GiftCardPurchaseRequest, options?: Pick): Promise; /** * Result shape consumed by the Checkout component / GiftCardInput. * Monetary fields here are in DOLLARS (formatCurrency-ready). */ export interface ApplyGiftCardResult { valid: boolean; giftCardCode?: string; giftCardAmount?: number; giftCardBalance?: number; paymentType?: string; stripeAmount?: number; orderTotal?: number; requiresStripe?: boolean; error?: string; } /** * Apply a gift card to a cart. */ export declare function applyGiftCard(cartId: string, code: string, req?: Pick): Promise; export interface RemoveGiftCardResult { success: boolean; error?: string; /** * Amount still owed after the removal, in DOLLARS, as the server computed it. * `undefined` when the cart is not yet priced (the server sends null) — the * caller must then leave its own total alone rather than infer a zero. */ remainingTotal?: number; } /** * Remove a gift card from a cart. Identify a single stacked card by `giftCardId` * (what the cart response gives — codes come back masked) or by `code` for one * applied in this same session. Pass neither to remove ALL applied cards. */ export declare function removeGiftCard(cartId: string, target?: { giftCardId?: number; code?: string; }, req?: Pick): Promise; export interface CompleteGiftCardPaymentInput { firstName: string; lastName: string; email: string; phoneNumber?: string | null; questionAnswer?: string; mailingList?: boolean; } export interface CompleteGiftCardPaymentResult { success: boolean; orderId?: string; confirmationNumber?: string; error?: string; } /** * Complete a gift-card-only payment (no Stripe required when balance >= total). */ export declare function completeGiftCardPayment(cartId: string, customerDetails: CompleteGiftCardPaymentInput, uiLocale?: string, req?: Pick): Promise; /** * Fetch venue information by slug, discriminating a real 404 from a transient * failure. * * The gift-card SSR loader (`v/[venueSlug]/gift-cards/purchase/+page.ts`) gates * its HTTP status on this: only an upstream 404 (`errNotFound`) becomes a page * 404. A 5xx, network error, or timeout is `err(...)` (transient) so the loader * answers 503/retry rather than a permanent-looking 404 on a backend blip. * * @param slug - Venue slug * @param customFetch - Optional custom fetch function (for SSR) * @returns `ok(venue)`, `errNotFound(...)` for a real 404, or `err(...)` transient */ export declare function getVenueBySlugResult(slug: string, customFetch?: typeof fetch, req?: Pick): Promise>; /** * Fetch venue information by slug * * Fail-open adapter over {@link getVenueBySlugResult}: returns `null` on any * failure. SSR loaders that need 404-vs-503 use the Result variant. * * @param slug - Venue slug * @returns Venue info or null on failure * @internal no shipped caller left; gift-cards.test.ts is what exercises it. */ export declare function getVenueBySlug(slug: string, customFetch?: typeof fetch, req?: Pick): Promise;