From a4358111d390e0fa74e6eb3547a8988c74f624a4 Mon Sep 17 00:00:00 2001 From: Abhishek Y Date: Wed, 23 Oct 2024 11:02:14 +0530 Subject: [PATCH] Added cred and on_cred endpoint --- .../configs/actions.app.config.schema.ts | 4 ++++ src/utils/actions.utils.ts | 22 +++++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/schemas/configs/actions.app.config.schema.ts b/src/schemas/configs/actions.app.config.schema.ts index 4163f22..86e72a8 100644 --- a/src/schemas/configs/actions.app.config.schema.ts +++ b/src/schemas/configs/actions.app.config.schema.ts @@ -13,6 +13,7 @@ export enum RequestActions { cancel = "cancel", rating = "rating", support = "support", + cred = "cred", get_cancellation_reasons = "get_cancellation_reasons", get_rating_categories = "get_rating_categories" } @@ -28,6 +29,7 @@ export enum ResponseActions { on_cancel = "on_cancel", on_rating = "on_rating", on_support = "on_support", + on_cred = "on_cred", cancellation_reasons = "cancellation_reasons", rating_categories = "rating_categories" } @@ -49,6 +51,7 @@ export const actionsAppConfigSchema = z.object({ [RequestActions.cancel]: actionConfigSchema.optional(), [RequestActions.rating]: actionConfigSchema.optional(), [RequestActions.support]: actionConfigSchema.optional(), + [RequestActions.cred]: actionConfigSchema.optional(), [RequestActions.get_cancellation_reasons]: actionConfigSchema.optional(), [RequestActions.get_rating_categories]: actionConfigSchema.optional() }), @@ -64,6 +67,7 @@ export const actionsAppConfigSchema = z.object({ [ResponseActions.on_cancel]: actionConfigSchema.optional(), [ResponseActions.on_rating]: actionConfigSchema.optional(), [ResponseActions.on_support]: actionConfigSchema.optional(), + [ResponseActions.on_cred]: actionConfigSchema.optional(), [ResponseActions.cancellation_reasons]: actionConfigSchema.optional(), [ResponseActions.rating_categories]: actionConfigSchema.optional() }), diff --git a/src/utils/actions.utils.ts b/src/utils/actions.utils.ts index e30a7dd..5ff884c 100644 --- a/src/utils/actions.utils.ts +++ b/src/utils/actions.utils.ts @@ -1,8 +1,8 @@ import { z } from "zod"; import { RequestActions, ResponseActions } from "../schemas/configs/actions.app.config.schema"; -export class ActionUtils{ - public static getCorrespondingResponseAction(action: RequestActions): ResponseActions{ +export class ActionUtils { + public static getCorrespondingResponseAction(action: RequestActions): ResponseActions { switch (action) { case RequestActions.cancel: return ResponseActions.on_cancel; @@ -18,12 +18,14 @@ export class ActionUtils{ return ResponseActions.on_select; case RequestActions.status: return ResponseActions.on_status; - case RequestActions.support: + case RequestActions.support: return ResponseActions.on_support; - case RequestActions.track: + case RequestActions.track: return ResponseActions.on_track; case RequestActions.update: return ResponseActions.on_update; + case RequestActions.cred: + return ResponseActions.on_cred; case RequestActions.get_cancellation_reasons: return ResponseActions.cancellation_reasons; case RequestActions.get_rating_categories: @@ -31,7 +33,7 @@ export class ActionUtils{ } } - public static getCorrespondingRequestAction(action: ResponseActions): RequestActions{ + public static getCorrespondingRequestAction(action: ResponseActions): RequestActions { switch (action) { case ResponseActions.on_cancel: return RequestActions.cancel; @@ -47,12 +49,14 @@ export class ActionUtils{ return RequestActions.select; case ResponseActions.on_status: return RequestActions.status; - case ResponseActions.on_support: + case ResponseActions.on_support: return RequestActions.support; - case ResponseActions.on_track: + case ResponseActions.on_track: return RequestActions.track; case ResponseActions.on_update: return RequestActions.update; + case ResponseActions.on_cred: + return RequestActions.cred; case ResponseActions.cancellation_reasons: return RequestActions.get_cancellation_reasons; case ResponseActions.rating_categories: @@ -60,8 +64,8 @@ export class ActionUtils{ } } - public static parseAction(action: string): RequestActions | ResponseActions{ - const actionSchema=z.union([ + public static parseAction(action: string): RequestActions | ResponseActions { + const actionSchema = z.union([ z.nativeEnum(RequestActions), z.nativeEnum(ResponseActions) ]);