//native
type Holded = {
apiKey: string;
};
/**
* Create Contact
* Create a new contact.
*/
export async function main(
auth: Holded,
body: {
CustomId?: string;
name?: string;
code?: string;
email?: string;
mobile?: string;
phone?: string;
type?: string;
isperson?: false | true;
iban?: string;
swift?: string;
sepaRef?: string;
groupId?: string;
taxOperation?: string;
sepaDate?: number;
clientRecord?: number;
supplierRecord?: number;
billAddress?: {
address?: string;
city?: string;
postalCode?: string;
province?: string;
country?: string;
};
numberingSeries?: {
invoice?: string;
receipt?: string;
salesOrder?: string;
purchasesOrder?: string;
proform?: string;
waybill?: string;
};
shippingAddresses?: {
name?: string;
address?: string;
city?: string;
postalCode?: string;
province?: string;
country?: string;
note?: string;
privateNote?: string;
}[];
defaults?: {
expensesAccountRecord?: number;
expensesAccountName?: string;
salesAccountRecord?: number;
salesAccountName?: string;
dueDays?: number;
salesTax?: number;
salesTaxes?: string[];
purchasesTax?: number;
purchasesTaxes?: string[];
accumulateInForm347?: string;
paymentMethod?: string;
discount?: number;
currency?: string;
language?: string;
showTradeNameOnDocs?: false | true;
showCountryOnDocs?: false | true;
};
socialNetworks?: { website?: string };
tags?: string[];
note?: string;
contactPersons?: { name?: string; phone?: string; email?: string }[];
},
) {
const url = new URL(`https://api.holded.com/api/invoicing/v1/contacts`);
const response = await fetch(url, {
method: "POST",
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