All files / src/services label.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 8/8
100% Lines 5/5

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21      2x   1x       1x       1x       1x      
import api from './api'
import type { Label, CreateLabelRequest } from '../types'
 
export const labelService = {
  getAll(listId: string): Promise<Label[]> {
    return api.get<Label[]>(`/lists/${listId}/labels`).then(r => r.data)
  },
 
  create(listId: string, req: CreateLabelRequest): Promise<Label> {
    return api.post<Label>(`/lists/${listId}/labels`, req).then(r => r.data)
  },
 
  update(listId: string, labelId: string, req: CreateLabelRequest): Promise<Label> {
    return api.put<Label>(`/lists/${listId}/labels/${labelId}`, req).then(r => r.data)
  },
 
  delete(listId: string, labelId: string): Promise<void> {
    return api.delete(`/lists/${listId}/labels/${labelId}`).then(() => undefined)
  },
}