//native
type Kustomer = {
apiKey: string;
};
/**
* Update Current User
* Updates the current user.
*/
export async function main(
auth: Kustomer,
body: {
displayName?: string;
avatarUrl?: string;
name?: string;
email?: string;
mobile?: string;
emailSignature?: string;
deleted?: false | true;
password?: string;
currentPassword?: string;
userType?: "user" | "limited" | "hourly";
roleGroups?: string[];
roles?: string[];
},
) {
const url = new URL(`https://api.kustomerapp.com/v1/users/current`);
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