Ringtone app
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

58 lignes
1.7 KiB

  1. import {models} from '@tonality/library-common';
  2. import {FetchClientParams, Method} from '../../utils/api/fetch';
  3. export const create = (body: Partial<models.Ringtone>): FetchClientParams => ({
  4. method: Method.POST,
  5. url: ['', 'api', 'ringtones'].join('/'),
  6. body: JSON.stringify(body),
  7. headers: {
  8. 'Content-Type': 'application/json',
  9. },
  10. })
  11. export const get = (id: string): FetchClientParams => ({
  12. method: Method.GET,
  13. url: ['', 'api', 'ringtones', encodeURIComponent(id)].join('/'),
  14. })
  15. export const browse = ({ skip, take, }: { skip?: number, take?: number }): FetchClientParams => ({
  16. method: Method.GET,
  17. url: ['', 'api', 'ringtones'].join('/'),
  18. query: {
  19. skip: typeof skip === 'number' ? skip.toString() : undefined,
  20. take: typeof take === 'number' ? take.toString() : undefined,
  21. },
  22. })
  23. export const update = (id: string) => (body: Partial<models.Ringtone>): FetchClientParams => ({
  24. method: Method.PATCH,
  25. url: ['', 'api', 'ringtones', encodeURIComponent(id)].join('/'),
  26. body: JSON.stringify(body),
  27. headers: {
  28. 'Content-Type': 'application/json',
  29. },
  30. })
  31. export const softDelete = (id: string): FetchClientParams => ({
  32. method: Method.POST,
  33. url: ['', 'api', 'ringtones', encodeURIComponent(id), 'delete'].join('/'),
  34. })
  35. export const undoDelete = (id: string): FetchClientParams => ({
  36. method: Method.DELETE,
  37. url: ['', 'api', 'ringtones', encodeURIComponent(id), 'delete'].join('/'),
  38. })
  39. export const hardDelete = (id: string): FetchClientParams => ({
  40. method: Method.DELETE,
  41. url: ['', 'api', 'ringtones', encodeURIComponent(id)].join('/'),
  42. })
  43. export const search = (q: string): FetchClientParams => ({
  44. method: Method.PATCH,
  45. url: ['', 'api', 'search', 'ringtones'].join('/'),
  46. query: {
  47. q,
  48. },
  49. })