@@ -24,6 +24,8 @@ import {
24
24
UpdateSectionArgs ,
25
25
UpdateTaskArgs ,
26
26
QuickAddTaskArgs ,
27
+ RenameSharedLabelArgs ,
28
+ RemoveSharedLabelArgs ,
27
29
} from './types/requests'
28
30
import { request , isSuccess } from './restClient'
29
31
import { getTaskFromQuickAddResponse } from './utils/taskConverters'
@@ -39,6 +41,9 @@ import {
39
41
ENDPOINT_REST_PROJECT_COLLABORATORS ,
40
42
ENDPOINT_REST_SECTIONS ,
41
43
ENDPOINT_REST_COMMENTS ,
44
+ ENDPOINT_REST_LABELS_SHARED ,
45
+ ENDPOINT_REST_LABELS_SHARED_RENAME ,
46
+ ENDPOINT_REST_LABELS_SHARED_REMOVE ,
42
47
} from './consts/endpoints'
43
48
import {
44
49
validateComment ,
@@ -313,6 +318,9 @@ export class TodoistApi {
313
318
return isSuccess ( response )
314
319
}
315
320
321
+ /**
322
+ * Fetches a personal label
323
+ */
316
324
async getLabel ( id : number ) : Promise < Label > {
317
325
Int . check ( id )
318
326
const response = await request < Label > (
@@ -325,6 +333,9 @@ export class TodoistApi {
325
333
return validateLabel ( response . data )
326
334
}
327
335
336
+ /**
337
+ * Fetches the personal labels
338
+ */
328
339
async getLabels ( ) : Promise < Label [ ] > {
329
340
const response = await request < Label [ ] > (
330
341
'GET' ,
@@ -336,6 +347,9 @@ export class TodoistApi {
336
347
return validateLabelArray ( response . data )
337
348
}
338
349
350
+ /**
351
+ * Adds a personal label
352
+ */
339
353
async addLabel ( args : AddLabelArgs , requestId ?: string ) : Promise < Label > {
340
354
const response = await request < Label > (
341
355
'POST' ,
@@ -349,6 +363,9 @@ export class TodoistApi {
349
363
return validateLabel ( response . data )
350
364
}
351
365
366
+ /**
367
+ * Updates a personal label
368
+ */
352
369
async updateLabel ( id : number , args : UpdateLabelArgs , requestId ?: string ) : Promise < boolean > {
353
370
Int . check ( id )
354
371
const response = await request (
@@ -362,6 +379,9 @@ export class TodoistApi {
362
379
return isSuccess ( response )
363
380
}
364
381
382
+ /**
383
+ * Deletes a personal label
384
+ */
365
385
async deleteLabel ( id : number , requestId ?: string ) : Promise < boolean > {
366
386
Int . check ( id )
367
387
const response = await request (
@@ -375,6 +395,37 @@ export class TodoistApi {
375
395
return isSuccess ( response )
376
396
}
377
397
398
+ async getSharedLabels ( ) : Promise < string [ ] > {
399
+ const response = await request < string [ ] > (
400
+ 'GET' ,
401
+ API_REST_BASE_URI ,
402
+ ENDPOINT_REST_LABELS_SHARED ,
403
+ this . authToken ,
404
+ )
405
+
406
+ return response . data
407
+ }
408
+
409
+ async renameSharedLabel ( args : RenameSharedLabelArgs ) : Promise < void > {
410
+ await request < void > (
411
+ 'POST' ,
412
+ API_REST_BASE_URI ,
413
+ ENDPOINT_REST_LABELS_SHARED_RENAME ,
414
+ this . authToken ,
415
+ args ,
416
+ )
417
+ }
418
+
419
+ async removeSharedLabel ( args : RemoveSharedLabelArgs ) : Promise < void > {
420
+ await request < void > (
421
+ 'POST' ,
422
+ API_REST_BASE_URI ,
423
+ ENDPOINT_REST_LABELS_SHARED_REMOVE ,
424
+ this . authToken ,
425
+ args ,
426
+ )
427
+ }
428
+
378
429
async getComments ( args : GetTaskCommentsArgs | GetProjectCommentsArgs ) : Promise < Comment [ ] > {
379
430
const response = await request < Comment [ ] > (
380
431
'GET' ,
0 commit comments