//native
type Zoho = {
token: string;
};
/**
* Get user
*
*/
export async function main(
auth: Zoho,
user: string,
X_ZOHO_SERVICE?: string,
X_ZCSRF_TOKEN?: string,
If_Modified_Since?: string,
) {
const url = new URL(`https://zohoapis.com/crm/v8/users/${user}`);
const response = await fetch(url, {
method: "GET",
headers: {
...(X_ZOHO_SERVICE ? { "X-ZOHO-SERVICE": X_ZOHO_SERVICE } : {}),
...(X_ZCSRF_TOKEN ? { "X-ZCSRF-TOKEN": X_ZCSRF_TOKEN } : {}),
...(If_Modified_Since ? { "If-Modified-Since": If_Modified_Since } : {}),
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