Skip to content

Commit

Permalink
Added cred and on_cred endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek Y authored and Abhishek Y committed Oct 25, 2024
1 parent 589a537 commit a435811
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
4 changes: 4 additions & 0 deletions src/schemas/configs/actions.app.config.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand All @@ -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"
}
Expand All @@ -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()
}),
Expand All @@ -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()
}),
Expand Down
22 changes: 13 additions & 9 deletions src/utils/actions.utils.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,20 +18,22 @@ 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:
return ResponseActions.rating_categories;
}
}

public static getCorrespondingRequestAction(action: ResponseActions): RequestActions{
public static getCorrespondingRequestAction(action: ResponseActions): RequestActions {
switch (action) {
case ResponseActions.on_cancel:
return RequestActions.cancel;
Expand All @@ -47,21 +49,23 @@ 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:
return RequestActions.get_rating_categories;
}
}

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)
]);
Expand Down

0 comments on commit a435811

Please sign in to comment.