1
//native
2
type Salesflare = {
3
apiKey: string;
4
};
5
/**
6
* Update a contact
7
*
8
*/
9
export async function main(
10
auth: Salesflare,
11
contact_id: string,
12
force: string | undefined,
13
) {
14
const url = new URL(`https://api.salesflare.com/contacts/${contact_id}`);
15
for (const [k, v] of [["force", force]]) {
16
if (v !== undefined && v !== "" && k !== undefined) {
17
url.searchParams.append(k, v);
18
}
19
20
const response = await fetch(url, {
21
method: "PUT",
22
headers: {
23
Authorization: "Bearer " + auth.apiKey,
24
},
25
body: undefined,
26
});
27
if (!response.ok) {
28
const text = await response.text();
29
throw new Error(`${response.status} ${text}`);
30
31
return await response.text();
32
33