//native
type Kustomer = {
apiKey: string;
};
/**
* Bulk batch update companies
* Batch updates multiple companies.
*/
export async function main(
auth: Kustomer,
body: {
id: string;
name?: string;
externalId?: string;
avatarUrl?: string;
emails?: {
type?: "home" | "work" | "other";
email: string;
verified?: false | true;
}[];
phones?: {
type?: "home" | "work" | "other" | "mobile" | "fax";
phone: string;
verified?: false | true;
}[];
socials?: {
type: "twitter" | "facebook" | "instagram" | "linkedin" | "pinterest";
userid?: string;
username: string;
url?: string;
verified?: false | true;
}[];
urls?: { type?: "other" | "website" | "blog"; url: string }[];
domains?: { domain: string }[];
locations?: {
type?: "home" | "work" | "other";
name?: string;
address?: string;
address2?: string;
address3?: string;
latitude?: number;
longitude?: number;
countryCode?: string;
countryName?: string;
regionCode?: string;
regionName?: string;
cityName?: string;
zipCode?: string;
areaCode?: string;
}[];
employeeCount?: number;
tags?: string[];
custom?: {};
defaultLang?: string;
deleted?: false | true;
}[],
) {
const url = new URL(`https://api.kustomerapp.com/v1/companies/bulk`);
const response = await fetch(url, {
method: "PUT",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + 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