UNPKG

@cranberry-money/shared-services

Version:

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

35 lines 1.37 kB
import { STOCK_EXCHANGE_ENDPOINTS } from '@cranberry-money/shared-constants'; let configuredApiClient = null; export const configureStockExchanges = (apiClient) => { configuredApiClient = apiClient; }; const getConfiguredClient = () => { if (!configuredApiClient) { throw new Error('Stock exchanges service not configured. Call configureStockExchanges(apiClient) before using stock exchanges functions.'); } return configuredApiClient; }; export const getStockExchanges = (params) => { const queryParams = {}; if (params?.name) queryParams.name = params.name; if (params?.short_name) queryParams.short_name = params.short_name; if (params?.country_uuid) queryParams.country_uuid = params.country_uuid; if (params?.country_code) queryParams.country_code = params.country_code; 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(STOCK_EXCHANGE_ENDPOINTS.BASE, { params: queryParams, }); }; export const getStockExchangeByUuid = (uuid) => { return getConfiguredClient().get(`${STOCK_EXCHANGE_ENDPOINTS.BASE}${uuid}/`); }; //# sourceMappingURL=stockExchanges.js.map