Display the list of family users
This commit is contained in:
@ -26,7 +26,7 @@ export class APIClient {
|
||||
*/
|
||||
static async exec(args: {
|
||||
uri: string;
|
||||
method: "GET" | "POST" | "DELETE";
|
||||
method: "GET" | "POST" | "DELETE" | "PATCH";
|
||||
allowFail?: boolean;
|
||||
jsonData?: any;
|
||||
}): Promise<APIResponse> {
|
||||
|
@ -62,6 +62,15 @@ export enum JoinFamilyResult {
|
||||
Success,
|
||||
}
|
||||
|
||||
export interface FamilyUser {
|
||||
user_id: number;
|
||||
family_id: number;
|
||||
time_create: number;
|
||||
is_admin: boolean;
|
||||
user_name: string;
|
||||
user_mail: string;
|
||||
}
|
||||
|
||||
export class FamilyApi {
|
||||
/**
|
||||
* Create a new family
|
||||
@ -142,4 +151,29 @@ export class FamilyApi {
|
||||
uri: `/family/${id}/renew_invitation_code`,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the users of a family
|
||||
*/
|
||||
static async GetUsersList(id: number): Promise<FamilyUser[]> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "GET",
|
||||
uri: `/family/${id}/users`,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a user of the family
|
||||
*/
|
||||
static async UpdateUser(user: FamilyUser): Promise<void> {
|
||||
await APIClient.exec({
|
||||
method: "PATCH",
|
||||
uri: `/family/${user.family_id}/user/${user.user_id}`,
|
||||
jsonData: {
|
||||
is_admin: user.is_admin,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user