Skip to content

Commit

Permalink
fix(frontend): change CreateChannelApi request params in order to mat…
Browse files Browse the repository at this point in the history
…ch backend ones
  • Loading branch information
luigi-borriello00 authored and Ro0t-set committed May 21, 2024
1 parent e1f519f commit fb33a52
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions frontend-service/src/main/vue/api/piperchat/channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,29 @@ export module GetChannelsApi {
channelType: string;
description?: string;
}

export class Success extends Response {
statusCode = 200;
message = "Channels retrieved successfully";

constructor(public channels: Channel[]) {
super();
}
}

export type Type = Success;
}
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
}

export type Type = ServerNotFound | UserNotAuthorized;
}
export type Response = Responses.Type | Errors.Type;
Expand Down Expand Up @@ -69,20 +74,24 @@ export module GetChannelByIdApi {
channelType: string;
description?: string;
}

export class Success extends Response {
statusCode = 200;
message = "Channels retrieved successfully";

constructor(public channel: Channel) {
super();
}
}

export type Type = Success;
}
export module Errors {
export class ChannelNotFound extends ErrorResponse {
statusCode = 404;
error = "Channel not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
Expand All @@ -100,9 +109,10 @@ export module GetChannelByIdApi {

export module CreateChannelApi {
export enum ChannelType {
Messages = "messages",
Multimedia = "multimedia",
Messages = "TEXT",
Multimedia = "MULTIMEDIA",
}

export module Request {
export type Type = Body & Params;
export type Params = {
Expand Down Expand Up @@ -132,22 +142,26 @@ export module CreateChannelApi {
channelType: string;
description?: string;
}

export class Success extends Response {
statusCode = 200;
message = "Channel created successfully";
channel: Channel;

constructor(channel: Channel) {
super();
this.channel = channel;
}
}

export type Type = Success;
}
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
Expand Down Expand Up @@ -199,17 +213,20 @@ export module UpdateChannelApi {
statusCode = 200;
message = "Channel updated successfully";
}

export type Type = Success;
}
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
}

export class ChannelNotFound extends ErrorResponse {
statusCode = 404;
error = "Channel not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
Expand All @@ -219,6 +236,7 @@ export module UpdateChannelApi {
statusCode = 409;
error = "Channel already exists" as const;
}

export type Type =
| ServerNotFound
| ChannelNotFound
Expand Down Expand Up @@ -249,21 +267,25 @@ export module DeleteChannelApi {
statusCode = 200;
message = "Channel deleted successfully";
}

export type Type = Success;
}
export module Errors {
export class ServerNotFound extends ErrorResponse {
statusCode = 404;
error = "Server not found" as const;
}

export class ChannelNotFound extends ErrorResponse {
statusCode = 404;
error = "Channel not found" as const;
}

export class UserNotAuthorized extends ErrorResponse {
statusCode = 403;
error = "User not authorized" as const;
}

export type Type = ServerNotFound | ChannelNotFound | UserNotAuthorized;
}
export type Response = Responses.Type | Errors.Type;
Expand Down

0 comments on commit fb33a52

Please sign in to comment.