diff --git a/src/api/index.ts b/src/api/index.ts index 8588aa73..d69ef763 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -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);