mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-07 04:12:18 +00:00
feat: Add ChargingRule enum with string conversion for charging decisions
- Add ChargingRule enum with 7 variants (Allowed, InsufficientCredit, DataLimitExceeded, VoiceLimitExceeded, SmsLimitExceeded, UserBlocked, Blocked) - Add Debug, Clone, Serialize, Deserialize, PartialEq, Eq derives to ChargingRule - Add as_str method to convert ChargingRule variants to uppercase string constants
This commit is contained in:
@@ -2,6 +2,31 @@ use chrono::{DateTime, Utc};
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use redis::{FromRedisValue, ToRedisArgs, ToSingleRedisArg};
|
use redis::{FromRedisValue, ToRedisArgs, ToSingleRedisArg};
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
|
pub enum ChargingRule {
|
||||||
|
Allowed,
|
||||||
|
InsufficientCredit,
|
||||||
|
DataLimitExceeded,
|
||||||
|
VoiceLimitExceeded,
|
||||||
|
SmsLimitExceeded,
|
||||||
|
UserBlocked,
|
||||||
|
Blocked,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl ChargingRule {
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
ChargingRule::Allowed => "ALLOWED",
|
||||||
|
ChargingRule::InsufficientCredit => "INSUFFICIENT_CREDIT",
|
||||||
|
ChargingRule::DataLimitExceeded => "DATA_LIMIT_EXCEEDED",
|
||||||
|
ChargingRule::VoiceLimitExceeded => "VOICE_LIMIT_EXCEEDED",
|
||||||
|
ChargingRule::SmsLimitExceeded => "SMS_LIMIT_EXCEEDED",
|
||||||
|
ChargingRule::UserBlocked => "USER_BLOCKED",
|
||||||
|
ChargingRule::Blocked => "BLOCKED",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub struct SubscriberAccount {
|
pub struct SubscriberAccount {
|
||||||
pub imsi: String,
|
pub imsi: String,
|
||||||
|
|||||||
Reference in New Issue
Block a user