mirror of
https://github.com/andwati/telecom-platform.git
synced 2026-11-23 20:38:48 +00:00
feat: Add analytics, security, and currency SDK modules with comprehensive API endpoints across Elixir and Go SDKs
- Add AnalyticsAPI with churn prediction (predict, metrics, at-risk), market analytics (metrics, competitors, opportunities), predictive maintenance (metrics, assets, alerts, predict), and pricing optimization (metrics, optimize, elasticity) endpoints - Add SecurityAPI with fraud detection (analyze, alerts, update status, metrics, patterns) and SIM swap protection (verify, history) endpoints - Add CurrencyAPI with currency conversion (convert, exchange rates, rate
This commit is contained in:
@@ -0,0 +1,216 @@
|
||||
use crate::client::HTTPClient;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Analytics API for churn prediction, market analysis, and pricing optimization
|
||||
#[derive(Clone)]
|
||||
pub struct AnalyticsAPI {
|
||||
client: HTTPClient,
|
||||
}
|
||||
|
||||
impl AnalyticsAPI {
|
||||
pub fn new(client: HTTPClient) -> Self {
|
||||
Self { client }
|
||||
}
|
||||
|
||||
// Churn Analysis
|
||||
|
||||
/// Predict churn risk for a profile
|
||||
pub async fn predict_churn(&self, profile_id: &str) -> Result<ChurnPrediction, crate::error::TelecomError> {
|
||||
let body = serde_json::json!({ "profile_id": profile_id });
|
||||
self.client.post("/api/v1/analytics/churn/predict", &body).await
|
||||
}
|
||||
|
||||
/// Get churn metrics
|
||||
pub async fn get_churn_metrics(&self, period: Option<&str>) -> Result<ChurnMetrics, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(p) = period {
|
||||
params.insert("period".to_string(), p.to_string());
|
||||
}
|
||||
self.client.get("/api/v1/analytics/churn/metrics", ¶ms).await
|
||||
}
|
||||
|
||||
/// Get at-risk customers
|
||||
pub async fn get_at_risk_customers(
|
||||
&self,
|
||||
risk_level: ChurnRiskLevel,
|
||||
limit: Option<u32>,
|
||||
) -> Result<Vec<ChurnPrediction>, crate::error::TelecomError> {
|
||||
let mut body = serde_json::json!({ "risk_level": risk_level });
|
||||
if let Some(l) = limit {
|
||||
body["limit"] = serde_json::Value::Number(l.into());
|
||||
}
|
||||
self.client.post("/api/v1/analytics/churn/at-risk", &body).await
|
||||
}
|
||||
|
||||
// Market Analytics
|
||||
|
||||
/// Get market metrics
|
||||
pub async fn get_market_metrics(&self, period: Option<&str>) -> Result<MarketMetrics, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(p) = period {
|
||||
params.insert("period".to_string(), p.to_string());
|
||||
}
|
||||
self.client.get("/api/v1/analytics/market/metrics", ¶ms).await
|
||||
}
|
||||
|
||||
/// Get competitor analysis
|
||||
pub async fn get_competitors(&self) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.get("/api/v1/analytics/market/competitors", &HashMap::new()).await
|
||||
}
|
||||
|
||||
/// Get market opportunities
|
||||
pub async fn get_market_opportunities(&self) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.get("/api/v1/analytics/market/opportunities", &HashMap::new()).await
|
||||
}
|
||||
|
||||
// Predictive Maintenance
|
||||
|
||||
/// Get maintenance metrics
|
||||
pub async fn get_maintenance_metrics(&self, period: Option<&str>) -> Result<MaintenanceMetrics, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(p) = period {
|
||||
params.insert("period".to_string(), p.to_string());
|
||||
}
|
||||
self.client.get("/api/v1/analytics/maintenance/metrics", ¶ms).await
|
||||
}
|
||||
|
||||
/// Get assets health
|
||||
pub async fn get_assets_health(&self) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.get("/api/v1/analytics/maintenance/assets", &HashMap::new()).await
|
||||
}
|
||||
|
||||
/// Get maintenance alerts
|
||||
pub async fn get_maintenance_alerts(&self) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.get("/api/v1/analytics/maintenance/alerts", &HashMap::new()).await
|
||||
}
|
||||
|
||||
/// Predict failure for an asset
|
||||
pub async fn predict_failure(&self, asset_id: &str) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.post(&format!("/api/v1/analytics/maintenance/predict/{}", asset_id), &serde_json::Value::Null).await
|
||||
}
|
||||
|
||||
// Pricing Optimization
|
||||
|
||||
/// Get pricing metrics
|
||||
pub async fn get_pricing_metrics(&self, period: Option<&str>) -> Result<PricingMetrics, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(p) = period {
|
||||
params.insert("period".to_string(), p.to_string());
|
||||
}
|
||||
self.client.get("/api/v1/analytics/pricing/metrics", ¶ms).await
|
||||
}
|
||||
|
||||
/// Optimize pricing for rate plans
|
||||
pub async fn optimize_pricing(
|
||||
&self,
|
||||
rate_plan_ids: Vec<String>,
|
||||
strategy: Option<&str>,
|
||||
) -> Result<Vec<PricingOptimizationResult>, crate::error::TelecomError> {
|
||||
let mut body = serde_json::json!({ "rate_plan_ids": rate_plan_ids });
|
||||
if let Some(s) = strategy {
|
||||
body["strategy"] = serde_json::Value::String(s.to_string());
|
||||
}
|
||||
self.client.post("/api/v1/analytics/pricing/optimize", &body).await
|
||||
}
|
||||
|
||||
/// Get price elasticity data
|
||||
pub async fn get_price_elasticity(&self) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.get("/api/v1/analytics/pricing/elasticity", &HashMap::new()).await
|
||||
}
|
||||
}
|
||||
|
||||
// Analytics Types
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ChurnPrediction {
|
||||
pub profile_id: String,
|
||||
pub risk_level: String,
|
||||
pub risk_score: f64,
|
||||
pub predicted_churn_date: Option<String>,
|
||||
pub reasons: Vec<String>,
|
||||
pub recommendations: Vec<String>,
|
||||
pub last_updated: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ChurnMetrics {
|
||||
pub period: String,
|
||||
pub total_subscribers: i64,
|
||||
pub churned_subscribers: i64,
|
||||
pub churn_rate: f64,
|
||||
pub monthly_churn_rate: f64,
|
||||
pub annual_churn_rate: f64,
|
||||
pub average_tenure_days: f64,
|
||||
pub risk_distribution: HashMap<String, i64>,
|
||||
pub generated_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct MarketMetrics {
|
||||
pub period: String,
|
||||
pub total_market_size: i64,
|
||||
pub our_subscribers: i64,
|
||||
pub market_share: f64,
|
||||
pub growth_rate: f64,
|
||||
pub by_country: HashMap<String, serde_json::Value>,
|
||||
pub generated_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct MaintenanceMetrics {
|
||||
pub period: String,
|
||||
pub total_assets: i64,
|
||||
pub healthy_assets: i64,
|
||||
pub assets_needing_attention: i64,
|
||||
pub uptime: f64,
|
||||
pub mean_time_to_failure: f64,
|
||||
pub mean_time_to_repair: f64,
|
||||
pub generated_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PricingMetrics {
|
||||
pub period: String,
|
||||
pub total_revenue: f64,
|
||||
pub arpu: f64,
|
||||
pub price_elasticity: f64,
|
||||
pub competitive_index: f64,
|
||||
pub optimization_roi: f64,
|
||||
pub generated_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct PricingOptimizationResult {
|
||||
pub rate_plan_id: String,
|
||||
pub strategy: String,
|
||||
pub current_price: f64,
|
||||
pub optimal_price: f64,
|
||||
pub price_change_pct: f64,
|
||||
pub expected_revenue: f64,
|
||||
pub expected_demand: f64,
|
||||
pub confidence: f64,
|
||||
pub reasoning: Vec<String>,
|
||||
pub risks: Vec<String>,
|
||||
pub recommendations: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum ChurnRiskLevel {
|
||||
Low,
|
||||
Medium,
|
||||
High,
|
||||
Critical,
|
||||
}
|
||||
|
||||
impl AsRef<str> for ChurnRiskLevel {
|
||||
fn as_ref(&self) -> &str {
|
||||
match self {
|
||||
ChurnRiskLevel::Low => "low",
|
||||
ChurnRiskLevel::Medium => "medium",
|
||||
ChurnRiskLevel::High => "high",
|
||||
ChurnRiskLevel::Critical => "critical",
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
use crate::client::HTTPClient;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Currency and Billing API
|
||||
#[derive(Clone)]
|
||||
pub struct CurrencyAPI {
|
||||
client: HTTPClient,
|
||||
}
|
||||
|
||||
impl CurrencyAPI {
|
||||
pub fn new(client: HTTPClient) -> Self {
|
||||
Self { client }
|
||||
}
|
||||
|
||||
// Currency Conversion
|
||||
|
||||
/// Convert currency
|
||||
pub async fn convert(
|
||||
&self,
|
||||
from: &str,
|
||||
to: &str,
|
||||
amount: f64,
|
||||
) -> Result<ConvertResponse, crate::error::TelecomError> {
|
||||
let body = serde_json::json!({
|
||||
"from": from,
|
||||
"to": to,
|
||||
"amount": amount
|
||||
});
|
||||
self.client.post("/api/v1/currency/convert", &body).await
|
||||
}
|
||||
|
||||
/// Get exchange rate between currencies
|
||||
pub async fn get_exchange_rate(&self, from: &str, to: &str) -> Result<ExchangeRate, crate::error::TelecomError> {
|
||||
self.client.get(&format!("/api/v1/currency/exchange/{}/{}", from, to), &HashMap::new()).await
|
||||
}
|
||||
|
||||
/// Get exchange rate history
|
||||
pub async fn get_exchange_rate_history(
|
||||
&self,
|
||||
from: &str,
|
||||
to: &str,
|
||||
days: Option<u32>,
|
||||
) -> Result<Vec<ExchangeRate>, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(d) = days {
|
||||
params.insert("days".to_string(), d.to_string());
|
||||
}
|
||||
self.client.get(&format!("/api/v1/currency/exchange/{}/{}", from, to), ¶ms).await
|
||||
}
|
||||
|
||||
/// Get supported currencies
|
||||
pub async fn get_supported_currencies(&self) -> Result<Vec<Currency>, crate::error::TelecomError> {
|
||||
self.client.get("/api/v1/currency/currencies", &HashMap::new()).await
|
||||
}
|
||||
|
||||
/// Refresh exchange rates
|
||||
pub async fn refresh_exchange_rates(&self) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.post("/api/v1/currency/exchange/refresh", &serde_json::Value::Null).await
|
||||
}
|
||||
|
||||
// Billing
|
||||
|
||||
/// Process billing transaction
|
||||
pub async fn process_billing(
|
||||
&self,
|
||||
billing_data: &serde_json::Value,
|
||||
) -> Result<BillingTransaction, crate::error::TelecomError> {
|
||||
self.client.post("/api/v1/currency/billing", billing_data).await
|
||||
}
|
||||
|
||||
/// Get billing history for a profile
|
||||
pub async fn get_billing_history(
|
||||
&self,
|
||||
profile_id: &str,
|
||||
limit: Option<u32>,
|
||||
) -> Result<Vec<BillingTransaction>, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(l) = limit {
|
||||
params.insert("limit".to_string(), l.to_string());
|
||||
}
|
||||
self.client.get(&format!("/api/v1/currency/billing/history/{}", profile_id), ¶ms).await
|
||||
}
|
||||
|
||||
/// Get billing summary for a profile
|
||||
pub async fn get_billing_summary(
|
||||
&self,
|
||||
profile_id: &str,
|
||||
period: Option<&str>,
|
||||
) -> Result<BillingSummary, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(p) = period {
|
||||
params.insert("period".to_string(), p.to_string());
|
||||
}
|
||||
self.client.get(&format!("/api/v1/currency/billing/summary/{}", profile_id), ¶ms).await
|
||||
}
|
||||
|
||||
/// Process refund
|
||||
pub async fn process_refund(
|
||||
&self,
|
||||
transaction_id: &str,
|
||||
reason: &str,
|
||||
) -> Result<BillingTransaction, crate::error::TelecomError> {
|
||||
let body = serde_json::json!({ "reason": reason });
|
||||
self.client.post(&format!("/api/v1/currency/billing/refund/{}", transaction_id), &body).await
|
||||
}
|
||||
|
||||
/// Get billing analytics
|
||||
pub async fn get_billing_analytics(&self, period: Option<&str>) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(p) = period {
|
||||
params.insert("period".to_string(), p.to_string());
|
||||
}
|
||||
self.client.get("/api/v1/currency/billing/analytics", ¶ms).await
|
||||
}
|
||||
}
|
||||
|
||||
// Currency Types
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ConvertRequest {
|
||||
pub from: String,
|
||||
pub to: String,
|
||||
pub amount: f64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ConvertResponse {
|
||||
pub from: String,
|
||||
pub to: String,
|
||||
pub amount: f64,
|
||||
pub converted: f64,
|
||||
pub rate: f64,
|
||||
pub timestamp: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct ExchangeRate {
|
||||
pub from: String,
|
||||
pub to: String,
|
||||
pub rate: f64,
|
||||
pub timestamp: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct Currency {
|
||||
pub code: String,
|
||||
pub name: String,
|
||||
pub symbol: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct BillingTransaction {
|
||||
pub id: String,
|
||||
#[serde(rename = "profile_id")]
|
||||
pub profile_id: String,
|
||||
pub amount: f64,
|
||||
pub currency: String,
|
||||
#[serde(rename = "type")]
|
||||
pub transaction_type: String,
|
||||
pub status: String,
|
||||
pub description: String,
|
||||
#[serde(rename = "created_at")]
|
||||
pub created_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct BillingSummary {
|
||||
#[serde(rename = "profile_id")]
|
||||
pub profile_id: String,
|
||||
pub period: String,
|
||||
#[serde(rename = "total_amount")]
|
||||
pub total_amount: f64,
|
||||
pub currency: String,
|
||||
#[serde(rename = "transaction_count")]
|
||||
pub transaction_count: u32,
|
||||
pub breakdown: HashMap<String, f64>,
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
use crate::client::HTTPClient;
|
||||
use crate::error::TelecomError;
|
||||
use crate::types::GraphQLRequest;
|
||||
use std::collections::HashMap;
|
||||
|
||||
pub struct GraphQLAPI {
|
||||
client: HTTPClient,
|
||||
}
|
||||
|
||||
impl GraphQLAPI {
|
||||
pub fn new(client: HTTPClient) -> Self {
|
||||
Self { client }
|
||||
}
|
||||
|
||||
pub async fn execute(
|
||||
&self,
|
||||
query: String,
|
||||
variables: Option<HashMap<String, serde_json::Value>>,
|
||||
) -> Result<HashMap<String, serde_json::Value>, TelecomError> {
|
||||
let req = GraphQLRequest { query, variables };
|
||||
self.client.post("/graphql", Some(&req)).await
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,17 @@
|
||||
pub mod graphql;
|
||||
pub mod analytics;
|
||||
pub mod currency;
|
||||
pub mod payments;
|
||||
pub mod rating_plans;
|
||||
pub mod security;
|
||||
pub mod subscribers;
|
||||
pub mod system;
|
||||
pub mod usage;
|
||||
|
||||
pub use graphql::GraphQLAPI;
|
||||
pub use analytics::AnalyticsAPI;
|
||||
pub use currency::CurrencyAPI;
|
||||
pub use payments::PaymentAPI;
|
||||
pub use rating_plans::RatingPlanAPI;
|
||||
pub use security::SecurityAPI;
|
||||
pub use subscribers::SubscriberAPI;
|
||||
pub use system::SystemAPI;
|
||||
pub use usage::UsageAPI;
|
||||
|
||||
@@ -0,0 +1,180 @@
|
||||
use crate::client::HTTPClient;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// Security API for fraud detection and SIM swap protection
|
||||
#[derive(Clone)]
|
||||
pub struct SecurityAPI {
|
||||
client: HTTPClient,
|
||||
}
|
||||
|
||||
impl SecurityAPI {
|
||||
pub fn new(client: HTTPClient) -> Self {
|
||||
Self { client }
|
||||
}
|
||||
|
||||
// Fraud Detection
|
||||
|
||||
/// Analyze a transaction for fraud
|
||||
pub async fn analyze_transaction(
|
||||
&self,
|
||||
transaction: &serde_json::Value,
|
||||
) -> Result<Option<FraudAlert>, crate::error::TelecomError> {
|
||||
match self.client.post("/api/v1/security/fraud/analyze", transaction).await {
|
||||
Ok(alert) => Ok(Some(alert)),
|
||||
Err(crate::error::TelecomError::APIError(404, _)) => Ok(None),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
/// Get fraud alerts with filtering
|
||||
pub async fn get_fraud_alerts(
|
||||
&self,
|
||||
filter: Option<FraudAlertFilter>,
|
||||
) -> Result<Vec<FraudAlert>, crate::error::TelecomError> {
|
||||
let body = if let Some(f) = filter {
|
||||
serde_json::to_value(f).unwrap_or_default()
|
||||
} else {
|
||||
serde_json::Value::Null
|
||||
};
|
||||
self.client.post("/api/v1/security/fraud/alerts", &body).await
|
||||
}
|
||||
|
||||
/// Update fraud alert status
|
||||
pub async fn update_alert_status(
|
||||
&self,
|
||||
alert_id: &str,
|
||||
status: &str,
|
||||
actions: Vec<String>,
|
||||
) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
let body = serde_json::json!({
|
||||
"status": status,
|
||||
"actions": actions
|
||||
});
|
||||
self.client.put(&format!("/api/v1/security/fraud/alerts/{}", alert_id), &body).await
|
||||
}
|
||||
|
||||
/// Get fraud detection metrics
|
||||
pub async fn get_fraud_metrics(&self, period: Option<&str>) -> Result<FraudMetrics, crate::error::TelecomError> {
|
||||
let mut params = HashMap::new();
|
||||
if let Some(p) = period {
|
||||
params.insert("period".to_string(), p.to_string());
|
||||
}
|
||||
self.client.get("/api/v1/security/fraud/metrics", ¶ms).await
|
||||
}
|
||||
|
||||
/// Get detected fraud patterns
|
||||
pub async fn get_fraud_patterns(&self) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.get("/api/v1/security/fraud/patterns", &HashMap::new()).await
|
||||
}
|
||||
|
||||
// SIM Swap Protection
|
||||
|
||||
/// Verify SIM swap request
|
||||
pub async fn verify_sim_swap(
|
||||
&self,
|
||||
profile_id: &str,
|
||||
msisdn: &str,
|
||||
) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
let body = serde_json::json!({
|
||||
"profile_id": profile_id,
|
||||
"msisdn": msisdn
|
||||
});
|
||||
self.client.post("/api/v1/security/simswap/verify", &body).await
|
||||
}
|
||||
|
||||
/// Get SIM swap history for a profile
|
||||
pub async fn get_sim_swap_history(&self, profile_id: &str) -> Result<HashMap<String, serde_json::Value>, crate::error::TelecomError> {
|
||||
self.client.get(&format!("/api/v1/security/simswap/history/{}", profile_id), &HashMap::new()).await
|
||||
}
|
||||
}
|
||||
|
||||
// Security Types
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct FraudAlert {
|
||||
pub id: String,
|
||||
#[serde(rename = "type")]
|
||||
pub alert_type: String,
|
||||
pub severity: String,
|
||||
#[serde(rename = "profile_id")]
|
||||
pub profile_id: String,
|
||||
pub description: String,
|
||||
#[serde(rename = "risk_score")]
|
||||
pub risk_score: f64,
|
||||
pub evidence: Vec<String>,
|
||||
#[serde(rename = "ip_address")]
|
||||
pub ip_address: String,
|
||||
pub timestamp: String,
|
||||
pub status: String,
|
||||
#[serde(rename = "actions_taken")]
|
||||
pub actions_taken: Vec<String>,
|
||||
pub metadata: HashMap<String, serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct FraudMetrics {
|
||||
pub period: String,
|
||||
#[serde(rename = "total_alerts")]
|
||||
pub total_alerts: i64,
|
||||
#[serde(rename = "resolved_alerts")]
|
||||
pub resolved_alerts: i64,
|
||||
#[serde(rename = "false_positives")]
|
||||
pub false_positives: i64,
|
||||
#[serde(rename = "resolution_rate")]
|
||||
pub resolution_rate: f64,
|
||||
#[serde(rename = "false_positive_rate")]
|
||||
pub false_positive_rate: f64,
|
||||
#[serde(rename = "by_type")]
|
||||
pub by_type: HashMap<String, i64>,
|
||||
#[serde(rename = "by_severity")]
|
||||
pub by_severity: HashMap<String, i64>,
|
||||
#[serde(rename = "generated_at")]
|
||||
pub generated_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct FraudAlertFilter {
|
||||
#[serde(rename = "type", skip_serializing_if = "Option::is_none")]
|
||||
pub alert_type: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub severity: Option<String>,
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub status: Option<String>,
|
||||
#[serde(default = "default_limit")]
|
||||
pub limit: u32,
|
||||
}
|
||||
|
||||
fn default_limit() -> u32 {
|
||||
50
|
||||
}
|
||||
|
||||
impl Default for FraudAlertFilter {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
alert_type: None,
|
||||
severity: None,
|
||||
status: None,
|
||||
limit: 50,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum FraudType {
|
||||
AccountTakeover,
|
||||
SubscriptionFraud,
|
||||
PaymentFraud,
|
||||
UsageAnomaly,
|
||||
SimSwap,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub enum FraudSeverity {
|
||||
Low,
|
||||
Medium,
|
||||
High,
|
||||
Critical,
|
||||
}
|
||||
+10
-4
@@ -14,7 +14,7 @@ use error::TelecomError;
|
||||
use std::time::Duration;
|
||||
use types::*;
|
||||
|
||||
pub use api::{GraphQLAPI, PaymentAPI, RatingPlanAPI, SubscriberAPI, SystemAPI, UsageAPI};
|
||||
pub use api::{AnalyticsAPI, CurrencyAPI, PaymentAPI, RatingPlanAPI, SecurityAPI, SubscriberAPI, SystemAPI, UsageAPI};
|
||||
|
||||
/// Telecom Platform SDK client
|
||||
#[derive(Clone)]
|
||||
@@ -28,7 +28,9 @@ pub struct TelecomClient {
|
||||
pub payments: PaymentAPI,
|
||||
pub rating_plans: RatingPlanAPI,
|
||||
pub system: SystemAPI,
|
||||
pub graphql: GraphQLAPI,
|
||||
pub analytics: AnalyticsAPI,
|
||||
pub security: SecurityAPI,
|
||||
pub currency: CurrencyAPI,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -73,7 +75,9 @@ impl TelecomClient {
|
||||
let payments = PaymentAPI::new(http_client.clone());
|
||||
let rating_plans = RatingPlanAPI::new(http_client.clone());
|
||||
let system = SystemAPI::new(http_client.clone());
|
||||
let graphql = GraphQLAPI::new(http_client.clone());
|
||||
let analytics = AnalyticsAPI::new(http_client.clone());
|
||||
let security = SecurityAPI::new(http_client.clone());
|
||||
let currency = CurrencyAPI::new(http_client.clone());
|
||||
|
||||
Self {
|
||||
auth_provider,
|
||||
@@ -83,7 +87,9 @@ impl TelecomClient {
|
||||
payments,
|
||||
rating_plans,
|
||||
system,
|
||||
graphql,
|
||||
analytics,
|
||||
security,
|
||||
currency,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user