UNPKG

autumn-js

Version:

Autumn JS Library

79 lines (74 loc) 3.45 kB
import { CreateReferralCodeParams, RedeemReferralCodeParams } from './client/types/clientReferralTypes.js'; import { CreateEntityParams, GetEntityParams } from './client/types/clientEntTypes.js'; import { AttachParams, CancelParams, CheckParams, TrackParams, OpenBillingPortalParams } from './client/types/clientGenTypes.js'; import { R as Result, A as AutumnPromise, a as AttachResult, C as CancelResult, b as CheckResult, T as TrackResult } from './response-B1KyqUB9.js'; import { A as AutumnError } from './error-CG2LXoa7.js'; import { C as CustomerData, a as CreateCustomerParams, b as Customer, B as BillingPortalResponse } from './cusTypes-Cf-s9PYP.js'; import { E as Entity, D as DeleteEntityResult } from './entTypes-BbIk0Toa.js'; interface PricingTableProduct { id: string; name: string; buttonText: string; price: { primaryText: string; secondaryText?: string; }; items: { primaryText: string; secondaryText?: string; }[]; } interface CreateReferralCodeResult { code: string; customer_id: string; created_at: number; } interface RedeemReferralCodeResult { id: string; customer_id: string; reward_id: string; applied: boolean; } interface ErrorResponse { message: string; code: string; } type OmitCustomerType = "id" | "name" | "email" | "fingerprint" | "customer_id"; declare class AutumnClient { private readonly backendUrl; private readonly getBearerToken?; private readonly customerData?; private readonly includeCredentials?; constructor({ backendUrl, getBearerToken, customerData, includeCredentials, }: { backendUrl: string; getBearerToken?: () => Promise<string | null | undefined>; customerData?: CustomerData; includeCredentials?: boolean; }); getHeaders(): Promise<any>; handleFetchResult(result: Response): Promise<Result<any, AutumnError>>; post(path: string, body: any): Promise<Result<any, AutumnError>>; get(path: string): Promise<Result<any, AutumnError>>; delete(path: string): Promise<Result<any, AutumnError>>; createCustomer(params: Omit<CreateCustomerParams, "id" | "data"> & { errorOnNotFound?: boolean; }): Promise<Result<Customer, AutumnError>>; getPricingTable(): Promise<Result<{ list: PricingTableProduct[]; }, AutumnError>>; attach: (params: AttachParams) => AutumnPromise<AttachResult>; cancel: (params: CancelParams) => AutumnPromise<CancelResult>; check: (params: CheckParams) => AutumnPromise<CheckResult>; track: (params: TrackParams) => AutumnPromise<TrackResult>; openBillingPortal: (params?: OpenBillingPortalParams | undefined) => AutumnPromise<BillingPortalResponse>; entities: { create: (params: CreateEntityParams | CreateEntityParams[]) => AutumnPromise<Entity | Entity[]>; get: (entityId: string, params?: GetEntityParams | undefined) => AutumnPromise<Entity>; delete: (entityId: string) => AutumnPromise<DeleteEntityResult>; }; referrals: { createCode: (params: CreateReferralCodeParams) => AutumnPromise<CreateReferralCodeResult>; redeemCode: (params: RedeemReferralCodeParams) => AutumnPromise<RedeemReferralCodeResult>; }; } export { AutumnClient as A, type CreateReferralCodeResult as C, type ErrorResponse as E, type OmitCustomerType as O, type PricingTableProduct as P, type RedeemReferralCodeResult as R };