@mft/moneyhub-api-client
Version:
Node.JS client for the Moneyhub API
29 lines • 1.41 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = ({ config, request }) => {
const { resourceServerUrl } = config;
const BENEFICIARIES_READ_SCOPE = "beneficiaries:read";
const BENEFICIARIES_DETAIL_READ_SCOPE = "beneficiaries_detail:read";
const getOneBeneficiary = ({ id, userId, scope, }, options) => request(`${resourceServerUrl}/beneficiaries/${id}`, {
cc: {
sub: userId,
scope,
},
options,
});
const getAllBeneficiaries = ({ params, userId, scope, }, options) => request(`${resourceServerUrl}/beneficiaries`, {
searchParams: params,
cc: {
sub: userId,
scope,
},
options,
});
return {
getBeneficiary: ({ id, userId }, options) => getOneBeneficiary({ id, userId, scope: BENEFICIARIES_READ_SCOPE }, options),
getBeneficiaryWithDetail: ({ id, userId }, options) => getOneBeneficiary({ id, userId, scope: BENEFICIARIES_DETAIL_READ_SCOPE }, options),
getBeneficiaries: ({ userId, params = {} }, options) => getAllBeneficiaries({ params, userId, scope: BENEFICIARIES_READ_SCOPE }, options),
getBeneficiariesWithDetail: ({ userId, params = {} }, options) => getAllBeneficiaries({ params, userId, scope: BENEFICIARIES_DETAIL_READ_SCOPE }, options),
};
};
//# sourceMappingURL=beneficiaries.js.map