/*
 * 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 getContactData(id: string) {
    const response = await useApi('auth')
        .get('/auth/contacts-share-data/' + id);

    return response.data;
}

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

    return response;
}

export async function dropContactData(id: string) {
    const {data: response} = await useApi('auth')
        .delete('/auth/contact-data-exchange/'+id);

    return response;
}

export async function addContactData(data: {[key: string] : any}) {
    const { data: response } = await useApi('auth').post('auth/contact-data-exchange', data);

    return response;
}
