2022-04-04 18:15:40 +05:30
|
|
|
function formatNewsletterResponse(newsletters) {
|
|
|
|
return newsletters.map(({id, name, description, sort_order: sortOrder}) => {
|
|
|
|
return {id, name, description, sort_order: sortOrder};
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-05-20 14:37:58 +05:30
|
|
|
module.exports.formattedMemberResponse = function formattedMemberResponse(member) {
|
|
|
|
if (!member) {
|
|
|
|
return null;
|
|
|
|
}
|
2022-04-04 18:15:40 +05:30
|
|
|
const data = {
|
2020-05-20 14:37:58 +05:30
|
|
|
uuid: member.uuid,
|
|
|
|
email: member.email,
|
|
|
|
name: member.name,
|
|
|
|
firstname: member.name && member.name.split(' ')[0],
|
|
|
|
avatar_image: member.avatar_image,
|
|
|
|
subscribed: !!member.subscribed,
|
2021-01-28 22:55:38 +05:30
|
|
|
subscriptions: member.subscriptions || [],
|
2021-02-25 14:23:36 +00:00
|
|
|
paid: member.status !== 'free'
|
2020-05-20 14:37:58 +05:30
|
|
|
};
|
2022-05-26 09:54:30 +02:00
|
|
|
if (member.newsletters) {
|
2022-04-04 18:15:40 +05:30
|
|
|
data.newsletters = formatNewsletterResponse(member.newsletters);
|
|
|
|
}
|
|
|
|
return data;
|
2020-05-20 14:37:58 +05:30
|
|
|
};
|