//native
type Square = {
token: string;
};
/**
* AddGroupToCustomer
* Adds a group membership to a customer.
The customer is identified by the `customer_id` value
and the customer group is identified by the `group_id` value.
*/
export async function main(
auth: Square,
customer_id: string,
group_id: string,
) {
const url = new URL(
`https://connect.squareup.com/v2/customers/${customer_id}/groups/${group_id}`,
);
const response = await fetch(url, {
method: "PUT",
headers: {
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 235 days ago