// Two credentials, one discriminated union
export type FlynetCredentials =
| { type: "oauth"; accessToken: string }
| { type: "apikey"; apiKey: string };
// One client factory
export function flynet(opts: FlynetClientOptions): {
request: <T>(path: string, init?: RequestInit) => Promise<T>;
// Discovery (API key only)
listRestaurants, getRestaurant, listRestaurantLocations,
listLocations, getLocationOpenHours,
// Member context (OAuth only): subject resolved from the token
getMe, getMyStatus, getMyWallets, getMyTags, getMyCheckIns,
listMemberships, listCheckIns,
// Payments (OAuth + merchant_id)
createPaymentIntent,
};
// One typed error class, with autocomplete on known codes
export class FlynetError extends Error {
readonly status: number;
readonly code?: FlynetErrorCode; // "MISSING_API_KEY" | "invalid_token" | "payment0030" | ...
readonly raw: unknown;
}
// Optional helper: decode the member UUID from the token (sub claim)
export function getAuthenticatedUserId(accessToken: string): string;