//native
type Zoho = {
token: string;
};
/**
* Update a customer
* Update details of an existing customer.
*/
export async function main(
auth: Zoho,
customer_id: string,
X_com_zoho_subscriptions_organizationid: string,
body: {
display_name: string;
salutation?: string;
first_name?: string;
last_name?: string;
email: string;
tags?: { tag_id?: number; tag_option_id?: number }[];
company_name?: string;
phone?: string;
mobile?: string;
billing_address?: {
attention?: string;
street?: string;
city?: string;
state?: string;
zip?: string;
country?: string;
state_code?: string;
fax?: string;
};
shipping_address?: {
attention?: string;
street?: string;
city?: string;
state?: string;
zip?: string;
country?: string;
state_code?: string;
fax?: string;
};
fax?: string;
currency_code?: string;
twitter?: string;
facebook?: string;
skype?: string;
is_portal_enabled?: false | true;
gst_no?: string;
gst_treatment?: string;
place_of_contact?: string;
vat_treatment?: string;
vat_reg_no?: string;
is_taxable?: string;
tax_id?: string;
tax_authority_id: string;
tax_authority_name: string;
tax_exemption_id?: string;
tax_exemption_code?: string;
default_templates?: {
invoice_template_id?: string;
creditnote_template_id?: string;
};
tax_reg_no?: string;
tds_tax_id?: string;
tax_treatment?: string;
tax_regime?: string;
is_tds_registered?: false | true;
custom_fields?: {
index?: number;
value?: string;
label?: string;
data_type?: string;
}[];
},
) {
const url = new URL(
`https://www.zohoapis.com/billing/v1/customers/${customer_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