1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update user |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | user: string, |
12 | body: { |
13 | users: { |
14 | country?: string; |
15 | language?: string; |
16 | microsoft?: false | true; |
17 | $shift_effective_from?: {}; |
18 | id?: string; |
19 | state?: string; |
20 | fax?: string; |
21 | country_locale?: string; |
22 | zip?: string; |
23 | created_time?: string; |
24 | time_format?: "HH:mm" | "hh:mm a"; |
25 | offset?: number; |
26 | imap_status?: false | true; |
27 | image_link?: string; |
28 | ezuid?: string; |
29 | profile?: { name: string; id: string }; |
30 | role?: { name: string; id: string }; |
31 | created_by?: { name: string; id: string; email?: string }; |
32 | full_name?: string; |
33 | zuid?: string; |
34 | phone?: string; |
35 | dob?: string; |
36 | status?: string; |
37 | customize_info?: { |
38 | notes_desc: {}; |
39 | show_right_panel: {}; |
40 | bc_view: {}; |
41 | unpin_recent_item: {}; |
42 | show_home: false | true; |
43 | show_detail_view: false | true; |
44 | }; |
45 | city?: string; |
46 | signature?: string; |
47 | sort_order_preference__s?: string; |
48 | category?: string; |
49 | date_format?: "MMM d, yyyy"; |
50 | confirm?: false | true; |
51 | decimal_separator?: "Comma" | "Period"; |
52 | number_separator?: "Space"; |
53 | time_zone?: {}; |
54 | last_name?: string; |
55 | mobile?: string; |
56 | $current_shift?: { name: string; id: string }; |
57 | Reporting_To?: { name: string; id: string; email?: string }; |
58 | Currency?: string; |
59 | $next_shift?: { name: string; id: string }; |
60 | Modified_Time?: string; |
61 | website?: string; |
62 | status_reason__s?: string; |
63 | email?: string; |
64 | first_name?: string; |
65 | sandboxDeveloper?: false | true; |
66 | alias?: string; |
67 | street?: string; |
68 | Modified_By?: { |
69 | name: string; |
70 | id: string; |
71 | last_name: string; |
72 | first_name: string; |
73 | }; |
74 | Isonline?: false | true; |
75 | locale?: string; |
76 | name_format__s?: |
77 | | "Salutation,First Name,Last Name" |
78 | | "Saluation,Last Name,First Name" |
79 | | "First Name,Last Name,Saluation"; |
80 | personal_account?: false | true; |
81 | default_tab_group?: string; |
82 | theme?: { |
83 | normal_tab: { font_color: "#FFFFFF"; background: "#222222" }; |
84 | selected_tab: { font_color: "#FFFFFF"; background: "#222222" }; |
85 | new_background: string; |
86 | background: "#F3F0EB"; |
87 | screen: "fixed"; |
88 | type: string; |
89 | }; |
90 | ntc_notification_type?: number[]; |
91 | ntc_enabled?: false | true; |
92 | rtl_enabled?: false | true; |
93 | telephony_enabled?: false | true; |
94 | sort_order_preference?: string; |
95 | }[]; |
96 | }, |
97 | ) { |
98 | const url = new URL(`https://zohoapis.com/crm/v8/users/${user}`); |
99 |
|
100 | const response = await fetch(url, { |
101 | method: "PUT", |
102 | headers: { |
103 | "Content-Type": "application/json", |
104 | Authorization: "Zoho-oauthtoken " + auth.token, |
105 | }, |
106 | body: JSON.stringify(body), |
107 | }); |
108 | if (!response.ok) { |
109 | const text = await response.text(); |
110 | throw new Error(`${response.status} ${text}`); |
111 | } |
112 | return await response.json(); |
113 | } |
114 |
|