User.ts 802 B

12345678910111213141516171819202122232425262728293031323334353637
  1. import {
  2. CreateUserParams,
  3. DeleteUserParams,
  4. UpdateUserParams,
  5. } from 'insight_src/pages/user/Types';
  6. import BaseModel from './BaseModel';
  7. export class UserHttp extends BaseModel {
  8. private names!: string[];
  9. constructor(props: {}) {
  10. super(props);
  11. Object.assign(this, props);
  12. }
  13. static USER_URL = `/users`;
  14. static getUsers() {
  15. return super.search({ path: this.USER_URL, params: {} });
  16. }
  17. static createUser(data: CreateUserParams) {
  18. return super.create({ path: this.USER_URL, data });
  19. }
  20. static updateUser(data: UpdateUserParams) {
  21. return super.update({ path: this.USER_URL, data });
  22. }
  23. static deleteUser(data: DeleteUserParams) {
  24. return super.delete({ path: `${this.USER_URL}/${data.username}` });
  25. }
  26. get _names() {
  27. return this.names;
  28. }
  29. }