mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-06-01 23:49:00 +00:00
- Add export-openapi.ts script for server OpenAPI spec export - Add shared/sdk-ts package with generated API clients (accounts, bills, customers, vendors, etc.) - Update Customers and Vendors controllers - Update ReportsEventsTracker - Update .gitignore, package.json, and pnpm-lock Made-with: Cursor
32 lines
1.2 KiB
TypeScript
32 lines
1.2 KiB
TypeScript
import type { ApiFetcher } from './fetch-utils';
|
|
import type { paths } from './schema';
|
|
|
|
export const SUBSCRIPTION_ROUTES = {
|
|
LIST: '/api/subscription',
|
|
CHECKOUT_URL: '/api/subscription/lemon/checkout_url',
|
|
CANCEL: '/api/subscription/cancel',
|
|
RESUME: '/api/subscription/resume',
|
|
CHANGE: '/api/subscription/change',
|
|
} as const satisfies Record<string, keyof paths>;
|
|
|
|
type GetSubscriptions = paths[typeof SUBSCRIPTION_ROUTES.LIST]['get'];
|
|
|
|
type GetSubscriptions200 = GetSubscriptions['responses'][200];
|
|
export type SubscriptionsListResponse = GetSubscriptions200 extends { content?: { 'application/json': infer J } } ? J : unknown;
|
|
|
|
export async function fetchSubscriptions(fetcher: ApiFetcher): Promise<SubscriptionsListResponse> {
|
|
const get = fetcher.path(SUBSCRIPTION_ROUTES.LIST).method('get').create();
|
|
const { data } = await get({});
|
|
return data;
|
|
}
|
|
|
|
export async function cancelSubscription(fetcher: ApiFetcher): Promise<void> {
|
|
const post = fetcher.path(SUBSCRIPTION_ROUTES.CANCEL).method('post').create();
|
|
await post({});
|
|
}
|
|
|
|
export async function resumeSubscription(fetcher: ApiFetcher): Promise<void> {
|
|
const post = fetcher.path(SUBSCRIPTION_ROUTES.RESUME).method('post').create();
|
|
await post({});
|
|
}
|