24 lines
862 B
JavaScript
24 lines
862 B
JavaScript
import { API_BASE_URL } from '../../../shared/services/apiConfig';
|
|
|
|
export async function listContactProfiles() {
|
|
const response = await fetch(`${API_BASE_URL}/contacts`);
|
|
if (!response.ok) throw new Error('Falha ao carregar agenda.');
|
|
return response.json();
|
|
}
|
|
|
|
export async function getContactProfile(chatId) {
|
|
const response = await fetch(`${API_BASE_URL}/contacts/${encodeURIComponent(chatId)}`);
|
|
if (!response.ok) throw new Error('Falha ao carregar contato.');
|
|
return response.json();
|
|
}
|
|
|
|
export async function saveContactProfile(chatId, payload) {
|
|
const response = await fetch(`${API_BASE_URL}/contacts/${encodeURIComponent(chatId)}`, {
|
|
method: 'PUT',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(payload),
|
|
});
|
|
if (!response.ok) throw new Error('Falha ao salvar contato.');
|
|
return response.json();
|
|
}
|