Add channel and role api
This commit is contained in:
parent
8881070cac
commit
1fbd120404
22 changed files with 538 additions and 2 deletions
42
src/api/channel/channel.ts
Normal file
42
src/api/channel/channel.ts
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
import { callApi, HTTP } from "../tools";
|
||||
import {
|
||||
IFetchChannelRequest,
|
||||
IFetchChannelResponse,
|
||||
ICreateChannelRequest,
|
||||
ICreateChannelResponse,
|
||||
IUpdateChannelRequest,
|
||||
IUpdateChannelResponse,
|
||||
IRemoveChannelRequest,
|
||||
IRemoveChannelResponse,
|
||||
} from "./types";
|
||||
|
||||
const fetchChannelApi = async (
|
||||
request: IFetchChannelRequest,
|
||||
): Promise<IFetchChannelResponse> => {
|
||||
return await callApi(HTTP.GET, `channel/${request.id}`);
|
||||
};
|
||||
|
||||
const createChannelApi = async (
|
||||
request: ICreateChannelRequest,
|
||||
): Promise<ICreateChannelResponse> => {
|
||||
return await callApi(HTTP.POST, `channel`, request);
|
||||
};
|
||||
|
||||
const updateChannelApi = async (
|
||||
request: IUpdateChannelRequest,
|
||||
): Promise<IUpdateChannelResponse> => {
|
||||
return await callApi(HTTP.PATCH, `channel/${request.id}`, request);
|
||||
};
|
||||
|
||||
const removeChannelApi = async (
|
||||
request: IRemoveChannelRequest,
|
||||
): Promise<IRemoveChannelResponse> => {
|
||||
return await callApi(HTTP.DELETE, `channel/${request.id}`, request);
|
||||
};
|
||||
|
||||
export {
|
||||
fetchChannelApi,
|
||||
createChannelApi,
|
||||
updateChannelApi,
|
||||
removeChannelApi,
|
||||
};
|
||||
2
src/api/channel/index.ts
Normal file
2
src/api/channel/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * from "./channel";
|
||||
export * from "./types";
|
||||
47
src/api/channel/types.ts
Normal file
47
src/api/channel/types.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
interface IFetchChannel {
|
||||
id: string;
|
||||
name: string;
|
||||
communityId: string;
|
||||
creationDate: number;
|
||||
}
|
||||
|
||||
interface IFetchChannelRequest {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IFetchChannelResponse extends IFetchChannel {}
|
||||
|
||||
interface ICreateChannelRequest {
|
||||
name: string;
|
||||
communityId: string;
|
||||
}
|
||||
|
||||
interface ICreateChannelResponse extends IFetchChannel {}
|
||||
|
||||
interface IUpdateChannelRequest {
|
||||
id: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
interface IUpdateChannelResponse extends IFetchChannel {}
|
||||
|
||||
interface IRemoveChannelRequest {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IRemoveChannelResponse {
|
||||
id: string;
|
||||
communityId: string;
|
||||
}
|
||||
|
||||
export {
|
||||
type IFetchChannel,
|
||||
type IFetchChannelRequest,
|
||||
type IFetchChannelResponse,
|
||||
type ICreateChannelRequest,
|
||||
type ICreateChannelResponse,
|
||||
type IUpdateChannelRequest,
|
||||
type IUpdateChannelResponse,
|
||||
type IRemoveChannelResponse,
|
||||
type IRemoveChannelRequest,
|
||||
};
|
||||
2
src/api/role/index.ts
Normal file
2
src/api/role/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * from "./role";
|
||||
export * from "./types";
|
||||
37
src/api/role/role.ts
Normal file
37
src/api/role/role.ts
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
import { callApi, HTTP } from "../tools";
|
||||
import {
|
||||
IFetchRoleRequest,
|
||||
IFetchRoleResponse,
|
||||
ICreateRoleRequest,
|
||||
ICreateRoleResponse,
|
||||
IUpdateRoleRequest,
|
||||
IUpdateRoleResponse,
|
||||
IRemoveRoleRequest,
|
||||
IRemoveRoleResponse,
|
||||
} from "./types";
|
||||
|
||||
const fetchRoleApi = async (
|
||||
request: IFetchRoleRequest,
|
||||
): Promise<IFetchRoleResponse> => {
|
||||
return await callApi(HTTP.GET, `role/${request.id}`);
|
||||
};
|
||||
|
||||
const createRoleApi = async (
|
||||
request: ICreateRoleRequest,
|
||||
): Promise<ICreateRoleResponse> => {
|
||||
return await callApi(HTTP.POST, `role`, request);
|
||||
};
|
||||
|
||||
const updateRoleApi = async (
|
||||
request: IUpdateRoleRequest,
|
||||
): Promise<IUpdateRoleResponse> => {
|
||||
return await callApi(HTTP.PATCH, `role/${request.id}`, request);
|
||||
};
|
||||
|
||||
const removeRoleApi = async (
|
||||
request: IRemoveRoleRequest,
|
||||
): Promise<IRemoveRoleResponse> => {
|
||||
return await callApi(HTTP.DELETE, `role/${request.id}`, request);
|
||||
};
|
||||
|
||||
export { fetchRoleApi, createRoleApi, updateRoleApi, removeRoleApi };
|
||||
47
src/api/role/types.ts
Normal file
47
src/api/role/types.ts
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
interface IFetchRole {
|
||||
id: string;
|
||||
name: string;
|
||||
communityId: string;
|
||||
creationDate: number;
|
||||
}
|
||||
|
||||
interface IFetchRoleRequest {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IFetchRoleResponse extends IFetchRole {}
|
||||
|
||||
interface ICreateRoleRequest {
|
||||
name: string;
|
||||
communityId: string;
|
||||
}
|
||||
|
||||
interface ICreateRoleResponse extends IFetchRole {}
|
||||
|
||||
interface IUpdateRoleRequest {
|
||||
id: string;
|
||||
name?: string;
|
||||
}
|
||||
|
||||
interface IUpdateRoleResponse extends IFetchRole {}
|
||||
|
||||
interface IRemoveRoleRequest {
|
||||
id: string;
|
||||
}
|
||||
|
||||
interface IRemoveRoleResponse {
|
||||
id: string;
|
||||
communityId: string;
|
||||
}
|
||||
|
||||
export {
|
||||
type IFetchRole,
|
||||
type IFetchRoleRequest,
|
||||
type IFetchRoleResponse,
|
||||
type ICreateRoleRequest,
|
||||
type ICreateRoleResponse,
|
||||
type IUpdateRoleRequest,
|
||||
type IUpdateRoleResponse,
|
||||
type IRemoveRoleResponse,
|
||||
type IRemoveRoleRequest,
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue