1 | |
2 | type Zoho = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Create portal |
7 | * |
8 | */ |
9 | export async function main( |
10 | auth: Zoho, |
11 | body: { |
12 | portals: { |
13 | created_time: string; |
14 | modified_time: string; |
15 | modified_by: { name: string; id: string }; |
16 | created_by: { name: string; id: string }; |
17 | zaid: string; |
18 | name: string; |
19 | active: false | true; |
20 | }[]; |
21 | }, |
22 | ) { |
23 | const url = new URL(`https://zohoapis.com/crm/v8/settings/portals`); |
24 |
|
25 | const response = await fetch(url, { |
26 | method: "POST", |
27 | headers: { |
28 | "Content-Type": "application/json", |
29 | Authorization: "Zoho-oauthtoken " + auth.token, |
30 | }, |
31 | body: JSON.stringify(body), |
32 | }); |
33 | if (!response.ok) { |
34 | const text = await response.text(); |
35 | throw new Error(`${response.status} ${text}`); |
36 | } |
37 | return await response.json(); |
38 | } |
39 |
|