2020-05-20 12:07:58 +03:00
|
|
|
module.exports.formattedMemberResponse = function formattedMemberResponse(member) {
|
|
|
|
if (!member) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
uuid: member.uuid,
|
|
|
|
email: member.email,
|
|
|
|
name: member.name,
|
|
|
|
firstname: member.name && member.name.split(' ')[0],
|
|
|
|
avatar_image: member.avatar_image,
|
|
|
|
subscribed: !!member.subscribed,
|
|
|
|
subscriptions: member.stripe ? member.stripe.subscriptions : [],
|
2020-11-25 13:39:07 +03:00
|
|
|
paid: member.stripe && member.stripe.subscriptions && member.stripe.subscriptions.filter((subscription) => {
|
|
|
|
return ['active', 'trialing', 'unpaid', 'past_due'].includes(subscription.status);
|
|
|
|
}).length !== 0
|
2020-05-20 12:07:58 +03:00
|
|
|
};
|
|
|
|
};
|