//native
type Zoho = {
token: string;
};
/**
* Create a retainerinvoice
* Create a retainer invoice for your customer.
*/
export async function main(
auth: Zoho,
organization_id: string | undefined,
ignore_auto_number_generation: string | undefined,
body: {
customer_id: string;
reference_number?: string;
date?: string;
contact_persons?: string[];
custom_fields?: {
index?: number;
show_on_pdf?: false | true;
value?: string;
label?: string;
}[];
notes?: string;
terms?: string;
location_id?: string;
line_items: { description?: string; item_order?: number; rate?: number }[];
payment_options?: {
payment_gateways?: {
configured?: false | true;
additional_field1?: string;
gateway_name?: string;
}[];
};
template_id?: string;
place_of_supply?: string;
},
) {
const url = new URL(`https://www.zohoapis.com/inventory/v1/retainerinvoices`);
for (const [k, v] of [
["organization_id", organization_id],
["ignore_auto_number_generation", ignore_auto_number_generation],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "POST",
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