18 lines
661 B
JavaScript
18 lines
661 B
JavaScript
|
|
import { API_BASE_URL } from '../../../shared/services/apiConfig';
|
||
|
|
|
||
|
|
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();
|
||
|
|
}
|