refactor: Update SubscriptionPlan method name to getPlanType

This commit is contained in:
Simon Larsen
2024-06-27 16:00:21 +01:00
parent 8be8c23ed9
commit 0a00cd9581
5 changed files with 9 additions and 9 deletions

View File

@@ -39,7 +39,7 @@ RunCron(
try {
if (project.paymentProviderPlanId) {
// get subscription detail.
const planName: PlanType = SubscriptionPlan.getPlanSelect(
const planName: PlanType = SubscriptionPlan.getPlanType(
project.paymentProviderPlanId as string,
);

View File

@@ -118,7 +118,7 @@ describe("SubscriptionPlan", () => {
expect(isValidPlanId).toBe(true);
});
});
describe("getPlanSelect", () => {
describe("getPlanType", () => {
it("should return the plan name if valid planId is passed", () => {
new SubscriptionPlan(
monthlyPlanId,
@@ -129,7 +129,7 @@ describe("SubscriptionPlan", () => {
2,
30,
);
const result: PlanType = SubscriptionPlan.getPlanSelect(
const result: PlanType = SubscriptionPlan.getPlanType(
monthlyPlanId,
env,
);
@@ -140,7 +140,7 @@ describe("SubscriptionPlan", () => {
.fn()
.mockReturnValue(undefined);
expect(() => {
SubscriptionPlan.getPlanSelect("invalid-plan-id", env);
SubscriptionPlan.getPlanType("invalid-plan-id", env);
}).toThrow(BadDataException);
});
});

View File

@@ -157,7 +157,7 @@ export default class SubscriptionPlan {
return Boolean(this.getSubscriptionPlanById(planId, env));
}
public static getPlanSelect(
public static getPlanType(
planId: string,
env?: JSONObject | undefined,
): PlanType {

View File

@@ -114,7 +114,7 @@ export class Service extends DatabaseService<Model> {
throw new BadDataException("Plan is invalid.");
}
data.data.planName = SubscriptionPlan.getPlanSelect(
data.data.planName = SubscriptionPlan.getPlanType(
data.data.paymentProviderPlanId,
);
@@ -358,7 +358,7 @@ export class Service extends DatabaseService<Model> {
paymentProviderMeteredSubscriptionId:
subscription.meteredSubscriptionId,
trialEndsAt: subscription.trialEndsAt || new Date(),
planName: SubscriptionPlan.getPlanSelect(
planName: SubscriptionPlan.getPlanType(
updateBy.data.paymentProviderPlanId! as string,
),
},
@@ -968,7 +968,7 @@ export class Service extends DatabaseService<Model> {
throw new BadDataException("Project does not have any plans");
}
const plan: PlanType = SubscriptionPlan.getPlanSelect(
const plan: PlanType = SubscriptionPlan.getPlanType(
project.paymentProviderPlanId,
getAllEnvVars(),
);

View File

@@ -44,7 +44,7 @@ export default class ProjectUtil {
return null;
}
return SubscriptionPlan.getPlanSelect(
return SubscriptionPlan.getPlanType(
project.paymentProviderPlanId,
getAllEnvVars(),
);