domo 0.3.2

The Domo Rust SDK wrapping our APIs. Also includes a CLI application.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
use chrono::{DateTime, Utc};
use serde::{Deserialize, Serialize};
use std::{error::Error, path::PathBuf};

/// “Projects and Tasks” is a project management tool that helps you take real action with simple planning, assigning, and task-tracking features. You can create projects with various tasks and assignments. Those tasks exist within swim lanes or lists, and can be moved from list to list to show progress through a particular workflow. You can use default lists or create new custom lists. You can also add attachments to individual tasks to reference relevant materials and other artifacts.
/// Note: You will need to ensure that your client application has access to the Workflow scope in order to access the Projects and Tasks endpoints.
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct Project {
    /// The ID of the project
    pub id: Option<String>,

    /// The name of the project
    pub name: Option<String>,

    /// Description of the project
    pub description: Option<String>,

    /// The ID of the user who created the project
    pub created_by: Option<u64>,

    /// Date the project was created
    pub created_date: Option<DateTime<Utc>>,

    /// Due date of the project
    pub due_date: Option<DateTime<Utc>>,

    /// whether or not the project is a public project
    pub public: Option<bool>,

    /// The ID's of the members of the project
    pub members: Option<Vec<u64>>,
}

impl Project {
    pub fn new() -> Self {
        Project {
            id: None,
            name: None,
            description: None,
            created_by: None,
            created_date: None,
            due_date: None,
            public: None,
            members: None,
        }
    }

    pub fn template() -> Self {
        Project {
            id: Some(String::from("0")),
            name: Some(String::from("Project Name")),
            description: Some(String::from("Project Description")),
            created_by: Some(12345),
            created_date: Some(Utc::now()),
            due_date: Some(Utc::now()),
            public: Some(true),
            members: Some(vec![0, 1, 2, 3]),
        }
    }
}

/// The list object
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct List {
    /// The ID of the List
    pub id: Option<u64>,

    /// The name of the List
    pub name: Option<String>,

    /// The type of List (i.e. TODO, WORKING_ON, COMPLETED)
    #[serde(rename = "type")]
    pub list_type: Option<String>,

    /// The ordered index of the list within the project.
    pub index: u32,
}

impl List {
    pub fn new() -> Self {
        List {
            id: None,
            name: None,
            list_type: None,
            index: 0,
        }
    }
    pub fn template() -> Self {
        List {
            id: Some(0),
            name: Some(String::from("List Name")),
            list_type: Some(String::from("")),
            index: 0,
        }
    }
}

/// The task object
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct Task {
    /// The ID of the task
    pub id: Option<u64>,

    /// The ID of the project that the task belongs to
    pub project_id: Option<u64>,

    /// The ID of the list within a project that the task belongs to
    pub project_list_id: Option<u64>,

    /// The name of the task
    pub task_name: Option<String>,

    /// An optional description of the task
    pub description: Option<String>,

    /// The date the task was created
    pub created_date: Option<DateTime<Utc>>,

    /// The date the task is expected to be completed
    pub due_date: Option<DateTime<Utc>>,

    /// The prioritized order of the task in a list
    pub priority: Option<u32>,

    /// The ID of the Domo user that created the task
    pub created_by: Option<u64>,

    /// The ID of the Domo user that owns the task
    pub owned_by: Option<u64>,

    /// An array of user IDs that are assigned as contributors to the task
    pub contributors: Option<Vec<u64>>,

    /// The number of attachments that task has
    pub attachment_count: Option<u32>,

    /// An array of tags that have been assigned to the task
    pub tags: Option<Vec<String>>,

    /// whether or not the task has been archived
    pub archived: bool,
}

impl Task {
    pub fn new() -> Self {
        Task {
            id: None,
            project_id: None,
            project_list_id: None,
            task_name: None,
            description: None,
            created_date: None,
            due_date: None,
            priority: None,
            created_by: None,
            owned_by: None,
            contributors: None,
            attachment_count: None,
            tags: None,
            archived: false,
        }
    }
    pub fn template() -> Self {
        Task {
            id: Some(0),
            project_id: Some(0),
            project_list_id: Some(0),
            task_name: Some(String::from("Task Name")),
            description: Some(String::from("Task Description")),
            created_date: Some(Utc::now()),
            due_date: Some(Utc::now()),
            priority: Some(0),
            created_by: Some(27),
            owned_by: Some(27),
            contributors: Some(vec![0, 1, 2, 3]),
            attachment_count: Some(0),
            tags: Some(vec![
                String::from("A"),
                String::from("B"),
                String::from("C"),
            ]),
            archived: false,
        }
    }
}

/// The attachment object
#[derive(Serialize, Deserialize, Debug, Default)]
#[serde(default, rename_all = "camelCase")]
pub struct Attachment {
    /// The ID of the attachment
    pub id: Option<u32>,

    /// The ID of the task that the attachment belongs to
    pub task_id: Option<u32>,

    /// The date the attachment was created
    pub created_date: Option<DateTime<Utc>>,

