SDK Smart Services
Gli SDK ufficiali di Smart Services semplificano l'integrazione con i nostri servizi AI e di automazione, fornendo librerie native per i linguaggi di programmazione piΓΉ popolari.
SDK disponibiliβ
π¨ JavaScript/TypeScriptβ
- NPM Package:
@teamsystem/smart-services-sdk - Supporto: Node.js 16+, Browser (con bundler)
- Features: Promise-based, TypeScript definitions, auto-retry
π¦ .NET (C#)β
- NuGet Package:
TeamSystem.SmartServices.SDK - Supporto: .NET 6+, .NET Framework 4.8+
- Features: Async/await, strong typing, dependency injection
π© Pythonβ
- PyPI Package:
teamsystem-smart-services - Supporto: Python 3.8+
- Features: Async/await, type hints, pytest integration
π§ Java (In sviluppo)β
- Maven Package:
com.teamsystem:smart-services-sdk - Supporto: Java 11+, Android
- Status: Coming soon in v1.1.0
Caratteristiche comuniβ
π Autenticazione automaticaβ
- Gestione automatica dei token OAuth 2.0
- Refresh automatico dei token scaduti
- Supporto per API Key e Client Credentials
Retry e resilienzaβ
- Retry automatico per errori temporanei
- Backoff esponenziale configurabile
- Circuit breaker per fallimenti ripetuti
Monitoring e loggingβ
- Logging strutturato delle richieste
- Metriche di performance integrate
- Tracciamento distribuito
Type safetyβ
- Modelli di dati strongly-typed
- Validazione automatica dei parametri
- IntelliSense completo negli IDE
Installazione rapidaβ
JavaScript/Node.jsβ
npm install @teamsystem/smart-services-sdk
import { SmartServicesClient } from '@teamsystem/smart-services-sdk';
const client = new SmartServicesClient({
apiKey: process.env.SMART_SERVICES_API_KEY,
environment: 'production'
});
.NET/C#β
dotnet add package TeamSystem.SmartServices.SDK
using TeamSystem.SmartServices;
var client = new SmartServicesClient(new SmartServicesOptions
{
ApiKey = Environment.GetEnvironmentVariable("SMART_SERVICES_API_KEY"),
Environment = SmartServicesEnvironment.Production
});
Pythonβ
pip install teamsystem-smart-services
from teamsystem_smart_services import SmartServicesClient
client = SmartServicesClient(
api_key=os.environ['SMART_SERVICES_API_KEY'],
environment='production'
)
Esempi di utilizzoβ
Analisi documento (Multi-linguaggio)β
- JavaScript
- C#
- Python
// Analisi fattura con JavaScript
const result = await client.ai.analyzeDocument({
file: './invoice.pdf',
type: 'invoice',
language: 'it'
});
console.log(`Fornitore: ${result.supplier.name}`);
console.log(`Totale: β¬${result.amounts.total}`);
// Analisi fattura con C#
var result = await client.AI.AnalyzeDocumentAsync(new DocumentAnalysisRequest
{
FilePath = "./invoice.pdf",
Type = DocumentType.Invoice,
Language = "it"
});
Console.WriteLine($"Fornitore: {result.Supplier.Name}");
Console.WriteLine($"Totale: β¬{result.Amounts.Total}");
# Analisi fattura con Python
result = await client.ai.analyze_document(
file='./invoice.pdf',
type='invoice',
language='it'
)
print(f"Fornitore: {result.supplier.name}")
print(f"Totale: β¬{result.amounts.total}")
Workflow automationβ
- JavaScript
- C#
- Python
// Creazione workflow
const workflow = await client.automation.createWorkflow({
name: 'Processo Approvazione Fatture',
trigger: {
type: 'document_uploaded',
filters: { document_type: 'invoice' }
},
steps: [
{
type: 'ai_analysis',
service: 'document_analysis'
},
{
type: 'approval_request',
assignee: 'finance_team'
},
{
type: 'integration',
target: 'erp_system'
}
]
});
// Creazione workflow
var workflow = await client.Automation.CreateWorkflowAsync(new WorkflowDefinition
{
Name = "Processo Approvazione Fatture",
Trigger = new DocumentUploadedTrigger
{
Filters = new { DocumentType = "invoice" }
},
Steps = new[]
{
new AIAnalysisStep { Service = "document_analysis" },
new ApprovalRequestStep { Assignee = "finance_team" },
new IntegrationStep { Target = "erp_system" }
}
});
# Creazione workflow
workflow = await client.automation.create_workflow({
'name': 'Processo Approvazione Fatture',
'trigger': {
'type': 'document_uploaded',
'filters': {'document_type': 'invoice'}
},
'steps': [
{
'type': 'ai_analysis',
'service': 'document_analysis'
},
{
'type': 'approval_request',
'assignee': 'finance_team'
},
{
'type': 'integration',
'target': 'erp_system'
}
]
})
Configurazione avanzataβ
Gestione ambientiβ
// Configurazione per ambienti diversi
const client = new SmartServicesClient({
apiKey: process.env.SMART_SERVICES_API_KEY,
environment: process.env.NODE_ENV === 'production' ? 'production' : 'sandbox',
timeout: 30000,
retryAttempts: 3,
retryDelay: 1000
});
Logging personalizzatoβ
// Configurazione logging
const client = new SmartServicesClient({
apiKey: 'your-api-key',
logger: {
level: 'debug',
format: 'json',
destination: './logs/smart-services.log'
}
});
Interceptors per richiesteβ
// Aggiunta di headers personalizzati
client.interceptors.request.use((config) => {
config.headers['X-Request-ID'] = generateRequestId();
config.headers['X-User-Agent'] = 'MyApp/1.0.0';
return config;
});
// Logging delle risposte
client.interceptors.response.use((response) => {
console.log(`Request completed: ${response.status} ${response.statusText}`);
return response;
});
Testingβ
Unit testing con mockβ
// Jest test con mock
import { SmartServicesClient } from '@teamsystem/smart-services-sdk';
import { mockDocumentAnalysis } from '@teamsystem/smart-services-sdk/testing';
describe('Document Analysis', () => {
let client;
beforeEach(() => {
client = new SmartServicesClient({ apiKey: 'test-key' });
mockDocumentAnalysis();
});
test('should analyze invoice correctly', async () => {
const result = await client.ai.analyzeDocument({
file: './test-invoice.pdf',
type: 'invoice'
});
expect(result.supplier.name).toBe('Test Supplier');
expect(result.amounts.total).toBe(1000);
});
});
Integration testingβ
// Test di integrazione
const client = new SmartServicesClient({
apiKey: process.env.TEST_API_KEY,
environment: 'sandbox'
});
test('integration: full document analysis flow', async () => {
const result = await client.ai.analyzeDocument({
file: './fixtures/sample-invoice.pdf',
type: 'invoice',
language: 'it'
});
expect(result.status).toBe('completed');
expect(result.confidence).toBeGreaterThan(0.8);
});
Migrazione e aggiornamentiβ
Versioning policyβ
- Patch releases (1.0.x): Bug fixes, nessun breaking change
- Minor releases (1.x.0): Nuove features, backward compatible
- Major releases (x.0.0): Breaking changes, migration guide fornita
Changelogβ
Mantieni sempre aggiornato il tuo SDK:
# Controlla la versione corrente
npm list @teamsystem/smart-services-sdk
# Aggiorna alla latest
npm update @teamsystem/smart-services-sdk
Supportoβ
Risorseβ
Gli SDK sono open source e contributi dalla community sono benvenuti!