|
- import {models} from '@tonality/library-common';
- import {FetchClientParams, Method} from '../../utils/api/fetch';
-
- export const create = (body: Partial<models.Ringtone>): FetchClientParams => ({
- method: Method.POST,
- url: ['', 'api', 'ringtones'].join('/'),
- body: JSON.stringify(body),
- headers: {
- 'Content-Type': 'application/json',
- },
- })
-
- export const get = (id: string): FetchClientParams => ({
- method: Method.GET,
- url: ['', 'api', 'ringtones', encodeURIComponent(id)].join('/'),
- })
-
- export const browse = ({ skip, take, }: { skip?: number, take?: number }): FetchClientParams => ({
- method: Method.GET,
- url: ['', 'api', 'ringtones'].join('/'),
- query: {
- skip: typeof skip === 'number' ? skip.toString() : undefined,
- take: typeof take === 'number' ? take.toString() : undefined,
- },
- })
-
- export const update = (id: string) => (body: Partial<models.Ringtone>): FetchClientParams => ({
- method: Method.PATCH,
- url: ['', 'api', 'ringtones', encodeURIComponent(id)].join('/'),
- body: JSON.stringify(body),
- headers: {
- 'Content-Type': 'application/json',
- },
- })
-
- export const softDelete = (id: string): FetchClientParams => ({
- method: Method.POST,
- url: ['', 'api', 'ringtones', encodeURIComponent(id), 'delete'].join('/'),
- })
-
- export const undoDelete = (id: string): FetchClientParams => ({
- method: Method.DELETE,
- url: ['', 'api', 'ringtones', encodeURIComponent(id), 'delete'].join('/'),
- })
-
- export const hardDelete = (id: string): FetchClientParams => ({
- method: Method.DELETE,
- url: ['', 'api', 'ringtones', encodeURIComponent(id)].join('/'),
- })
-
- export const search = (q: string): FetchClientParams => ({
- method: Method.PATCH,
- url: ['', 'api', 'search', 'ringtones'].join('/'),
- query: {
- q,
- },
- })
|