Update contact
One script reply has been approved by the moderators Verified
Created by hugo697 486 days ago
Submitted by hugo697 Bun
Verified 486 days ago
1
//native
2
type Actimo = {
3
	apiKey: string
4
}
5

6
export async function main(
7
	auth: Actimo,
8
	contactId: string,
9
	body: {
10
		addr_city?: string
11
		addr_country?: string
12
		addr_line_1?: string
13
		addr_line_2?: string
14
		addr_state?: string
15
		addr_zip?: string
16
		company?: string
17
		company_reg?: string
18
		country_code?: string
19
		data1?: string
20
		data2?: string
21
		data3?: string
22
		department?: string
23
		email?: string
24
		employee_id?: number
25
		first_name?: string
26
		last_name?: string
27
		manager_id?: number
28
		manager_name?: string
29
		manager_type?: string
30
		phone_number?: string
31
		timezone?: string
32
		title?: string
33
		'{data3-data20}'?: string
34
	}
35
) {
36
	const url = new URL(`https://actimo.com/api/v1/contacts/${contactId}`)
37

38
	const response = await fetch(url, {
39
		method: 'PUT',
40
		headers: {
41
			'api-key': auth.apiKey,
42
			'Content-Type': 'application/json'
43
		},
44
		body: JSON.stringify(body)
45
	})
46

47
	if (!response.ok) {
48
		const text = await response.text()
49
		throw new Error(`${response.status} ${text}`)
50
	}
51

52
	return await response.json()
53
}
54