//native
type Zoho = {
token: string;
};
/**
* Invite users
*
*/
export async function main(
auth: Zoho,
_module: string,
record: string,
user_type_id: string | undefined,
_type: "reinvite" | "invite" | undefined,
language:
| "it_IT"
| "ru_RU"
| "pl_PL"
| "tr_TR"
| "hi_IN"
| "pt_BR"
| "th_TH"
| "fr_FR"
| "ja_JP"
| "in_ID"
| "cs_CZ"
| "de_DE"
| "hu_HU"
| "zh_TW"
| "es_ES"
| "nl_NL"
| "sv_SE"
| "da_DK"
| "bg_BG"
| "vi_VN"
| "iw_IL"
| "hr_HR"
| "en_GB"
| "ko_KR"
| "en_US"
| "zh_CN"
| "ar_EG"
| "pt_PT"
| undefined,
) {
const url = new URL(
`https://zohoapis.com/crm/v8/${_module}/${record}/actions/portal_invite`,
);
for (const [k, v] of [
["user_type_id", user_type_id],
["type", _type],
["language", language],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago