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
+7 -3
View File
@@ -10,7 +10,9 @@ require_relative "telecom_sdk/usage_api"
require_relative "telecom_sdk/payments_api"
require_relative "telecom_sdk/rating_plans_api"
require_relative "telecom_sdk/system_api"
require_relative "telecom_sdk/graphql_api"
require_relative "telecom_sdk/analytics_api"
require_relative "telecom_sdk/security_api"
require_relative "telecom_sdk/currency_api"
module TelecomSDK
class Error < StandardError; end
@@ -22,7 +24,7 @@ module TelecomSDK
class ServerError < Error; end
class Client
attr_reader :config, :subscribers, :usage, :payments, :rating_plans, :system, :graphql
attr_reader :config, :subscribers, :usage, :payments, :rating_plans, :system, :analytics, :security, :currency
def initialize(config = {})
@config = Config.new(config)
@@ -42,7 +44,9 @@ module TelecomSDK
@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)
end
# Authentication methods
+73
View File
@@ -0,0 +1,73 @@
module TelecomSDK
class AnalyticsAPI
def initialize(http_client)
@http_client = http_client
end
# Churn Analysis
def predict_churn(profile_id)
@http_client.post("/api/v1/analytics/churn/predict", { profile_id: profile_id })
end
def get_churn_metrics(period: "monthly")
@http_client.get("/api/v1/analytics/churn/metrics", { period: period })
end
def get_at_risk_customers(risk_level:, limit: 100)
@http_client.post("/api/v1/analytics/churn/at-risk", {
risk_level: risk_level,
limit: limit
})
end
# Market Analytics
def get_market_metrics(period: "monthly")
@http_client.get("/api/v1/analytics/market/metrics", { period: period })
end
def get_competitors
@http_client.get("/api/v1/analytics/market/competitors")
end
def get_market_opportunities
@http_client.get("/api/v1/analytics/market/opportunities")
end
# Predictive Maintenance
def get_maintenance_metrics(period: "monthly")
@http_client.get("/api/v1/analytics/maintenance/metrics", { period: period })
end
def get_assets_health
@http_client.get("/api/v1/analytics/maintenance/assets")
end
def get_maintenance_alerts
@http_client.get("/api/v1/analytics/maintenance/alerts")
end
def predict_failure(asset_id)
@http_client.post("/api/v1/analytics/maintenance/predict/#{asset_id}", {})
end
# Pricing Optimization
def get_pricing_metrics(period: "monthly")
@http_client.get("/api/v1/analytics/pricing/metrics", { period: period })
end
def optimize_pricing(rate_plan_ids:, strategy: "revenue_maximization")
@http_client.post("/api/v1/analytics/pricing/optimize", {
rate_plan_ids: rate_plan_ids,
strategy: strategy
})
end
def get_price_elasticity
@http_client.get("/api/v1/analytics/pricing/elasticity")
end
end
end
+55
View File
@@ -0,0 +1,55 @@
module TelecomSDK
class CurrencyAPI
def initialize(http_client)
@http_client = http_client
end
# Currency Conversion
def convert(from:, to:, amount:)
@http_client.post("/api/v1/currency/convert", {
from: from,
to: to,
amount: amount
})
end
def get_exchange_rate(from:, to:)
@http_client.get("/api/v1/currency/exchange/#{from}/#{to}")
end
def get_exchange_rate_history(from:, to:, days: 30)
@http_client.get("/api/v1/currency/exchange/#{from}/#{to}/history", { days: days })
end
def get_supported_currencies
@http_client.get("/api/v1/currency/currencies")
end
def refresh_exchange_rates
@http_client.post("/api/v1/currency/exchange/refresh", {})
end
# Billing
def process_billing(billing_data)
@http_client.post("/api/v1/currency/billing", billing_data)
end
def get_billing_history(profile_id:, limit: 50)
@http_client.get("/api/v1/currency/billing/history/#{profile_id}", { limit: limit })
end
def get_billing_summary(profile_id:, period: "monthly")
@http_client.get("/api/v1/currency/billing/summary/#{profile_id}", { period: period })
end
def process_refund(transaction_id:, reason:)
@http_client.post("/api/v1/currency/billing/refund/#{transaction_id}", { reason: reason })
end
def get_billing_analytics(period: "monthly")
@http_client.get("/api/v1/currency/billing/analytics", { period: period })
end
end
end
-14
View File
@@ -1,14 +0,0 @@
module TelecomSDK
# API for GraphQL queries
class GraphQLAPI
def initialize(client)
@client = client
end
def execute(query, variables = nil)
request = { query: query }
request[:variables] = variables if variables
@client.post("/graphql", request)
end
end
end
+46
View File
@@ -0,0 +1,46 @@
module TelecomSDK
class SecurityAPI
def initialize(http_client)
@http_client = http_client
end
# Fraud Detection
def analyze_transaction(transaction)
@http_client.post("/api/v1/security/fraud/analyze", transaction)
end
def get_fraud_alerts(filter: nil)
payload = filter&.compact || {}
@http_client.post("/api/v1/security/fraud/alerts", payload)
end
def update_alert_status(alert_id:, status:, actions: [])
@http_client.put("/api/v1/security/fraud/alerts/#{alert_id}", {
status: status,
actions: actions
})
end
def get_fraud_metrics(period: "monthly")
@http_client.get("/api/v1/security/fraud/metrics", { period: period })
end
def get_fraud_patterns
@http_client.get("/api/v1/security/fraud/patterns")
end
# SIM Swap Protection
def verify_sim_swap(profile_id:, msisdn:)
@http_client.post("/api/v1/security/simswap/verify", {
profile_id: profile_id,
msisdn: msisdn
})
end
def get_sim_swap_history(profile_id)
@http_client.get("/api/v1/security/simswap/history/#{profile_id}")
end
end
end