feat(api): patching members
This commit is contained in:
parent
58ae113e77
commit
fd78ed2810
@ -18,6 +18,7 @@ export default class PKAPI {
|
|||||||
|
|
||||||
PATCH_SYSTEM: () => `/systems/@me`,
|
PATCH_SYSTEM: () => `/systems/@me`,
|
||||||
PATCH_GROUP: (gid: string) => `/groups/${gid}`,
|
PATCH_GROUP: (gid: string) => `/groups/${gid}`,
|
||||||
|
PATCH_MEMBER: (mid: string) => `/members/${mid}`,
|
||||||
|
|
||||||
POST_MEMBER: () => `/members`
|
POST_MEMBER: () => `/members`
|
||||||
}
|
}
|
||||||
@ -101,6 +102,20 @@ export default class PKAPI {
|
|||||||
return member;
|
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}) {
|
async postMember(options: {token: any, data: any}) {
|
||||||
if (!options.token) throw new Error("Must pass a token.");
|
if (!options.token) throw new Error("Must pass a token.");
|
||||||
var body = new Member(options.data);
|
var body = new Member(options.data);
|
||||||
|
Loading…
Reference in New Issue
Block a user