use crate::models;
use serde::{Deserialize, Serialize};
#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize, bon::Builder)]
pub struct GroupResponse {
#[serde(rename = "id")]
pub id: String,
#[serde(rename = "name")]
pub name: String,
#[serde(rename = "created_at")]
pub created_at: i32,
#[serde(rename = "is_scim_managed")]
pub is_scim_managed: bool,
#[serde(rename = "group_type")]
pub group_type: GroupType,
}
impl GroupResponse {
pub fn new(
id: String,
name: String,
created_at: i32,
is_scim_managed: bool,
group_type: GroupType,
) -> GroupResponse {
GroupResponse {
id,
name,
created_at,
is_scim_managed,
group_type,
}
}
}
#[derive(Clone, Copy, Debug, Eq, PartialEq, Ord, PartialOrd, Hash, Serialize, Deserialize)]
pub enum GroupType {
#[serde(rename = "group")]
Group,
#[serde(rename = "tenant_group")]
TenantGroup,
}
impl Default for GroupType {
fn default() -> GroupType {
Self::Group
}
}
impl std::fmt::Display for GroupResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match serde_json::to_string(self) {
Ok(s) => write!(f, "{}", s),
Err(_) => Err(std::fmt::Error),
}
}
}