@cranberry-money/shared-services
Version:
Platform-agnostic API services with pure functions and dependency injection. Includes auth, portfolios, instruments, countries, sectors, and more.
28 lines • 1.1 kB
JavaScript
import { TAX_RESIDENCY_ENDPOINTS } from '@cranberry-money/shared-constants';
let configuredApiClient = null;
export const configureTaxResidencies = (apiClient) => {
configuredApiClient = apiClient;
};
const getConfiguredClient = () => {
if (!configuredApiClient) {
throw new Error('Tax residencies service not configured. Call configureTaxResidencies(apiClient) before using tax residencies functions.');
}
return configuredApiClient;
};
export const createTaxResidency = (data) => {
return getConfiguredClient().post(TAX_RESIDENCY_ENDPOINTS.BASE, data);
};
export const updateTaxResidency = (uuid, data) => {
return getConfiguredClient().patch(`${TAX_RESIDENCY_ENDPOINTS.BASE}${uuid}/`, data);
};
export const deleteTaxResidency = (uuid) => {
return getConfiguredClient().delete(`${TAX_RESIDENCY_ENDPOINTS.BASE}${uuid}/`);
};
export const getTaxResidencies = () => {
return getConfiguredClient().get(TAX_RESIDENCY_ENDPOINTS.BASE, {
params: {
order_by: '-is_primary,country',
},
});
};
//# sourceMappingURL=taxResidencies.js.map