//native
type Zoho = {
token: string;
};
/**
* Get matching transactions
* Provide criteria to search for matching uncategorised transactions. The list of transactions can also include invoices/bills/credit-notes which will not be matched directly. Instead, a new (payment/refund) transaction is recorded and matched.
*/
export async function main(
auth: Zoho,
transaction_id: string,
organization_id: string | undefined,
transaction_type: string | undefined,
date_after: string | undefined,
date_before: string | undefined,
amount_start: string | undefined,
amount_end: string | undefined,
contact: string | undefined,
reference_number: string | undefined,
show_all_transactions: string | undefined,
) {
const url = new URL(
`https://www.zohoapis.com/books/v3/banktransactions/uncategorized/${transaction_id}/match`,
);
for (const [k, v] of [
["organization_id", organization_id],
["transaction_type", transaction_type],
["date_after", date_after],
["date_before", date_before],
["amount_start", amount_start],
["amount_end", amount_end],
["contact", contact],
["reference_number", reference_number],
["show_all_transactions", show_all_transactions],
]) {
if (v !== undefined && v !== "" && k !== undefined) {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
Authorization: "Zoho-oauthtoken " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago