redeploy

This commit is contained in:
Maxime Lalo 2024-04-25 11:36:24 +02:00
parent ed46eddf29
commit eae6aece6c

View File

@ -2,7 +2,7 @@ import authHandler from "@App/middlewares/AuthHandler";
import ruleHandler from "@App/middlewares/RulesHandler"; import ruleHandler from "@App/middlewares/RulesHandler";
// import roleHandler from "@App/middlewares/RolesHandler"; // import roleHandler from "@App/middlewares/RolesHandler";
import ApiController from "@Common/system/controller-pattern/ApiController"; import ApiController from "@Common/system/controller-pattern/ApiController";
import { Controller, Get, Post} from "@ControllerPattern/index"; import { Controller, Get, Post } from "@ControllerPattern/index";
import StripeService from "@Services/common/StripeService/StripeService"; import StripeService from "@Services/common/StripeService/StripeService";
import { validateOrReject } from "class-validator"; import { validateOrReject } from "class-validator";
import { Request, Response } from "express"; import { Request, Response } from "express";
@ -28,13 +28,13 @@ export default class StripeController extends ApiController {
//add office id to request body //add office id to request body
req.body.office = { uid: officeId }; req.body.office = { uid: officeId };
const frequency : EPaymentFrequency = req.body.frequency; const frequency: EPaymentFrequency = req.body.frequency;
if(!frequency || !Object.values(EPaymentFrequency).includes(frequency)) { if (!frequency || !Object.values(EPaymentFrequency).includes(frequency)) {
this.httpBadRequest(response, "Invalid frequency"); this.httpBadRequest(response, "Invalid frequency");
return; return;
} }
//init Subscription resource with request body values //init Subscription resource with request body valuess
const subscriptionEntity = Subscription.hydrate<Subscription>(req.body, { strategy: "excludeAll" }); const subscriptionEntity = Subscription.hydrate<Subscription>(req.body, { strategy: "excludeAll" });
await validateOrReject(subscriptionEntity, { groups: ["createSubscription"], forbidUnknownValues: false }); await validateOrReject(subscriptionEntity, { groups: ["createSubscription"], forbidUnknownValues: false });
@ -42,7 +42,6 @@ export default class StripeController extends ApiController {
const stripeSession = await this.stripeService.createCheckoutSession(subscriptionEntity, frequency); const stripeSession = await this.stripeService.createCheckoutSession(subscriptionEntity, frequency);
this.httpCreated(response, stripeSession); this.httpCreated(response, stripeSession);
} catch (error) { } catch (error) {
this.httpInternalError(response, error); this.httpInternalError(response, error);
return; return;
@ -70,7 +69,6 @@ export default class StripeController extends ApiController {
@Get("/api/v1/admin/stripe/:uid/client-portal", [authHandler, ruleHandler]) @Get("/api/v1/admin/stripe/:uid/client-portal", [authHandler, ruleHandler])
protected async getClientPortalSession(req: Request, response: Response) { protected async getClientPortalSession(req: Request, response: Response) {
try { try {
const uid = req.params["uid"]; const uid = req.params["uid"];
if (!uid) { if (!uid) {
this.httpBadRequest(response, "No uid provided"); this.httpBadRequest(response, "No uid provided");
@ -95,7 +93,7 @@ export default class StripeController extends ApiController {
return; return;
} }
const customer = await this.stripeService.getCustomerBySubscription(uid); const customer = await this.stripeService.getCustomerBySubscription(uid);
this.httpSuccess(response, customer); this.httpSuccess(response, customer);
} catch (error) { } catch (error) {
this.httpInternalError(response, error); this.httpInternalError(response, error);