figma_api/models/
variable_create.rs

1/*
2 * Figma API
3 *
4 * This is the OpenAPI specification for the [Figma REST API](https://www.figma.com/developers/api).  Note: we are releasing the OpenAPI specification as a beta given the large surface area and complexity of the REST API. If you notice any inaccuracies with the specification, please [file an issue](https://github.com/figma/rest-api-spec/issues).
5 *
6 * The version of the OpenAPI document: 0.31.0
7 * Contact: support@figma.com
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14/// VariableCreate : An object that contains details about creating a `Variable`.
15#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
16pub struct VariableCreate {
17    /// The action to perform for the variable.
18    #[serde(rename = "action")]
19    pub action: Action,
20    /// A temporary id for this variable.
21    #[serde(rename = "id", skip_serializing_if = "Option::is_none")]
22    pub id: Option<String>,
23    /// The name of this variable.
24    #[serde(rename = "name")]
25    pub name: String,
26    /// The variable collection that will contain the variable. You can use the temporary id of a variable collection.
27    #[serde(rename = "variableCollectionId")]
28    pub variable_collection_id: String,
29    /// The resolved type of the variable.
30    #[serde(rename = "resolvedType")]
31    pub resolved_type: ResolvedType,
32    /// The description of this variable.
33    #[serde(rename = "description", skip_serializing_if = "Option::is_none")]
34    pub description: Option<String>,
35    /// Whether this variable is hidden when publishing the current file as a library.
36    #[serde(rename = "hiddenFromPublishing", skip_serializing_if = "Option::is_none")]
37    pub hidden_from_publishing: Option<bool>,
38    /// An array of scopes in the UI where this variable is shown. Setting this property will show/hide this variable in the variable picker UI for different fields.
39    #[serde(rename = "scopes", skip_serializing_if = "Option::is_none")]
40    pub scopes: Option<Vec<models::VariableScope>>,
41    #[serde(rename = "codeSyntax", skip_serializing_if = "Option::is_none")]
42    pub code_syntax: Option<Box<models::VariableCodeSyntax>>,
43}
44
45impl VariableCreate {
46    /// An object that contains details about creating a `Variable`.
47    pub fn new(action: Action, name: String, variable_collection_id: String, resolved_type: ResolvedType) -> VariableCreate {
48        VariableCreate {
49            action,
50            id: None,
51            name,
52            variable_collection_id,
53            resolved_type,
54            description: None,
55            hidden_from_publishing: None,
56            scopes: None,
57            code_syntax: None,
58        }
59    }
60}
61/// The action to perform for the variable.
62#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
63pub enum Action {
64    #[serde(rename = "CREATE")]
65    Create,
66}
67
68impl Default for Action {
69    fn default() -> Action {
70        Self::Create
71    }
72}
73/// The resolved type of the variable.
74#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
75pub enum ResolvedType {
76    #[serde(rename = "BOOLEAN")]
77    Boolean,
78    #[serde(rename = "FLOAT")]
79    Float,
80    #[serde(rename = "STRING")]
81    String,
82    #[serde(rename = "COLOR")]
83    Color,
84}
85
86impl Default for ResolvedType {
87    fn default() -> ResolvedType {
88        Self::Boolean
89    }
90}
91