//native
type Zoho = {
token: string;
};
/**
* Update project
* Update details of a project.
*/
export async function main(
auth: Zoho,
project_id: string,
organization_id: string | undefined,
body: {
project_name: string;
customer_id: string;
currency_id?: string;
description?: string;
billing_type: string;
rate?: string;
budget_type?: string;
budget_hours?: string;
budget_amount?: string;
cost_budget_amount?: number;
user_id: string;
tasks?: {
task_name: string;
description?: string;
rate?: string;
budget_hours?: string;
}[];
users?: {
user_id?: string;
is_current_user?: false | true;
user_name?: string;
email?: string;
user_role?: string;
status?: string;
rate?: string;
budget_hours?: string;
total_hours?: string;
billed_hours?: string;
un_billed_hours?: string;
cost_rate?: number;
}[];
},
) {
const url = new URL(
`https://www.zohoapis.com/books/v3/projects/${project_id}`,
);
for (const [k, v] of [["organization_id", organization_id]]) {
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