1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update record locking configurations |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | _module: string, |
12 | body: { |
13 | record_locking_configurations?: { |
14 | created_time?: string; |
15 | locked_for?: string; |
16 | excluded_fields?: { api_name: string; id: string }[]; |
17 | created_by?: { name: string; id: string; email?: string }; |
18 | feature_type?: string; |
19 | locking_rules?: { |
20 | name?: string; |
21 | id?: string; |
22 | lock_existing_records?: false | true; |
23 | criteria?: { |
24 | comparator: string; |
25 | field: { api_name: string; id: string }; |
26 | value: {}; |
27 | group_operator: string; |
28 | group: {}[]; |
29 | }; |
30 | _delete?: false | true; |
31 | }[]; |
32 | restricted_actions?: string[]; |
33 | lock_for_portal_users?: false | true; |
34 | modified_time?: string; |
35 | restricted_communications?: string[]; |
36 | system_defined?: false | true; |
37 | modified_by?: { name: string; id: string; email?: string }; |
38 | id?: string; |
39 | lock_type?: "automatic" | "manual" | "both"; |
40 | restricted_custom_buttons?: { name?: string; id?: string }[]; |
41 | lock_excluded_profiles?: { name?: string; id?: string }[]; |
42 | }[]; |
43 | }, |
44 | ) { |
45 | const url = new URL( |
46 | `https://zohoapis.com/crm/v8/settings/record_locking_configurations`, |
47 | ); |
48 | for (const [k, v] of [["module", _module]]) { |
49 | if (v !== undefined && v !== "" && k !== undefined) { |
50 | url.searchParams.append(k, v); |
51 | } |
52 | } |
53 | const response = await fetch(url, { |
54 | method: "PUT", |
55 | headers: { |
56 | "Content-Type": "application/json", |
57 | Authorization: "Zoho-oauthtoken " + auth.token, |
58 | }, |
59 | body: JSON.stringify(body), |
60 | }); |
61 | if (!response.ok) { |
62 | const text = await response.text(); |
63 | throw new Error(`${response.status} ${text}`); |
64 | } |
65 | return await response.json(); |
66 | } |
67 |
|