1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00
vault-frontend/src/redux/messages/api.ts
2021-09-20 14:43:24 +07:00

29 lines
956 B
TypeScript

import { api, cleanResult } from '~/utils/api';
import { API } from '~/constants/api';
import {
ApiDeleteMessageRequest,
ApiDeleteMessageResult,
ApiGetUserMessagesRequest,
ApiGetUserMessagesResponse,
ApiSendMessageRequest,
ApiSendMessageResult,
} from '~/redux/messages/types';
export const apiGetUserMessages = ({ username, after, before }: ApiGetUserMessagesRequest) =>
api
.get<ApiGetUserMessagesResponse>(API.USER.MESSAGES(username), {
params: { after, before },
})
.then(cleanResult);
export const apiSendMessage = ({ username, message }: ApiSendMessageRequest) =>
api
.post<ApiSendMessageResult>(API.USER.MESSAGE_SEND(username), { message })
.then(cleanResult);
export const apiDeleteMessage = ({ username, id, is_locked }: ApiDeleteMessageRequest) =>
api
.delete<ApiDeleteMessageResult>(API.USER.MESSAGE_DELETE(username, id), {
params: { isLocked: is_locked },
})
.then(cleanResult);