//native
type Holded = {
apiKey: string;
};
/**
* Update Contact
* Update a specific contact.
Only the params included in the operation will update the contact.
*/
export async function main(
auth: Holded,
contactId: string,
body: {
name?: string;
code?: string;
tradeName?: string;
email?: string;
mobile?: string;
phone?: string;
type?: string;
isperson?: false | true;
iban?: string;
swift?: string;
sepaRef?: string;
sepaDate?: number;
clientRecord?: number;
supplierRecord?: number;
groupId?: string;
taxOperation?: string;
billAddress?: {
address?: string;
city?: string;
postalCode?: string;
province?: string;
country?: string;
countryCode?: string;
};
shippingAddresses?: {
name?: string;
address?: string;
city?: string;
postalCode?: string;
province?: string;
country?: string;
notes?: string;
privateNote?: string;
}[];
defaults?: {
expensesAccountRecord?: number;
expensesAccountName?: string;
salesAccountRecord?: number;
salesAccountName?: string;
dueDays?: number;
salesTax?: number;
purchasesTax?: number;
accumulateInForm347?: string;
paymentMethod?: string;
discount?: number;
currency?: string;
language?: string;
showTradeNameOnDocs?: false | true;
showCountryOnDocs?: false | true;
};
socialNetworks?: { website?: string };
numberingSeries?: {
invoice?: string;
receipt?: string;
salesOrder?: string;
purchasesOrder?: string;
proform?: string;
waybill?: string;
};
},
) {
const url = new URL(
`https://api.holded.com/api/invoicing/v1/contacts/${contactId}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
key: auth.apiKey,
},
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