asana/models/
custom_field_request.rs

1/*
2 * Asana
3 *
4 * This is the interface for interacting with the [Asana Platform](https://developers.asana.com). Our API reference is generated from our [OpenAPI spec] (https://raw.githubusercontent.com/Asana/developer-docs/master/defs/asana_oas.yaml).
5 *
6 * The version of the OpenAPI document: 1.0
7 *
8 * Generated by: https://openapi-generator.tech
9 */
10
11#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
12pub struct CustomFieldRequest {
13    /// Globally unique identifier of the resource, as a string.
14    #[serde(rename = "gid", skip_serializing_if = "Option::is_none")]
15    pub gid: Option<String>,
16    /// The base type of this resource.
17    #[serde(rename = "resource_type", skip_serializing_if = "Option::is_none")]
18    pub resource_type: Option<String>,
19    /// The name of the custom field.
20    #[serde(rename = "name", skip_serializing_if = "Option::is_none")]
21    pub name: Option<String>,
22    /// The type of the custom field. Must be one of the given values.
23    #[serde(
24        rename = "resource_subtype",
25        skip_serializing_if = "Option::is_none"
26    )]
27    pub resource_subtype: Option<ResourceSubtype>,
28    /// *Deprecated: new integrations should prefer the resource_subtype field.* The type of the custom field. Must be one of the given values.
29    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
30    pub _type: Option<Type>,
31    /// *Conditional*. Only relevant for custom fields of type `enum`. This array specifies the possible values which an `enum` custom field can adopt. To modify the enum options, refer to [working with enum options](/docs/create-an-enum-option).
32    #[serde(rename = "enum_options", skip_serializing_if = "Option::is_none")]
33    pub enum_options: Option<Vec<crate::models::EnumOption>>,
34    /// *Conditional*. Determines if the custom field is enabled or not.
35    #[serde(rename = "enabled", skip_serializing_if = "Option::is_none")]
36    pub enabled: Option<bool>,
37    /// *Conditional*. This number is the value of a number custom field.
38    #[serde(rename = "number_value", skip_serializing_if = "Option::is_none")]
39    pub number_value: Option<f32>,
40    /// *Conditional*. This string is the value of a text custom field.
41    #[serde(rename = "text_value", skip_serializing_if = "Option::is_none")]
42    pub text_value: Option<String>,
43    /// A string representation for the value of the custom field. Integrations that don't require the underlying type should use this field to read values. Using this field will future-proof an app against new custom field types.
44    #[serde(rename = "display_value", skip_serializing_if = "Option::is_none")]
45    pub display_value: Option<String>,
46    /// [Opt In](/docs/input-output-options). The description of the custom field.
47    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
48    pub description: Option<String>,
49    /// Only relevant for custom fields of type ‘Number’. This field dictates the number of places after the decimal to round to, i.e. 0 is integer values, 1 rounds to the nearest tenth, and so on. Must be between 0 and 6, inclusive. For percentage format, this may be unintuitive, as a value of 0.25 has a precision of 0, while a value of 0.251 has a precision of 1. This is due to 0.25 being displayed as 25%. The identifier format will always have a precision of 0.
50    #[serde(rename = "precision", skip_serializing_if = "Option::is_none")]
51    pub precision: Option<i32>,
52    /// The format of this custom field.
53    #[serde(rename = "format", skip_serializing_if = "Option::is_none")]
54    pub format: Option<Format>,
55    /// ISO 4217 currency code to format this custom field. This will be null if the `format` is not `currency`.
56    #[serde(rename = "currency_code", skip_serializing_if = "Option::is_none")]
57    pub currency_code: Option<String>,
58    /// This is the string that appears next to the custom field value. This will be null if the `format` is not `custom`.
59    #[serde(rename = "custom_label", skip_serializing_if = "Option::is_none")]
60    pub custom_label: Option<String>,
61    /// Only relevant for custom fields with `custom` format. This depicts where to place the custom label. This will be null if the `format` is not `custom`.
62    #[serde(
63        rename = "custom_label_position",
64        skip_serializing_if = "Option::is_none"
65    )]
66    pub custom_label_position: Option<CustomLabelPosition>,
67    /// This flag describes whether this custom field is available to every container in the workspace. Before project-specific custom fields, this field was always true.
68    #[serde(
69        rename = "is_global_to_workspace",
70        skip_serializing_if = "Option::is_none"
71    )]
72    pub is_global_to_workspace: Option<bool>,
73    /// *Conditional*. This flag describes whether a follower of a task with this field should receive inbox notifications from changes to this field.
74    #[serde(
75        rename = "has_notifications_enabled",
76        skip_serializing_if = "Option::is_none"
77    )]
78    pub has_notifications_enabled: Option<bool>,
79    /// *Create-Only* The workspace to create a custom field in.
80    #[serde(rename = "workspace")]
81    pub workspace: String,
82}
83
84impl CustomFieldRequest {
85    pub fn new(workspace: String) -> CustomFieldRequest {
86        CustomFieldRequest {
87            gid: None,
88            resource_type: None,
89            name: None,
90            resource_subtype: None,
91            _type: None,
92            enum_options: None,
93            enabled: None,
94            number_value: None,
95            text_value: None,
96            display_value: None,
97            description: None,
98            precision: None,
99            format: None,
100            currency_code: None,
101            custom_label: None,
102            custom_label_position: None,
103            is_global_to_workspace: None,
104            has_notifications_enabled: None,
105            workspace,
106        }
107    }
108}
109
110/// The type of the custom field. Must be one of the given values.
111#[derive(
112    Clone,
113    Copy,
114    Debug,
115    Eq,
116    PartialEq,
117    Ord,
118    PartialOrd,
119    Hash,
120    Serialize,
121    Deserialize
122)]
123pub enum ResourceSubtype {
124    #[serde(rename = "text")]
125    Text,
126    #[serde(rename = "enum")]
127    _Enum,
128    #[serde(rename = "number")]
129    Number,
130}
131/// *Deprecated: new integrations should prefer the resource_subtype field.* The type of the custom field. Must be one of the given values.
132#[derive(
133    Clone,
134    Copy,
135    Debug,
136    Eq,
137    PartialEq,
138    Ord,
139    PartialOrd,
140    Hash,
141    Serialize,
142    Deserialize
143)]
144pub enum Type {
145    #[serde(rename = "text")]
146    Text,
147    #[serde(rename = "enum")]
148    _Enum,
149    #[serde(rename = "number")]
150    Number,
151}
152/// The format of this custom field.
153#[derive(
154    Clone,
155    Copy,
156    Debug,
157    Eq,
158    PartialEq,
159    Ord,
160    PartialOrd,
161    Hash,
162    Serialize,
163    Deserialize
164)]
165pub enum Format {
166    #[serde(rename = "currency")]
167    Currency,
168    #[serde(rename = "identifier")]
169    Identifier,
170    #[serde(rename = "percentage")]
171    Percentage,
172    #[serde(rename = "custom")]
173    Custom,
174    #[serde(rename = "none")]
175    None,
176}
177/// Only relevant for custom fields with `custom` format. This depicts where to place the custom label. This will be null if the `format` is not `custom`.
178#[derive(
179    Clone,
180    Copy,
181    Debug,
182    Eq,
183    PartialEq,
184    Ord,
185    PartialOrd,
186    Hash,
187    Serialize,
188    Deserialize
189)]
190pub enum CustomLabelPosition {
191    #[serde(rename = "prefix")]
192    Prefix,
193    #[serde(rename = "suffix")]
194    Suffix,
195}