Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cred endpoint #241

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading