asana/model/
task_request.rs

1use serde::{Serialize, Deserialize};
2use super::TaskBase;
3impl TaskRequest {
4    pub fn new(name: impl Into<String>) -> Self {
5        Self {
6            task_base: TaskBase {
7                name: Some(name.into()),
8                ..TaskBase::default()
9            },
10            ..Self::default()
11        }
12    }
13}
14#[derive(Debug, Clone, Serialize, Deserialize, Default)]
15pub struct TaskRequest {
16    #[serde(flatten)]
17    pub task_base: TaskBase,
18    ///Gid of a user.
19    #[serde(skip_serializing_if = "Option::is_none")]
20    pub assignee: Option<String>,
21    /**The *assignee section* is a subdivision of a project that groups tasks together in the assignee's "My Tasks" list. It can either be a header above a list of tasks in a list view or a column in a board view of "My Tasks."
22The `assignee_section` property will be returned in the response only if the request was sent by the user who is the assignee of the task. Note that you can only write to `assignee_section` with the gid of an existing section visible in the user's "My Tasks" list.*/
23    #[serde(skip_serializing_if = "Option::is_none")]
24    pub assignee_section: Option<String>,
25    ///An object where each key is the GID of a custom field and its corresponding value is either an enum GID, string, number, object, or array (depending on the custom field type). See the [custom fields guide](/docs/custom-fields-guide) for details on creating and updating custom field values.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub custom_fields: Option<serde_json::Value>,
28    ///*Create-Only* An array of strings identifying users. These can either be the string "me", an email, or the gid of a user. In order to change followers on an existing task use `addFollowers` and `removeFollowers`.
29    #[serde(skip_serializing_if = "Option::is_none")]
30    pub followers: Option<Vec<String>>,
31    ///Gid of a task.
32    #[serde(skip_serializing_if = "Option::is_none")]
33    pub parent: Option<String>,
34    ///*Create-Only* Array of project gids. In order to change projects on an existing task use `addProject` and `removeProject`.
35    #[serde(skip_serializing_if = "Option::is_none")]
36    pub projects: Option<Vec<String>>,
37    ///*Create-Only* Array of tag gids. In order to change tags on an existing task use `addTag` and `removeTag`.
38    #[serde(skip_serializing_if = "Option::is_none")]
39    pub tags: Option<Vec<String>>,
40    ///Gid of a workspace.
41    #[serde(skip_serializing_if = "Option::is_none")]
42    pub workspace: Option<String>,
43}
44impl std::fmt::Display for TaskRequest {
45    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
46        write!(f, "{}", serde_json::to_string(self).unwrap())
47    }
48}
49impl std::ops::Deref for TaskRequest {
50    type Target = TaskBase;
51    fn deref(&self) -> &Self::Target {
52        &self.task_base
53    }
54}
55impl std::ops::DerefMut for TaskRequest {
56    fn deref_mut(&mut self) -> &mut Self::Target {
57        &mut self.task_base
58    }
59}