UNPKG

autumn-js

Version:

Autumn JS Library

140 lines (135 loc) 7.24 kB
import { P as Product, C as CreateProductParams, L as ListProductsParams, G as GetEntityParams, E as Entity, a as CreateEntityParams, b as CreateEntityResult, D as DeleteEntityResult, A as AttachParams, c as AttachResult, U as UsageParams, d as UsageResult, e as CancelParams, f as CancelResult, g as CheckParams, h as CheckResult, T as TrackParams, i as TrackResult, j as GetEntityParams$1 } from './clientEntTypes-BRUTcNUD.js'; import { R as Result, A as AutumnError } from './response-BCg7kiiN.js'; import { G as GetCustomerParams, a as Customer, b as CreateCustomerParams, U as UpdateCustomerParams, B as BillingPortalParams, c as BillingPortalResponse, C as CustomerData } from './cusTypes-BD42O-7Z.js'; declare class Autumn { private readonly secretKey; private readonly publishableKey; private level; private headers; private url; constructor(options?: { secretKey?: string; publishableKey?: string; url?: string; version?: string; headers?: Record<string, string>; }); getLevel(): "secret" | "publishable"; get(path: string): Promise<Result<any, AutumnError>>; post(path: string, body: any): Promise<Result<any, AutumnError>>; delete(path: string): Promise<Result<any, AutumnError>>; static customers: { get: (id: string, params?: GetCustomerParams) => Promise<Result<Customer, AutumnError>>; create: (params?: CreateCustomerParams) => Promise<Result<Customer, AutumnError>>; update: (id: string, params: UpdateCustomerParams) => Promise<Result<Customer, AutumnError>>; delete: (id: string) => Promise<Result<Customer, AutumnError>>; billingPortal: (id: string, params?: BillingPortalParams) => Promise<Result<BillingPortalResponse, AutumnError>>; }; static products: { get: (id: string) => Promise<Result<Product, AutumnError>>; create: (params?: CreateProductParams) => Promise<Result<Product, AutumnError>>; list: (params?: ListProductsParams) => Promise<Result<Product[], AutumnError>>; }; static entities: { get: (customer_id: string, entity_id: string, params?: GetEntityParams) => Promise<Result<Entity, AutumnError>>; create: (customer_id: string, params?: CreateEntityParams | CreateEntityParams[]) => Promise<Result<CreateEntityResult, AutumnError>>; delete: (customer_id: string, entity_id: string) => Promise<Result<DeleteEntityResult, AutumnError>>; }; static referrals: { createCode: (params: CreateReferralCodeParams) => Promise<Result<any, AutumnError>>; redeemCode: (params: RedeemReferralCodeParams) => Promise<Result<any, AutumnError>>; }; customers: { get: (id: string, params?: GetCustomerParams) => Promise<Result<Customer, AutumnError>>; create: (params?: CreateCustomerParams) => Promise<Result<Customer, AutumnError>>; update: (id: string, params: UpdateCustomerParams) => Promise<Result<Customer, AutumnError>>; delete: (id: string) => Promise<Result<Customer, AutumnError>>; billingPortal: (id: string, params?: BillingPortalParams) => Promise<Result<BillingPortalResponse, AutumnError>>; }; products: { get: (id: string) => Promise<Result<Product, AutumnError>>; create: (params?: CreateProductParams) => Promise<Result<Product, AutumnError>>; list: (params?: ListProductsParams) => Promise<Result<Product[], AutumnError>>; }; entities: { get: (customer_id: string, entity_id: string, params?: GetEntityParams) => Promise<Result<Entity, AutumnError>>; create: (customer_id: string, params?: CreateEntityParams | CreateEntityParams[]) => Promise<Result<CreateEntityResult, AutumnError>>; delete: (customer_id: string, entity_id: string) => Promise<Result<DeleteEntityResult, AutumnError>>; }; referrals: { createCode: (params: CreateReferralCodeParams) => Promise<Result<any, AutumnError>>; redeemCode: (params: RedeemReferralCodeParams) => Promise<Result<any, AutumnError>>; }; static attach: (params: AttachParams) => Promise<Result<AttachResult, AutumnError>>; static usage: (params: UsageParams) => Promise<Result<UsageResult, AutumnError>>; attach(params: AttachParams): Promise<Result<AttachResult, AutumnError>>; static cancel: (params: CancelParams) => Promise<Result<CancelResult, AutumnError>>; cancel(params: CancelParams): Promise<Result<CancelResult, AutumnError>>; /** * @deprecated This method is deprecated and will be removed in a future version. * Please use the new check() method instead. */ static entitled: (params: CheckParams) => Promise<Result<CheckResult, AutumnError>>; /** * @deprecated This method is deprecated and will be removed in a future version. * Please use the new check() method instead. */ entitled(params: CheckParams): Promise<Result<CheckResult, AutumnError>>; static check: (params: CheckParams) => Promise<Result<CheckResult, AutumnError>>; check(params: CheckParams): Promise<Result<CheckResult, AutumnError>>; /** * @deprecated This method is deprecated and will be removed in a future version. * Please use the new track() method instead. */ static event: (params: TrackParams) => Promise<Result<TrackResult, AutumnError>>; /** * @deprecated This method is deprecated and will be removed in a future version. * Please use the new track() method instead. */ event(params: TrackParams): Promise<Result<TrackResult, AutumnError>>; static track: (params: TrackParams) => Promise<Result<TrackResult, AutumnError>>; track(params: TrackParams): Promise<Result<TrackResult, AutumnError>>; usage(params: UsageParams): Promise<Result<UsageResult, AutumnError>>; } interface CreateReferralCodeParams { customer_id: string; program_id: string; } interface RedeemReferralCodeParams { code: string; customer_id: string; } declare const createAutumnClient: (publishableKey?: string) => Autumn; declare const getOrCreateCustomer: (args: Omit<{ customerId: string; customerData?: CustomerData; params?: CreateCustomerParams; }, "customerId"> & { encryptedCustomerId?: string; }, request?: Request) => Promise<any>; declare const getCustomer: (args: Omit<{ customerId: string; params?: GetCustomerParams; }, "customerId"> & { encryptedCustomerId?: string; }, request?: Request) => Promise<any>; declare const getEntityAction: (args: Omit<{ customerId: string; entityId: string; params?: GetEntityParams$1; }, "customerId"> & { encryptedCustomerId?: string; }, request?: Request) => Promise<any>; declare const createEntityAction: (args: Omit<{ customerId: string; entity: CreateEntityParams | CreateEntityParams[]; }, "customerId"> & { encryptedCustomerId?: string; }, request?: Request) => Promise<any>; declare const deleteEntityAction: (args: Omit<{ customerId: string; entityId: string; }, "customerId"> & { encryptedCustomerId?: string; }, request?: Request) => Promise<any>; export { createAutumnClient, createEntityAction, deleteEntityAction, getCustomer, getEntityAction, getOrCreateCustomer };