//native
type Square = {
token: string;
};
/**
* BulkCreateCustomers
* Creates multiple [customer profiles]($m/Customer) for a business.
This endpoint takes a map of individual create requests and returns a map of responses.
You must provide at least one of the following values in each create request:
- `given_name`
- `family_name`
- `company_name`
- `email_address`
- `phone_number`
*/
export async function main(auth: Square, body: { customers: {} }) {
const url = new URL(`https://connect.squareup.com/v2/customers/bulk-create`);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: "Bearer " + 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