flagsmith_flag_engine/organisations/
mod.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug, Clone)]
4pub struct Organisation {
5 pub id: u32,
6 pub name: String,
7 pub feature_analytics: bool,
8 pub stop_serving_flags: bool,
9 pub persist_trait_data: bool,
10}
11
12impl Organisation {
13 pub fn unique_slug(&self) -> String {
14 return self.id.to_string() + "_" + &self.name;
15 }
16}
17
18#[cfg(test)]
19mod tests {
20 use super::*;
21
22 #[test]
23 fn unqiue_slug_is_correct() {
24 let expected_slug = "1_test_org";
25 let organisation_json = r#"{
26 "id": 1,
27 "name": "test_org",
28 "feature_analytics": true,
29 "stop_serving_flags": false,
30 "persist_trait_data": true
31 }"#;
32
33 let organisation: Organisation = serde_json::from_str(organisation_json).unwrap();
34 assert_eq!(organisation.unique_slug(), expected_slug)
35 }
36}