import {BodyTypeItem} from "@/api/context/BodyType";

export async function list () {
    const response = await fetch('/api/v1/body-types');
    return (await response.json()).results.rows;
}

export async function add (params: BodyTypeItem) {
    const response = await fetch('/api/v1/body-types', {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(params)
    });
    return await response.json();
}

export async function update (params: BodyTypeItem) {
    const response = await fetch('/api/v1/body-types', {
        method: 'PUT',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify({
            updates: params,
            where: {
                id: params.id,
            }
        })
    });
    return await response.json();
}

export async function remove (params: BodyTypeItem) {
    const response = await fetch('/api/v1/body-types', {
        method: 'DELETE',
        headers: {
            'Content-Type': 'application/json',
        },
        body: JSON.stringify(params)
    });
    return await response.json();
}