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:
nutcas3
2026-05-03 13:29:44 +03:00
parent 12887765de
commit 9f51d6f20e
44 changed files with 3432 additions and 146 deletions
+6 -2
View File
@@ -57,7 +57,9 @@ defmodule TelecomSDK do
payments = PaymentAPI.new(http_client)
rating_plans = RatingPlanAPI.new(http_client)
system = SystemAPI.new(http_client)
graphql = GraphQLAPI.new(http_client)
analytics = AnalyticsAPI.new(http_client)
security = SecurityAPI.new(http_client)
currency = CurrencyAPI.new(http_client)
state = %{
config: config,
@@ -68,7 +70,9 @@ defmodule TelecomSDK do
payments: payments,
rating_plans: rating_plans,
system: system,
graphql: graphql
analytics: analytics,
security: security,
currency: currency
}
{:ok, state}
@@ -0,0 +1,78 @@
defmodule TelecomSDK.AnalyticsAPI do
@moduledoc """
Analytics API for churn prediction, market analysis, and pricing optimization
"""
defstruct [:http_client]
def new(http_client) do
%__MODULE__{http_client: http_client}
end
# Churn Analysis
def predict_churn(%__MODULE__{http_client: client}, profile_id) do
body = %{profile_id: profile_id}
HTTPClient.post(client, "/api/v1/analytics/churn/predict", body)
end
def get_churn_metrics(%__MODULE__{http_client: client}, period \\ "monthly") do
params = %{period: period}
HTTPClient.get(client, "/api/v1/analytics/churn/metrics", params)
end
def get_at_risk_customers(%__MODULE__{http_client: client}, risk_level, limit \\ 100) do
body = %{risk_level: risk_level, limit: limit}
HTTPClient.post(client, "/api/v1/analytics/churn/at-risk", body)
end
# Market Analytics
def get_market_metrics(%__MODULE__{http_client: client}, period \\ "monthly") do
params = %{period: period}
HTTPClient.get(client, "/api/v1/analytics/market/metrics", params)
end
def get_competitors(%__MODULE__{http_client: client}) do
HTTPClient.get(client, "/api/v1/analytics/market/competitors", %{})
end
def get_market_opportunities(%__MODULE__{http_client: client}) do
HTTPClient.get(client, "/api/v1/analytics/market/opportunities", %{})
end
# Predictive Maintenance
def get_maintenance_metrics(%__MODULE__{http_client: client}, period \\ "monthly") do
params = %{period: period}
HTTPClient.get(client, "/api/v1/analytics/maintenance/metrics", params)
end
def get_assets_health(%__MODULE__{http_client: client}) do
HTTPClient.get(client, "/api/v1/analytics/maintenance/assets", %{})
end
def get_maintenance_alerts(%__MODULE__{http_client: client}) do
HTTPClient.get(client, "/api/v1/analytics/maintenance/alerts", %{})
end
def predict_failure(%__MODULE__{http_client: client}, asset_id) do
HTTPClient.post(client, "/api/v1/analytics/maintenance/predict/#{asset_id}", %{})
end
# Pricing Optimization
def get_pricing_metrics(%__MODULE__{http_client: client}, period \\ "monthly") do
params = %{period: period}
HTTPClient.get(client, "/api/v1/analytics/pricing/metrics", params)
end
def optimize_pricing(%__MODULE__{http_client: client}, rate_plan_ids, strategy \\ "revenue_maximization") do
body = %{rate_plan_ids: rate_plan_ids, strategy: strategy}
HTTPClient.post(client, "/api/v1/analytics/pricing/optimize", body)
end
def get_price_elasticity(%__MODULE__{http_client: client}) do
HTTPClient.get(client, "/api/v1/analytics/pricing/elasticity", %{})
end
end
@@ -0,0 +1,61 @@
defmodule TelecomSDK.CurrencyAPI do
@moduledoc """
Currency and Billing API
"""
defstruct [:http_client]
def new(http_client) do
%__MODULE__{http_client: http_client}
end
# Currency Conversion
def convert(%__MODULE__{http_client: client}, from, to, amount) do
body = %{from: from, to: to, amount: amount}
HTTPClient.post(client, "/api/v1/currency/convert", body)
end
def get_exchange_rate(%__MODULE__{http_client: client}, from, to) do
HTTPClient.get(client, "/api/v1/currency/exchange/#{from}/#{to}", %{})
end
def get_exchange_rate_history(%__MODULE__{http_client: client}, from, to, days \\ 30) do
params = %{days: days}
HTTPClient.get(client, "/api/v1/currency/exchange/#{from}/#{to}/history", params)
end
def get_supported_currencies(%__MODULE__{http_client: client}) do
HTTPClient.get(client, "/api/v1/currency/currencies", %{})
end
def refresh_exchange_rates(%__MODULE__{http_client: client}) do
HTTPClient.post(client, "/api/v1/currency/exchange/refresh", %{})
end
# Billing
def process_billing(%__MODULE__{http_client: client}, billing_data) do
HTTPClient.post(client, "/api/v1/currency/billing", billing_data)
end
def get_billing_history(%__MODULE__{http_client: client}, profile_id, limit \\ 50) do
params = %{limit: limit}
HTTPClient.get(client, "/api/v1/currency/billing/history/#{profile_id}", params)
end
def get_billing_summary(%__MODULE__{http_client: client}, profile_id, period \\ "monthly") do
params = %{period: period}
HTTPClient.get(client, "/api/v1/currency/billing/summary/#{profile_id}", params)
end
def process_refund(%__MODULE__{http_client: client}, transaction_id, reason) do
body = %{reason: reason}
HTTPClient.post(client, "/api/v1/currency/billing/refund/#{transaction_id}", body)
end
def get_billing_analytics(%__MODULE__{http_client: client}, period \\ "monthly") do
params = %{period: period}
HTTPClient.get(client, "/api/v1/currency/billing/analytics", params)
end
end
-17
View File
@@ -1,17 +0,0 @@
defmodule TelecomSDK.GraphQLAPI do
@moduledoc """
API for GraphQL queries
"""
defstruct [:client]
def new(client) do
%__MODULE__{client: client}
end
def execute(api, query, variables \\ nil) do
request = %{query: query}
request = if variables, do: Map.put(request, :variables, variables), else: request
TelecomSDK.HTTPClient.post(api.client, "/graphql", request)
end
end
@@ -0,0 +1,47 @@
defmodule TelecomSDK.SecurityAPI do
@moduledoc """
Security API for fraud detection and SIM swap protection
"""
defstruct [:http_client]
def new(http_client) do
%__MODULE__{http_client: http_client}
end
# Fraud Detection
def analyze_transaction(%__MODULE__{http_client: client}, transaction) do
HTTPClient.post(client, "/api/v1/security/fraud/analyze", transaction)
end
def get_fraud_alerts(%__MODULE__{http_client: client}, filter \\ nil) do
body = if filter, do: filter, else: %{}
HTTPClient.post(client, "/api/v1/security/fraud/alerts", body)
end
def update_alert_status(%__MODULE__{http_client: client}, alert_id, status, actions \\ []) do
body = %{status: status, actions: actions}
HTTPClient.put(client, "/api/v1/security/fraud/alerts/#{alert_id}", body)
end
def get_fraud_metrics(%__MODULE__{http_client: client}, period \\ "monthly") do
params = %{period: period}
HTTPClient.get(client, "/api/v1/security/fraud/metrics", params)
end
def get_fraud_patterns(%__MODULE__{http_client: client}) do
HTTPClient.get(client, "/api/v1/security/fraud/patterns", %{})
end
# SIM Swap Protection
def verify_sim_swap(%__MODULE__{http_client: client}, profile_id, msisdn) do
body = %{profile_id: profile_id, msisdn: msisdn}
HTTPClient.post(client, "/api/v1/security/simswap/verify", body)
end
def get_sim_swap_history(%__MODULE__{http_client: client}, profile_id) do
HTTPClient.get(client, "/api/v1/security/simswap/history/#{profile_id}", %{})
end
end