UNPKG

@cranberry-money/shared-services

Version:

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

24 lines 1.13 kB
import { PORTFOLIO_TEMPLATE_ENDPOINTS } from '@cranberry-money/shared-constants'; let configuredApiClient = null; export const configurePortfolioTemplates = (apiClient) => { configuredApiClient = apiClient; }; const getConfiguredClient = () => { if (!configuredApiClient) { throw new Error('Portfolio templates service not configured. Call configurePortfolioTemplates(apiClient) before using portfolio template functions.'); } return configuredApiClient; }; export const getPortfolioTemplates = () => { return getConfiguredClient().get(PORTFOLIO_TEMPLATE_ENDPOINTS.BASE); }; export const getRecommendedPortfolioTemplate = () => { return getConfiguredClient().get(PORTFOLIO_TEMPLATE_ENDPOINTS.RECOMMENDED); }; export const getPortfolioTemplateAllocations = (templateUuid) => { return getConfiguredClient().get(`${PORTFOLIO_TEMPLATE_ENDPOINTS.BASE}${templateUuid}/allocations/`); }; export const applyPortfolioTemplate = (templateUuid) => { return getConfiguredClient().post(`${PORTFOLIO_TEMPLATE_ENDPOINTS.BASE}${templateUuid}/apply/`, {}); }; //# sourceMappingURL=portfolioTemplates.js.map