Skip to content

Commit 273a936

Browse files
feat: add project features (#31)
* feat: add project features * fix: format * chore: update the implementation to use generic request with features * chore: update with suggestions
1 parent c007202 commit 273a936

3 files changed

Lines changed: 463 additions & 2 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async-trait = "0.1"
1616

1717
# Serialization
1818
serde = { version = "1", features = ["derive", "rc"] }
19+
serde_json = "1"
1920

2021
## Misc
2122
bitflags = "2.4"

src/project/types/project_data.rs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,58 @@ pub struct PlanLimits {
6464
pub is_above_mau_limit: bool,
6565
}
6666

67+
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
68+
#[serde(rename_all = "camelCase")]
69+
pub struct Feature {
70+
pub id: String,
71+
pub is_enabled: bool,
72+
pub config: Option<serde_json::Value>,
73+
}
74+
75+
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
76+
#[serde(rename_all = "camelCase")]
77+
pub struct FeaturesResponse {
78+
pub features: Vec<Feature>,
79+
}
80+
81+
#[derive(Debug, Clone, PartialEq, Eq)]
82+
pub struct ProjectDataRequest<'a> {
83+
pub id: &'a str,
84+
pub include_limits: bool,
85+
pub include_features: bool,
86+
}
87+
88+
impl<'a> ProjectDataRequest<'a> {
89+
pub fn new(id: &'a str) -> Self {
90+
Self {
91+
id,
92+
include_limits: false,
93+
include_features: false,
94+
}
95+
}
96+
97+
pub fn include_limits(mut self) -> Self {
98+
self.include_limits = true;
99+
self
100+
}
101+
102+
pub fn include_features(mut self) -> Self {
103+
self.include_features = true;
104+
self
105+
}
106+
}
107+
108+
#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
109+
#[serde(rename_all = "camelCase")]
110+
pub struct ProjectDataResponse {
111+
#[serde(flatten)]
112+
pub data: ProjectData,
113+
#[serde(default)]
114+
pub limits: Option<PlanLimits>,
115+
#[serde(default)]
116+
pub features: Option<Vec<Feature>>,
117+
}
118+
67119
impl ProjectData {
68120
pub fn validate_access(
69121
&self,

0 commit comments

Comments
 (0)