use serde::{Deserialize, Serialize};
use super::{
entitlement_check_limit_behavior::EntitlementCheckLimitBehavior, usage_limit_id::UsageLimitId,
};
#[derive(Clone, Debug, PartialEq, Deserialize, Serialize)]
#[non_exhaustive]
pub struct EntitlementCheckLimit {
pub behavior: EntitlementCheckLimitBehavior,
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<std::collections::HashMap<String, String>>,
pub has_access: bool,
pub limit: rust_decimal::Decimal,
pub remaining: rust_decimal::Decimal,
pub usage_limit_id: UsageLimitId,
pub used: rust_decimal::Decimal,
#[serde(flatten)]
pub extra: serde_json::Map<String, serde_json::Value>,
}
impl EntitlementCheckLimit {
#[must_use]
pub fn new(
behavior: EntitlementCheckLimitBehavior,
has_access: bool,
limit: rust_decimal::Decimal,
remaining: rust_decimal::Decimal,
usage_limit_id: impl Into<UsageLimitId>,
used: rust_decimal::Decimal,
) -> Self {
Self {
behavior,
group: None,
has_access,
limit,
remaining,
usage_limit_id: usage_limit_id.into(),
used,
extra: serde_json::Map::new(),
}
}
}