    /// The filename of the attachment
    pub file_name: Option<String>,

    /// The mime type of the attachment
    pub mime_type: Option<String>,
}

#[derive(Serialize)]
struct QueryParams {
    pub limit: Option<u32>,
    pub offset: Option<u32>,
}

/// Workflow API methods
/// Uses the form method_object
impl super::Client {
    /// Retrieves a list of all projects that the client scope has access to.
    pub async fn get_projects(
        &self,
        limit: Option<u32>,
        offset: Option<u32>,
    ) -> Result<Vec<Project>, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let q = QueryParams { limit, offset };
        let mut response = surf::get(&format!("{}{}", self.host, "/v1/projects/"))
            .query(&q)?
            .header("Authorization", at)
            .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Create a new project in your Domo instance
    ///
    /// Required attributes:
    /// * name
    /// * members
    /// * public
    pub async fn post_project(
        &self,
        project: Project,
    ) -> Result<Project, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::post(&format!("{}{}", self.host, "/v1/projects"))
            .header("Authorization", at)
            .body(surf::Body::from_json(&project)?)
            .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Retrieves the details of an individual existing project given a project id.
    /// Use the special project ID me to return your personal project.
    pub async fn get_project(
        &self,
        id: &str,
    ) -> Result<Project, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::get(&format!("{}{}{}", self.host, "/v1/projects/", id))
            .header("Authorization", at)
            .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Updates attributes of an existing project in your Domo instance. The following properties are read-only and cannot be updated with this request:
    /// * id
    /// * members
    /// * createdBy
    /// * createdDate
    ///
    /// Required attributes:
    /// * id
    pub async fn put_project(
        &self,
        id: &str,
        project: Project,
    ) -> Result<Project, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::put(&format!("{}{}{}", self.host, "/v1/projects/", id))
            .header("Authorization", at)
            .body(surf::Body::from_json(&project)?)
            .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Permanently deletes a project from your Domo instance.
    /// This is destructive and cannot be reversed.
    pub async fn delete_project(
        &self,
        id: &str,
    ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::delete(&format!("{}{}{}", self.host, "/v1/projects/", id))
            .header("Authorization", at)
            .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Retrieves a list of ids of the users that are members of the given project id.
    pub async fn get_project_members(
        &self,
        id: &str,
    ) -> Result<Vec<u64>, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::get(&format!(
            "{}{}{}{}",
            self.host, "/v1/projects/", id, "/members"
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Update the members of a given project id.
    pub async fn put_project_members(
        &self,
        id: &str,
        members: Vec<u64>,
    ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::put(&format!(
            "{}{}{}{}",
            self.host, "/v1/projects/", id, "/members"
        ))
        .header("Authorization", at)
        .body(surf::Body::from_json(&members)?)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Retrieves all lists available within a given project id.
    pub async fn get_project_lists(
        &self,
        id: &str,
    ) -> Result<Vec<List>, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::get(&format!(
            "{}{}{}{}",
            self.host, "/v1/projects/", id, "/lists"
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Creates a new list within the given project id.
    ///
    /// Required attributes:
    /// * project_id
    /// * name
    /// * type
    ///
    /// Index: Setting this property will re-order other lists in the project to maintain sequential order. Leaving this property blank will default the index to 1 and shift the index of all other lists.
    pub async fn post_project_list(
        &self,
        project_id: &str,
        list: List,
    ) -> Result<List, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::post(&format!(
            "{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists"
        ))
        .header("Authorization", at)
        .body(surf::Body::from_json(&list)?)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Retrieves the details of an individual list given a project id and a list id.
    pub async fn get_project_list(
        &self,
        project_id: &str,
        list_id: &str,
    ) -> Result<List, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::get(&format!(
            "{}{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists/", list_id
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Update the details of a list given an existing project id and list id.
    ///
    /// Required attributes:
    /// * project_id
    /// * list_id
    /// * name
    /// * type
    /// * index
    pub async fn put_project_list(
        &self,
        project_id: &str,
        list_id: &str,
        list: List,
    ) -> Result<List, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::put(&format!(
            "{}{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists/", list_id
        ))
        .header("Authorization", at)
        .body(surf::Body::from_json(&list)?)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Permanently deletes a list from your Domo instance.
    /// This is destructive and cannot be reversed.
    pub async fn delete_project_list(
        &self,
        project_id: &str,
        list_id: &str,
    ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::delete(&format!(
            "{}{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists/", list_id
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Retrieves all tasks from a given project id.
    ///
    /// limit: The maximum amount of results to return (defaults to 10 with a maximum of 50)
    /// offset: The number of records to offset from the beginning of the result list (defaults to 0)
    pub async fn get_project_tasks(
        &self,
        id: &str,
        limit: Option<u32>,
        offset: Option<u32>,
    ) -> Result<Vec<Task>, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let q = QueryParams { limit, offset };
        let mut response = surf::get(&format!(
            "{}{}{}{}",
            self.host, "/v1/projects/", id, "/tasks"
        ))
        .query(&q)?
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Retrieves all tasks from a given project id and list id
    ///
    /// limit: The maximum amount of results to return (defaults to 10 with a maximum of 50)
    /// offset: The number of records to offset from the beginning of the result list (defaults to 0)
    pub async fn get_project_list_tasks(
        &self,
        project_id: &str,
        list_id: &str,
        limit: Option<u32>,
        offset: Option<u32>,
    ) -> Result<Vec<Task>, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let q = QueryParams { limit, offset };
        let mut response = surf::get(&format!(
            "{}{}{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists/", list_id, "/tasks"
        ))
        .query(&q)?
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Add a task to a project list.
    ///
    /// Required attributes:
    /// * projectId
    /// * projectListId
    /// * taskName
    /// * ownedBy
    /// * contributers
    pub async fn post_project_list_task(
        &self,
        project_id: &str,
        list_id: &str,
        task: Task,
    ) -> Result<Task, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::post(&format!(
            "{}{}{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists/", list_id, "/tasks"
        ))
        .header("Authorization", at)
        .body(surf::Body::from_json(&task)?)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Retrieves an individual task from a given project id and list id.
    pub async fn get_project_list_task(
        &self,
        project_id: &str,
        list_id: &str,
        task_id: &str,
    ) -> Result<Task, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::get(&format!(
            "{}{}{}{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists/", list_id, "/tasks/", task_id
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Update the details of a task given an existing project id, list id, and task id.
    ///
    /// Required Attributes:
    /// * project_id
    /// * list_id
    /// * task_id
    /// * taskName
    /// * priority
    /// * ownedBy
    /// * contributors
    pub async fn put_project_list_task(
        &self,
        project_id: &str,
        list_id: &str,
        task_id: &str,
        task: Task,
    ) -> Result<Task, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::put(&format!(
            "{}{}{}{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists/", list_id, "/tasks/", task_id
        ))
        .header("Authorization", at)
        .body(surf::Body::from_json(&task)?)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// TODO May just need to set the archived flag
    pub async fn delete_project_list_task(
        &self,
        project_id: &str,
        list_id: &str,
        task_id: &str,
    ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::delete(&format!(
            "{}{}{}{}{}{}{}",
            self.host, "/v1/projects/", project_id, "/lists/", list_id, "/tasks/", task_id
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Retrieve details about all of the attachments belonging to a particular task.
    pub async fn get_project_list_task_attachments(
        &self,
        project_id: &str,
        list_id: &str,
        task_id: &str,
    ) -> Result<Vec<Attachment>, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::get(&format!(
            "{}{}{}{}{}{}{}{}",
            self.host,
            "/v1/projects/",
            project_id,
            "/lists/",
            list_id,
            "/tasks/",
            task_id,
            "/attachments"
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Downloads an individual attachment given an attachment id.
    pub async fn get_project_list_task_attachment(
        &self,
        project_id: &str,
        list_id: &str,
        task_id: &str,
        attachment_id: &str,
    ) -> Result<Vec<u8>, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::get(&format!(
            "{}{}{}{}{}{}{}{}{}",
            self.host,
            "/v1/projects/",
            project_id,
            "/lists/",
            list_id,
            "/tasks/",
            task_id,
            "/attachments/",
            attachment_id
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_bytes().await?)
    }

    /// Add a multipart form file to a task item as an attachment.
    pub async fn post_project_list_task_attachment(
        &self,
        project_id: &str,
        list_id: &str,
        task_id: &str,
        _path: PathBuf,
    ) -> Result<Attachment, Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        //TODO Is there a way to upload a file using surf?
        //let form = reqwest::blocking::multipart::Form::new().file("file", path).unwrap();
        let mut response = surf::post(&format!(
            "{}{}{}{}{}{}{}{}",
            self.host,
            "/v1/projects/",
            project_id,
            "/lists/",
            list_id,
            "/tasks/",
            task_id,
            "/attachments"
        ))
        .header("Authorization", at)
        //TODO Need to do the equiv in surf
        //.multipart(form)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }

    /// Permanently deletes an attachment from your task.
    /// This is destructive and cannot be reversed.
    pub async fn delete_project_list_task_attachment(
        &self,
        project_id: &str,
        list_id: &str,
        task_id: &str,
        attachment_id: &str,
    ) -> Result<(), Box<dyn Error + Send + Sync + 'static>> {
        let at = self.get_access_token("workflow").await?;
        let mut response = surf::delete(&format!(
            "{}{}{}{}{}{}{}{}{}",
            self.host,
            "/v1/projects/",
            project_id,
            "/lists/",
            list_id,
            "/tasks/",
            task_id,
            "/attachments/",
            attachment_id
        ))
        .header("Authorization", at)
        .await?;
        if !response.status().is_success() {
            let e: Box<super::PubAPIError> = response.body_json().await?;
            return Err(e);
        }
        Ok(response.body_json().await?)
    }
}