UNPKG

@cranberry-money/shared-services

Version:

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

27 lines 1.14 kB
import { PORTFOLIO_ENDPOINTS } from '@cranberry-money/shared-constants'; let configuredApiClient = null; export const configurePortfolios = (apiClient) => { configuredApiClient = apiClient; }; const getConfiguredClient = () => { if (!configuredApiClient) { throw new Error('Portfolios service not configured. Call configurePortfolios(apiClient) before using portfolio functions.'); } return configuredApiClient; }; export const getPortfolios = () => { return getConfiguredClient().get(PORTFOLIO_ENDPOINTS.BASE); }; export const createPortfolio = (data) => { return getConfiguredClient().post(PORTFOLIO_ENDPOINTS.BASE, data); }; export const updatePortfolio = (uuid, data) => { return getConfiguredClient().patch(`${PORTFOLIO_ENDPOINTS.BASE}${uuid}/`, data); }; export const getPortfolioByUuid = (uuid) => { return getConfiguredClient().get(`${PORTFOLIO_ENDPOINTS.BASE}${uuid}/`); }; export const generateRebalancingTrades = (portfolioUuid) => { return getConfiguredClient().post(`${PORTFOLIO_ENDPOINTS.BASE}${portfolioUuid}/generate-rebalancing-trades/`); }; //# sourceMappingURL=portfolios.js.map