(userId)
| 763 | |
| 764 | // test |
| 765 | public static async getSubscriptionStatus(userId) { |
| 766 | if (!userId) { |
| 767 | throw new Error('Bad data'); |
| 768 | } |
| 769 | |
| 770 | const teamLeader = await this.findOne({ _id: userId }).setOptions({ |
| 771 | lean: true, |
| 772 | }); |
| 773 | |
| 774 | if (!teamLeader) { |
| 775 | throw new Error('Team Leader not found'); |
| 776 | } |
| 777 | |
| 778 | // isSubscriptionActiveForTeam: true or false |
| 779 | return { |
| 780 | isSubscriptionActiveForAccount: teamLeader.isSubscriptionActiveForAccount, |
| 781 | isPaymentFailedForAccount: teamLeader.isPaymentFailedForAccount, |
| 782 | isTrialPeriodOverForAccount: moment(new Date()).isAfter( |
| 783 | moment(teamLeader.trialPeriodStartDate).add(30, 'days'), |
| 784 | ), |
| 785 | }; |
| 786 | } |
| 787 | |
| 788 | // test |
| 789 | public static async createOrUpdateInvitedUserAndAddToTeam({ emailOfInvitee, teamId, userId }) { |
no outgoing calls
no test coverage detected