//native
type Zoho = {
token: string;
};
/**
* Update a project
* Update details of a project.
*/
export async function main(
auth: Zoho,
project_id: string,
X_com_zoho_subscriptions_organizationid: string,
body: {
project_name: string;
customer_id: string;
description?: string;
billing_type: string;
rate?: string;
budget_type?: string;
budget_hours?: string;
budget_amount?: 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;
}[];
},
) {
const url = new URL(
`https://www.zohoapis.com/billing/v1/projects/${project_id}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"X-com-zoho-subscriptions-organizationid":
X_com_zoho_subscriptions_organizationid,
"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