Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async-trait = "0.1"

# Serialization
serde = { version = "1", features = ["derive", "rc"] }
serde_json = "1"

## Misc
bitflags = "2.4"
Expand Down
60 changes: 60 additions & 0 deletions src/project/types/project_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,66 @@ pub struct PlanLimits {
pub is_above_mau_limit: bool,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Feature {
pub id: String,
pub is_enabled: bool,
pub config: Option<serde_json::Value>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
#[serde(rename_all = "camelCase")]
pub struct FeaturesResponse {
pub features: Vec<Feature>,
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ProjectDataWithLimitsAndFeatures {
Comment thread
lukaisailovic marked this conversation as resolved.
Outdated
pub data: ProjectData,
pub limits: PlanLimits,
pub features: Vec<Feature>,
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct ProjectDataRequest<'a> {
pub id: &'a str,
pub include_limits: bool,
pub include_features: bool,
}

impl<'a> ProjectDataRequest<'a> {
pub fn new(id: &'a str) -> Self {
Self {
id,
include_limits: false,
include_features: false,
}
}

pub fn include_limits(mut self, include: bool) -> Self {
Comment thread
lukaisailovic marked this conversation as resolved.
Outdated
self.include_limits = include;
self
}

pub fn include_features(mut self, include: bool) -> Self {
self.include_features = include;
self
}
}

#[derive(Debug, Serialize, Deserialize, PartialEq, Eq, Hash, Clone)]
#[serde(rename_all = "camelCase")]
pub struct ProjectDataResponse {
#[serde(flatten)]
pub data: ProjectData,
#[serde(default)]
pub limits: Option<PlanLimits>,
#[serde(default)]
pub features: Option<Vec<Feature>>,
}

impl ProjectData {
pub fn validate_access(
&self,
Expand Down
Loading
Loading