feat(api): patching members

This commit is contained in:
Spectralitree 2021-12-30 10:18:08 +01:00
parent 58ae113e77
commit fd78ed2810

View File

@ -18,6 +18,7 @@ export default class PKAPI {
PATCH_SYSTEM: () => `/systems/@me`,
PATCH_GROUP: (gid: string) => `/groups/${gid}`,
PATCH_MEMBER: (mid: string) => `/members/${mid}`,
POST_MEMBER: () => `/members`
}
@ -101,6 +102,20 @@ export default class PKAPI {
return member;
}
async patchMember(options: {token: string, id: any, data: any}) {
var body = new Member(options.data);
var member: Member;
var res: AxiosResponse;
try {
res = await this.handle(this.ROUTES.PATCH_MEMBER(options.id), 'PATCH', {token: options.token, body: body});
if (res.status === 200) member = new Member(res.data);
else this.handleErrors(res);
} catch (error) {
throw new Error(error.message);
}
return member;
}
async postMember(options: {token: any, data: any}) {
if (!options.token) throw new Error("Must pass a token.");
var body = new Member(options.data);