//native
type Zoho = {
token: string;
};
/**
* Create a bank account
* Create a bank account or a credit card account for your organization.
*/
export async function main(
auth: Zoho,
organization_id: string | undefined,
body: {
account_name: string;
account_type: string;
account_number?: string;
account_code?: string;
currency_id?: string;
currency_code?: string;
description?: string;
bank_name?: string;
routing_number?: string;
is_primary_account?: false | true;
is_paypal_account?: false | true;
paypal_type?: string;
paypal_email_address?: string;
},
) {
const url = new URL(`https://www.zohoapis.com/books/v3/bankaccounts`);
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: "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