User.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. import { User } from 'src/models/User.js'
  2. import { appApi } from 'src/boot/axios.js'
  3. import APIRepository from '../classes/APIRepository.js'
  4. export default class UserAPI extends APIRepository {
  5. constructor() {
  6. super('user', appApi, '/user', User)
  7. this.APIAdresses = {
  8. base: '/uma/users',
  9. verify: '/uma/users/verify',
  10. current: '/uma/users/current',
  11. byId: (id) => '/uma/users/' + id,
  12. changeRole: (id) => '/uma/users/' + id + '/change_role'
  13. }
  14. this.CacheList = {
  15. base: this.name + this.APIAdresses.base,
  16. current: this.name + this.APIAdresses.current,
  17. verify: this.name + this.APIAdresses.verify,
  18. byId: (id) => this.name + this.APIAdresses.byId(id),
  19. changeRole: (id) => this.name + this.APIAdresses.changeRole(id)
  20. }
  21. }
  22. updateCurrent(data = {}) {
  23. return this.sendRequest({
  24. apiMethod: 'put',
  25. api: this.api,
  26. request: this.APIAdresses.current,
  27. data: this.getNormalizedSendData({
  28. firstname: '', // String
  29. lastname: '', // String
  30. gender: 'MALE', // String
  31. marital_status: 'UNKNOWN', // String
  32. birthdate: null, // String
  33. national_code: '', // String
  34. has_seminary_education: false, // Boolean
  35. last_academic_degree: 'UNDER_DIPLOMA', // String
  36. last_academic_degree_field: null, // String
  37. last_academy_name: null, // String
  38. educational_status: null, // String
  39. phone_number: null, // String
  40. on_social_network_mobile_number: null, // String
  41. on_call_mobile_number: null, // String
  42. email: '', // String
  43. is_abroad_birth_address: 'False', // String
  44. is_abroad_living_address: 'False', // String
  45. birth_country: 'ایران', // String
  46. living_country: 'ایران', // String
  47. birth_province: null, // String
  48. living_province: null, // String
  49. birth_city: null, // String
  50. living_city: null, // String
  51. living_address: null, // String
  52. living_postal_code: null, // String
  53. living_address_additional_info: null // String
  54. }, data),
  55. resolveCallback: (response) => {
  56. return new User(response.data)
  57. },
  58. rejectCallback: (error) => {
  59. return error
  60. }
  61. })
  62. }
  63. updateByAdmin(data = {}) {
  64. return this.sendRequest({
  65. apiMethod: 'put',
  66. api: this.api,
  67. request: this.APIAdresses.byId(data.id),
  68. data: this.getNormalizedSendData({
  69. firstname: '', // String
  70. lastname: '', // String
  71. gender: 'MALE', // String
  72. marital_status: 'UNKNOWN', // String
  73. birthdate: null, // String
  74. national_code: '', // String
  75. has_seminary_education: false, // Boolean
  76. last_academic_degree: 'UNDER_DIPLOMA', // String
  77. last_academic_degree_field: null, // String
  78. last_academy_name: null, // String
  79. educational_status: null, // String
  80. phone_number: null, // String
  81. on_social_network_mobile_number: null, // String
  82. on_call_mobile_number: null, // String
  83. email: '', // String
  84. is_abroad_birth_address: 'False', // String
  85. is_abroad_living_address: 'False', // String
  86. birth_country: 'ایران', // String
  87. living_country: 'ایران', // String
  88. birth_province: null, // String
  89. living_province: null, // String
  90. birth_city: null, // String
  91. living_city: null, // String
  92. living_address: null, // String
  93. living_postal_code: null, // String
  94. living_address_additional_info: null // String
  95. }, data),
  96. resolveCallback: (response) => {
  97. return new User(response.data)
  98. },
  99. rejectCallback: (error) => {
  100. return error
  101. }
  102. })
  103. }
  104. }