//native
type Square = {
token: string;
};
/**
* SearchTeamMembers
* Returns a paginated list of `TeamMember` objects for a business.
The list can be filtered by location IDs, `ACTIVE` or `INACTIVE` status, or whether
the team member is the Square account owner.
*/
export async function main(
auth: Square,
body: {
query?: {
filter?: {
location_ids?: string[];
status?: "ACTIVE" | "INACTIVE";
is_owner?: false | true;
};
};
limit?: number;
cursor?: string;
},
) {
const url = new URL(`https://connect.squareup.com/v2/team-members/search`);
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