/*
 * Copyright (c) 2022.
 * Author Peter Placzek (tada5hi)
 * For the full copyright and license information,
 * view the LICENSE file that was distributed with this source code.
 */

import {formatRequestRecord, RequestRecord} from "~/modules/api/utils";
import {useApi} from "~/modules/api";

export async function getInvitation(roomId: string) {
    const response = await useApi('auth')
        .get('/auth/invitations/' + roomId);

    return response.data;
}

export async function getInvitations(record?: RequestRecord) {
    const {data: response} = await useApi('auth')
        .get('/auth/invitations' + formatRequestRecord(record));

    return response;
}

export async function addInvitation(data?: Record<string, any>) {
    const {data: response} = await useApi('auth')
        .post('/auth/invitations', data);

    return response;
}

export async function editInvitation(id: string, data: Record<string, any>) {
    const {data: response} = await useApi('auth')
        .post('/auth/invitations/'+id, data);

    return response;
}

export async function dropInvitation(id: string) {
    const {data: response} = await useApi('auth')
        .delete('/auth/invitations/'+id);

    return response;
}
