1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Update share permissions |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | module_api_name: string, |
12 | record_id: string, |
13 | body: { |
14 | share: { |
15 | shared_with?: { |
16 | country?: string; |
17 | language?: string; |
18 | microsoft?: false | true; |
19 | $shift_effective_from?: {}; |
20 | id?: string; |
21 | state?: string; |
22 | fax?: string; |
23 | country_locale?: string; |
24 | zip?: string; |
25 | created_time?: string; |
26 | time_format?: "HH:mm" | "hh:mm a"; |
27 | offset?: number; |
28 | imap_status?: false | true; |
29 | image_link?: string; |
30 | ezuid?: string; |
31 | profile?: { name: string; id: string }; |
32 | role?: { name: string; id: string }; |
33 | created_by?: { name: string; id: string; email?: string }; |
34 | full_name?: string; |
35 | zuid?: string; |
36 | phone?: string; |
37 | dob?: string; |
38 | status?: string; |
39 | customize_info?: { |
40 | notes_desc: {}; |
41 | show_right_panel: {}; |
42 | bc_view: {}; |
43 | unpin_recent_item: {}; |
44 | show_home: false | true; |
45 | show_detail_view: false | true; |
46 | }; |
47 | city?: string; |
48 | signature?: string; |
49 | sort_order_preference__s?: string; |
50 | category?: string; |
51 | date_format?: "MMM d, yyyy"; |
52 | confirm?: false | true; |
53 | decimal_separator?: "Comma" | "Period"; |
54 | number_separator?: "Space"; |
55 | time_zone?: {}; |
56 | last_name?: string; |
57 | mobile?: string; |
58 | $current_shift?: { name: string; id: string }; |
59 | Reporting_To?: { name: string; id: string; email?: string }; |
60 | Currency?: string; |
61 | $next_shift?: { name: string; id: string }; |
62 | Modified_Time?: string; |
63 | website?: string; |
64 | status_reason__s?: string; |
65 | email?: string; |
66 | first_name?: string; |
67 | sandboxDeveloper?: false | true; |
68 | alias?: string; |
69 | street?: string; |
70 | Modified_By?: { |
71 | name: string; |
72 | id: string; |
73 | last_name: string; |
74 | first_name: string; |
75 | }; |
76 | Isonline?: false | true; |
77 | locale?: string; |
78 | name_format__s?: |
79 | | "Salutation,First Name,Last Name" |
80 | | "Saluation,Last Name,First Name" |
81 | | "First Name,Last Name,Saluation"; |
82 | personal_account?: false | true; |
83 | default_tab_group?: string; |
84 | theme?: { |
85 | normal_tab: { font_color: "#FFFFFF"; background: "#222222" }; |
86 | selected_tab: { font_color: "#FFFFFF"; background: "#222222" }; |
87 | new_background: string; |
88 | background: "#F3F0EB"; |
89 | screen: "fixed"; |
90 | type: string; |
91 | }; |
92 | ntc_notification_type?: number[]; |
93 | ntc_enabled?: false | true; |
94 | rtl_enabled?: false | true; |
95 | telephony_enabled?: false | true; |
96 | sort_order_preference?: string; |
97 | }; |
98 | share_related_records: false | true; |
99 | shared_through: { |
100 | module: { name?: string; api_name?: string; id?: string }; |
101 | id: string; |
102 | entity_name: string; |
103 | name?: string; |
104 | }; |
105 | shared_time: string; |
106 | permission: string; |
107 | shared_by: { |
108 | country?: string; |
109 | language?: string; |
110 | microsoft?: false | true; |
111 | $shift_effective_from?: {}; |
112 | id?: string; |
113 | state?: string; |
114 | fax?: string; |
115 | country_locale?: string; |
116 | zip?: string; |
117 | created_time?: string; |
118 | time_format?: "HH:mm" | "hh:mm a"; |
119 | offset?: number; |
120 | imap_status?: false | true; |
121 | image_link?: string; |
122 | ezuid?: string; |
123 | profile?: { name: string; id: string }; |
124 | role?: { name: string; id: string }; |
125 | created_by?: { name: string; id: string; email?: string }; |
126 | full_name?: string; |
127 | zuid?: string; |
128 | phone?: string; |
129 | dob?: string; |
130 | status?: string; |
131 | customize_info?: { |
132 | notes_desc: {}; |
133 | show_right_panel: {}; |
134 | bc_view: {}; |
135 | unpin_recent_item: {}; |
136 | show_home: false | true; |
137 | show_detail_view: false | true; |
138 | }; |
139 | city?: string; |
140 | signature?: string; |
141 | sort_order_preference__s?: string; |
142 | category?: string; |
143 | date_format?: "MMM d, yyyy"; |
144 | confirm?: false | true; |
145 | decimal_separator?: "Comma" | "Period"; |
146 | number_separator?: "Space"; |
147 | time_zone?: {}; |
148 | last_name?: string; |
149 | mobile?: string; |
150 | $current_shift?: { name: string; id: string }; |
151 | Reporting_To?: { name: string; id: string; email?: string }; |
152 | Currency?: string; |
153 | $next_shift?: { name: string; id: string }; |
154 | Modified_Time?: string; |
155 | website?: string; |
156 | status_reason__s?: string; |
157 | email?: string; |
158 | first_name?: string; |
159 | sandboxDeveloper?: false | true; |
160 | alias?: string; |
161 | street?: string; |
162 | Modified_By?: { |
163 | name: string; |
164 | id: string; |
165 | last_name: string; |
166 | first_name: string; |
167 | }; |
168 | Isonline?: false | true; |
169 | locale?: string; |
170 | name_format__s?: |
171 | | "Salutation,First Name,Last Name" |
172 | | "Saluation,Last Name,First Name" |
173 | | "First Name,Last Name,Saluation"; |
174 | personal_account?: false | true; |
175 | default_tab_group?: string; |
176 | theme?: { |
177 | normal_tab: { font_color: "#FFFFFF"; background: "#222222" }; |
178 | selected_tab: { font_color: "#FFFFFF"; background: "#222222" }; |
179 | new_background: string; |
180 | background: "#F3F0EB"; |
181 | screen: "fixed"; |
182 | type: string; |
183 | }; |
184 | ntc_notification_type?: number[]; |
185 | ntc_enabled?: false | true; |
186 | rtl_enabled?: false | true; |
187 | telephony_enabled?: false | true; |
188 | sort_order_preference?: string; |
189 | }; |
190 | user: { |
191 | country?: string; |
192 | language?: string; |
193 | microsoft?: false | true; |
194 | $shift_effective_from?: {}; |
195 | id?: string; |
196 | state?: string; |
197 | fax?: string; |
198 | country_locale?: string; |
199 | zip?: string; |
200 | created_time?: string; |
201 | time_format?: "HH:mm" | "hh:mm a"; |
202 | offset?: number; |
203 | imap_status?: false | true; |
204 | image_link?: string; |
205 | ezuid?: string; |
206 | profile?: { name: string; id: string }; |
207 | role?: { name: string; id: string }; |
208 | created_by?: { name: string; id: string; email?: string }; |
209 | full_name?: string; |
210 | zuid?: string; |
211 | phone?: string; |
212 | dob?: string; |
213 | status?: string; |
214 | customize_info?: { |
215 | notes_desc: {}; |
216 | show_right_panel: {}; |
217 | bc_view: {}; |
218 | unpin_recent_item: {}; |
219 | show_home: false | true; |
220 | show_detail_view: false | true; |
221 | }; |
222 | city?: string; |
223 | signature?: string; |
224 | sort_order_preference__s?: string; |
225 | category?: string; |
226 | date_format?: "MMM d, yyyy"; |
227 | confirm?: false | true; |
228 | decimal_separator?: "Comma" | "Period"; |
229 | number_separator?: "Space"; |
230 | time_zone?: {}; |
231 | last_name?: string; |
232 | mobile?: string; |
233 | $current_shift?: { name: string; id: string }; |
234 | Reporting_To?: { name: string; id: string; email?: string }; |
235 | Currency?: string; |
236 | $next_shift?: { name: string; id: string }; |
237 | Modified_Time?: string; |
238 | website?: string; |
239 | status_reason__s?: string; |
240 | email?: string; |
241 | first_name?: string; |
242 | sandboxDeveloper?: false | true; |
243 | alias?: string; |
244 | street?: string; |
245 | Modified_By?: { |
246 | name: string; |
247 | id: string; |
248 | last_name: string; |
249 | first_name: string; |
250 | }; |
251 | Isonline?: false | true; |
252 | locale?: string; |
253 | name_format__s?: |
254 | | "Salutation,First Name,Last Name" |
255 | | "Saluation,Last Name,First Name" |
256 | | "First Name,Last Name,Saluation"; |
257 | personal_account?: false | true; |
258 | default_tab_group?: string; |
259 | theme?: { |
260 | normal_tab: { font_color: "#FFFFFF"; background: "#222222" }; |
261 | selected_tab: { font_color: "#FFFFFF"; background: "#222222" }; |
262 | new_background: string; |
263 | background: "#F3F0EB"; |
264 | screen: "fixed"; |
265 | type: string; |
266 | }; |
267 | ntc_notification_type?: number[]; |
268 | ntc_enabled?: false | true; |
269 | rtl_enabled?: false | true; |
270 | telephony_enabled?: false | true; |
271 | sort_order_preference?: string; |
272 | }; |
273 | type?: "private" | "public"; |
274 | }[]; |
275 | notify_on_completion?: false | true; |
276 | notify?: false | true; |
277 | }, |
278 | ) { |
279 | const url = new URL( |
280 | `https://zohoapis.com/crm/v8/${module_api_name}/${record_id}/actions/share`, |
281 | ); |
282 |
|
283 | const response = await fetch(url, { |
284 | method: "PUT", |
285 | headers: { |
286 | "Content-Type": "application/json", |
287 | Authorization: "Zoho-oauthtoken " + auth.token, |
288 | }, |
289 | body: JSON.stringify(body), |
290 | }); |
291 | if (!response.ok) { |
292 | const text = await response.text(); |
293 | throw new Error(`${response.status} ${text}`); |
294 | } |
295 | return await response.json(); |
296 | } |
297 |
|