twofaccountService.js 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import { httpClientFactory } from '@/services/httpClientFactory'
  2. const apiClient = httpClientFactory('api')
  3. export default {
  4. getAll(withOtp = false, config = {}) {
  5. return apiClient.get('/twofaccounts' + (withOtp ? '?withOtp=1' : ''), { ...config })
  6. },
  7. getByIds(ids, withOtp = false, config = {}) {
  8. return apiClient.get('/twofaccounts?ids=' + ids + (withOtp ? '&withOtp=1' : ''), { ...config })
  9. },
  10. get(id, config = {}) {
  11. return apiClient.get('/twofaccounts/' + id, { ...config })
  12. },
  13. preview(uri, config = {}) {
  14. return apiClient.post('/twofaccounts/preview', { uri: uri }, { ...config })
  15. },
  16. storeFromUri(uri, config = {}) {
  17. return apiClient.post('/twofaccounts', { uri: uri }, { ...config })
  18. },
  19. getLogo(service, config = {}) {
  20. return apiClient.post('/icons/default', { service: service }, { ...config })
  21. },
  22. deleteIcon(icon, config = {}) {
  23. return apiClient.delete('/icons/' + icon, { ...config })
  24. },
  25. getOtpById(id, config = {}) {
  26. return apiClient.get('/twofaccounts/' + id + '/otp', { ...config })
  27. },
  28. getOtpByUri(uri, config = {}) {
  29. return apiClient.post('/twofaccounts/otp', { uri: uri }, { ...config })
  30. },
  31. getOtpByParams(params, config = {}) {
  32. return apiClient.post('/twofaccounts/otp', params, { ...config })
  33. },
  34. withdraw(ids, config = {}) {
  35. return apiClient.patch('/twofaccounts/withdraw?ids=' + ids.join(), { ...config })
  36. },
  37. saveOrder(orderedIds, config = {}) {
  38. return apiClient.post('/twofaccounts/reorder', { orderedIds: orderedIds }, { ...config })
  39. },
  40. batchDelete(ids, config = {}) {
  41. return apiClient.delete('/twofaccounts?ids=' + ids, { ...config })
  42. },
  43. export(ids, otpauthFormat, config = {}) {
  44. return apiClient.get('/twofaccounts/export?ids=' + ids + (otpauthFormat ? '&otpauth=1' : ''), { ...config })
  45. },
  46. getQrcode(id, config = {}) {
  47. return apiClient.get('/twofaccounts/' + id + '/qrcode', { ...config })
  48. },
  49. migrate(payload, config = {}) {
  50. return apiClient.post('/twofaccounts/migration', { payload: payload, withSecret: true }, { ...config })
  51. },
  52. count(config = {}) {
  53. return apiClient.get('/twofaccounts/count', { ...config })
  54. },
  55. }