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
use serde::{Deserialize, Serialize};
use crate::{field_access, impl_default, impl_display};
/// OnboardingStep : Dictionary containing details of a single onboarding step.
///
/// Modified from `openapi-generator-cli` output:
///
/// ```shell,no_build,no_run
/// $ openapi-generator-cli generate -g rust -i ./zerver/openapi/zulip.yaml -o zulip-openapi --skip-validate-spec
/// ```
///
/// ```text
/// /*
/// * Zulip REST API
/// *
/// * Powerful open source group chat
/// *
/// * The version of the OpenAPI document: 1.0.0
/// *
/// * Generated by: https://openapi-generator.tech
/// */
/// ```
///
/// See [zerver/openapi/zulip.yaml](https://github.com/zulip/zulip/blob/main/zerver/openapi/zulip.yaml) for the original OpenAPI configuration.
///
/// Configuration slightly modified to work with the Rust generator of [`openapi-generator-cli`](https://openapi-generator.tech).
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct OnboardingStep {
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
onboarding_type: Option<OnboardingType>,
#[serde(skip_serializing_if = "Option::is_none")]
name: Option<String>,
}
impl OnboardingStep {
/// Creates a new [OnboardingStep].
pub const fn new() -> Self {
OnboardingStep {
onboarding_type: None,
name: None,
}
}
}
field_access! {
OnboardingStep {
/// The type of the onboarding step.
onboarding_type: option { OnboardingType },
}
}
field_access! {
OnboardingStep {
/// The name of the onboarding step.
name: option_cow_deref { str, String },
}
}
impl_default!(OnboardingStep);
impl_display!(OnboardingStep);
/// Represents the [OnboardingStep] type.
///
/// Valid value is `\"one_time_notice\"`.
///
/// **Changes**: Removed type `\"hotspot\"` in Zulip 9.0 (feature level 259). New in Zulip 8.0 (feature level 233).
#[derive(Clone, Copy, Debug, Eq, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum OnboardingType {
OneTimeNotice,
}
impl OnboardingType {
/// Creates a new [OnboardingType].
pub const fn new() -> Self {
Self::OneTimeNotice
}
}
impl_default!(OnboardingType);
impl_display!(OnboardingType);
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_onboarding_step() {
let onboarding_type = OnboardingType::new();
let name = "test name";
let step = OnboardingStep::new()
.with_onboarding_type(onboarding_type)
.with_name(name);
let step_json = step.to_string();
assert_eq!(serde_json::to_string(&step).unwrap(), step_json);
assert_eq!(
serde_json::from_str::<OnboardingStep>(&step_json).unwrap(),
step
);
assert_eq!(step.onboarding_type(), Some(onboarding_type));
assert_eq!(step.name(), Some(name));
}
}