//native
type Zoho = {
token: string;
};
/**
* Update map dependency
*
*/
export async function main(
auth: Zoho,
layout_id: string,
dependency_id: string,
_module: string | undefined,
body: {
map_dependency?: {
parent?: { api_name?: string; id?: string };
child?: { api_name?: string; id?: string };
pick_list_values?: {
id?: string;
actual_value?: string;
display_value?: string;
maps?: {
id?: string;
actual_value?: string;
display_value?: string;
_delete?: false | true;
}[];
}[];
internal?: false | true;
active?: false | true;
id?: string;
source?: number;
category?: number;
sub_module?: { api_name?: string; id?: string };
}[];
},
) {
const url = new URL(
`https://zohoapis.com/crm/v8/settings/layouts/${layout_id}/map_dependency/${dependency_id}`,
);
for (const [k, v] of [["module", _module]]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago