import ApiRequest from "@services/Api.Service";
import {
    FindConversationsResults,
    ISendMessageResult,
    MarkConversationAsReadParams,
    PaginateFindContactsParams,
    PaginateFindContactsResults,
    PaginateMessageParams,
    PaginateMessageResults,
    SendMessageParams,
} from "@core/Models/Messages.model";
import { ApiVoidResult } from "@core/Models/Api.VoidResult.type";

export const messagesFindConversations = async (
    data: PaginateFindContactsParams
): Promise<FindConversationsResults> => {
    return ApiRequest.post<FindConversationsResults>("messages/find-conversations", data);
};

export const messagesFindContacts = async (
    data: PaginateFindContactsParams
): Promise<PaginateFindContactsResults> => {
    return ApiRequest.post<PaginateFindContactsResults>("messages/find-contacts", data);
};

export const messagesFind = async (
    data: PaginateMessageParams
): Promise<PaginateMessageResults> => {
    return ApiRequest.post<PaginateMessageResults>("messages/paginate", data);
};

export const sendMessage = async (data: SendMessageParams): Promise<ISendMessageResult> => {
    return ApiRequest.post<ISendMessageResult>("messages/send", data);
};

export const markConversationAsRead = async (
    data: MarkConversationAsReadParams
): Promise<ApiVoidResult> => {
    return ApiRequest.post<ApiVoidResult>("messages/conversation-read", data);
};
