UNPKG

@cranberry-money/shared-services

Version:

Platform-agnostic API services with pure functions and dependency injection. Includes auth, portfolios, instruments, countries, sectors, and more.

33 lines 1.17 kB
import { SECTOR_ENDPOINTS } from '@cranberry-money/shared-constants'; let configuredApiClient = null; export const configureSectors = (apiClient) => { configuredApiClient = apiClient; }; const getConfiguredClient = () => { if (!configuredApiClient) { throw new Error('Sectors service not configured. Call configureSectors(apiClient) before using sectors functions.'); } return configuredApiClient; }; export const getSectors = (params) => { const queryParams = {}; if (params?.name) queryParams.name = params.name; if (params?.order_by) queryParams.order_by = params.order_by; if (params?.page) queryParams.page = params.page.toString(); if (params?.page_size) queryParams.page_size = params.page_size.toString(); return getConfiguredClient().get(SECTOR_ENDPOINTS.BASE, { params: queryParams }); }; export const getSectorByUuid = (uuid) => { return getConfiguredClient().get(`${SECTOR_ENDPOINTS.BASE}${uuid}/`); }; export const searchSectors = (searchTerm, params) => { return getSectors({ ...params, name: searchTerm, }); }; //# sourceMappingURL=sectors.js.map