Files
bigcapital/shared/sdk-ts/src/settings.ts
Ahmed Bouhuolia ac8dcfed67 feat(sdk): enhance authentication and account management API endpoints
- Added new authentication routes for user sign-in, sign-up, and password reset functionalities.
- Updated account management routes to include bulk delete and validation for accounts.
- Refactored type definitions to utilize utility functions for better type safety and clarity.
- Introduced new methods for handling user authentication and account operations in the SDK.
2026-03-05 01:07:14 +02:00

31 lines
1.1 KiB
TypeScript

import type { ApiFetcher } from './fetch-utils';
import { paths } from './schema';
import { OpForPath, OpQueryParams, OpRequestBody, OpResponseBody } from './utils';
export const SETTINGS_ROUTES = {
GET_SAVE: '/api/settings',
} as const satisfies Record<string, keyof paths>;
export type SettingsResponse = OpResponseBody<OpForPath<typeof SETTINGS_ROUTES.GET_SAVE, 'get'>>;
export type SaveSettingsBody = OpRequestBody<OpForPath<typeof SETTINGS_ROUTES.GET_SAVE, 'put'>>;
export type GetSettingsQuery = OpQueryParams<OpForPath<typeof SETTINGS_ROUTES.GET_SAVE, 'get'>>;
export async function fetchSettings(
fetcher: ApiFetcher,
query?: GetSettingsQuery
): Promise<SettingsResponse> {
const get = fetcher.path(SETTINGS_ROUTES.GET_SAVE).method('get').create();
const { data } = await (get as (params?: GetSettingsQuery) => Promise<{ data: SettingsResponse }>)(
query ?? {}
);
return data;
}
export async function saveSettings(
fetcher: ApiFetcher,
values: SaveSettingsBody
): Promise<void> {
const put = fetcher.path(SETTINGS_ROUTES.GET_SAVE).method('put').create();
await put(values);
}