chore: sync submodule state (parent ref update)
Made-with: Cursor
This commit is contained in:
159
sdk/dotnet/DBIS.IRU.SDK/IRUClient.cs
Normal file
159
sdk/dotnet/DBIS.IRU.SDK/IRUClient.cs
Normal file
@@ -0,0 +1,159 @@
|
||||
// DBIS IRU .NET SDK
|
||||
// Client library for IRU integration
|
||||
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DBIS.IRU.SDK
|
||||
{
|
||||
/// <summary>
|
||||
/// DBIS IRU Client
|
||||
/// </summary>
|
||||
public class IRUClient
|
||||
{
|
||||
private readonly string apiBaseUrl;
|
||||
private readonly string apiKey;
|
||||
private readonly HttpClient httpClient;
|
||||
private readonly JsonSerializerOptions jsonOptions;
|
||||
|
||||
public IRUClient(string apiBaseUrl, string apiKey = null)
|
||||
{
|
||||
this.apiBaseUrl = apiBaseUrl.TrimEnd('/');
|
||||
this.apiKey = apiKey;
|
||||
this.httpClient = new HttpClient
|
||||
{
|
||||
Timeout = TimeSpan.FromSeconds(30)
|
||||
};
|
||||
|
||||
if (!string.IsNullOrEmpty(apiKey))
|
||||
{
|
||||
this.httpClient.DefaultRequestHeaders.Add("Authorization", $"Bearer {apiKey}");
|
||||
}
|
||||
|
||||
this.httpClient.DefaultRequestHeaders.Add("Content-Type", "application/json");
|
||||
|
||||
this.jsonOptions = new JsonSerializerOptions
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get all IRU offerings
|
||||
/// </summary>
|
||||
public async Task<IRUOffering[]> GetOfferingsAsync(
|
||||
int? capacityTier = null,
|
||||
string institutionalType = null
|
||||
)
|
||||
{
|
||||
var url = $"{apiBaseUrl}/api/v1/iru/marketplace/offerings";
|
||||
var queryParams = new System.Collections.Specialized.NameValueCollection();
|
||||
|
||||
if (capacityTier.HasValue)
|
||||
{
|
||||
queryParams.Add("capacityTier", capacityTier.Value.ToString());
|
||||
}
|
||||
if (!string.IsNullOrEmpty(institutionalType))
|
||||
{
|
||||
queryParams.Add("institutionalType", institutionalType);
|
||||
}
|
||||
|
||||
if (queryParams.Count > 0)
|
||||
{
|
||||
var queryString = string.Join("&",
|
||||
Array.ConvertAll(queryParams.AllKeys,
|
||||
key => $"{key}={Uri.EscapeDataString(queryParams[key])}"));
|
||||
url += "?" + queryString;
|
||||
}
|
||||
|
||||
var response = await httpClient.GetAsync(url);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonSerializer.Deserialize<ApiResponse<IRUOffering[]>>(json, jsonOptions);
|
||||
|
||||
return result.Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Submit inquiry
|
||||
/// </summary>
|
||||
public async Task<InquiryResult> SubmitInquiryAsync(IRUInquiry inquiry)
|
||||
{
|
||||
var url = $"{apiBaseUrl}/api/v1/iru/marketplace/inquiries";
|
||||
var json = JsonSerializer.Serialize(inquiry, jsonOptions);
|
||||
var content = new StringContent(json, Encoding.UTF8, "application/json");
|
||||
|
||||
var response = await httpClient.PostAsync(url, content);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var responseJson = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonSerializer.Deserialize<ApiResponse<InquiryResult>>(responseJson, jsonOptions);
|
||||
|
||||
return result.Data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get dashboard
|
||||
/// </summary>
|
||||
public async Task<DashboardData> GetDashboardAsync()
|
||||
{
|
||||
var url = $"{apiBaseUrl}/api/v1/iru/portal/dashboard";
|
||||
var response = await httpClient.GetAsync(url);
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
var json = await response.Content.ReadAsStringAsync();
|
||||
var result = JsonSerializer.Deserialize<ApiResponse<DashboardData>>(json, jsonOptions);
|
||||
|
||||
return result.Data;
|
||||
}
|
||||
}
|
||||
|
||||
public class ApiResponse<T>
|
||||
{
|
||||
public bool Success { get; set; }
|
||||
public T Data { get; set; }
|
||||
}
|
||||
|
||||
public class IRUOffering
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string OfferingId { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int CapacityTier { get; set; }
|
||||
public string InstitutionalType { get; set; }
|
||||
public decimal? BasePrice { get; set; }
|
||||
public string Currency { get; set; }
|
||||
}
|
||||
|
||||
public class IRUInquiry
|
||||
{
|
||||
public string OfferingId { get; set; }
|
||||
public string OrganizationName { get; set; }
|
||||
public string InstitutionalType { get; set; }
|
||||
public string Jurisdiction { get; set; }
|
||||
public string ContactEmail { get; set; }
|
||||
public string ContactPhone { get; set; }
|
||||
public string ContactName { get; set; }
|
||||
public string EstimatedVolume { get; set; }
|
||||
public DateTime? ExpectedGoLive { get; set; }
|
||||
}
|
||||
|
||||
public class InquiryResult
|
||||
{
|
||||
public string InquiryId { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string Message { get; set; }
|
||||
}
|
||||
|
||||
public class DashboardData
|
||||
{
|
||||
public object Subscription { get; set; }
|
||||
public object DeploymentStatus { get; set; }
|
||||
public object ServiceHealth { get; set; }
|
||||
}
|
||||
}
|
||||
122
sdk/java/src/main/java/org/dbis/iru/IRUClient.java
Normal file
122
sdk/java/src/main/java/org/dbis/iru/IRUClient.java
Normal file
@@ -0,0 +1,122 @@
|
||||
package org.dbis.iru;
|
||||
|
||||
import java.net.http.HttpClient;
|
||||
import java.net.http.HttpRequest;
|
||||
import java.net.http.HttpResponse;
|
||||
import java.net.URI;
|
||||
import java.time.Duration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
/**
|
||||
* DBIS IRU Java Client
|
||||
*/
|
||||
public class IRUClient {
|
||||
private final String apiBaseUrl;
|
||||
private final String apiKey;
|
||||
private final HttpClient httpClient;
|
||||
private final ObjectMapper objectMapper;
|
||||
|
||||
public IRUClient(String apiBaseUrl, String apiKey) {
|
||||
this.apiBaseUrl = apiBaseUrl.replaceAll("/$", "");
|
||||
this.apiKey = apiKey;
|
||||
this.httpClient = HttpClient.newBuilder()
|
||||
.connectTimeout(Duration.ofSeconds(30))
|
||||
.build();
|
||||
this.objectMapper = new ObjectMapper();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all IRU offerings
|
||||
*/
|
||||
public CompletableFuture<List<IRUOffering>> getOfferings(
|
||||
Integer capacityTier,
|
||||
String institutionalType
|
||||
) {
|
||||
StringBuilder url = new StringBuilder(apiBaseUrl + "/api/v1/iru/marketplace/offerings");
|
||||
boolean hasParams = false;
|
||||
|
||||
if (capacityTier != null) {
|
||||
url.append(hasParams ? "&" : "?").append("capacityTier=").append(capacityTier);
|
||||
hasParams = true;
|
||||
}
|
||||
if (institutionalType != null) {
|
||||
url.append(hasParams ? "&" : "?").append("institutionalType=").append(institutionalType);
|
||||
}
|
||||
|
||||
return request("GET", url.toString(), null)
|
||||
.thenApply(response -> {
|
||||
try {
|
||||
Map<String, Object> json = objectMapper.readValue(response, Map.class);
|
||||
Map<String, Object> data = (Map<String, Object>) json.get("data");
|
||||
List<Map<String, Object>> offerings = (List<Map<String, Object>>) data.get("data");
|
||||
// Convert to IRUOffering objects
|
||||
return offerings.stream()
|
||||
.map(this::mapToOffering)
|
||||
.collect(java.util.stream.Collectors.toList());
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to parse response", e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit inquiry
|
||||
*/
|
||||
public CompletableFuture<InquiryResult> submitInquiry(IRUInquiry inquiry) {
|
||||
try {
|
||||
String body = objectMapper.writeValueAsString(inquiry.toMap());
|
||||
return request("POST", apiBaseUrl + "/api/v1/iru/marketplace/inquiries", body)
|
||||
.thenApply(response -> {
|
||||
try {
|
||||
Map<String, Object> json = objectMapper.readValue(response, Map.class);
|
||||
Map<String, Object> data = (Map<String, Object>) json.get("data");
|
||||
return new InquiryResult(
|
||||
(String) data.get("inquiryId"),
|
||||
(String) data.get("status"),
|
||||
(String) data.get("message")
|
||||
);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Failed to parse response", e);
|
||||
}
|
||||
});
|
||||
} catch (Exception e) {
|
||||
return CompletableFuture.failedFuture(e);
|
||||
}
|
||||
}
|
||||
|
||||
private CompletableFuture<String> request(String method, String url, String body) {
|
||||
HttpRequest.Builder builder = HttpRequest.newBuilder()
|
||||
.uri(URI.create(url))
|
||||
.timeout(Duration.ofSeconds(30))
|
||||
.header("Content-Type", "application/json");
|
||||
|
||||
if (apiKey != null) {
|
||||
builder.header("Authorization", "Bearer " + apiKey);
|
||||
}
|
||||
|
||||
if (body != null) {
|
||||
builder.method(method, HttpRequest.BodyPublishers.ofString(body));
|
||||
} else {
|
||||
builder.method(method, HttpRequest.BodyPublishers.noBody());
|
||||
}
|
||||
|
||||
return httpClient.sendAsync(builder.build(), HttpResponse.BodyHandlers.ofString())
|
||||
.thenApply(HttpResponse::body);
|
||||
}
|
||||
|
||||
private IRUOffering mapToOffering(Map<String, Object> map) {
|
||||
return new IRUOffering(
|
||||
(String) map.get("id"),
|
||||
(String) map.get("offeringId"),
|
||||
(String) map.get("name"),
|
||||
(String) map.get("description"),
|
||||
((Number) map.get("capacityTier")).intValue(),
|
||||
(String) map.get("institutionalType"),
|
||||
map.get("basePrice") != null ? ((Number) map.get("basePrice")).doubleValue() : null,
|
||||
(String) map.get("currency")
|
||||
);
|
||||
}
|
||||
}
|
||||
10
sdk/python/dbis_iru/__init__.py
Normal file
10
sdk/python/dbis_iru/__init__.py
Normal file
@@ -0,0 +1,10 @@
|
||||
"""
|
||||
DBIS IRU Python SDK
|
||||
Client library for IRU integration
|
||||
"""
|
||||
|
||||
from .client import IRUClient
|
||||
from .types import IRUOffering, IRUInquiry, IRUSubscription
|
||||
|
||||
__version__ = "1.0.0"
|
||||
__all__ = ["IRUClient", "IRUOffering", "IRUInquiry", "IRUSubscription"]
|
||||
219
sdk/python/dbis_iru/client.py
Normal file
219
sdk/python/dbis_iru/client.py
Normal file
@@ -0,0 +1,219 @@
|
||||
"""
|
||||
DBIS IRU Python Client
|
||||
"""
|
||||
|
||||
import requests
|
||||
from typing import Optional, Dict, Any, List
|
||||
from .types import IRUOffering, IRUInquiry, IRUSubscription
|
||||
|
||||
|
||||
class IRUClient:
|
||||
"""Client for DBIS IRU API"""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
api_base_url: str,
|
||||
api_key: Optional[str] = None,
|
||||
timeout: int = 30
|
||||
):
|
||||
"""
|
||||
Initialize IRU Client
|
||||
|
||||
Args:
|
||||
api_base_url: Base URL for DBIS API
|
||||
api_key: API key for authentication (optional)
|
||||
timeout: Request timeout in seconds
|
||||
"""
|
||||
self.api_base_url = api_base_url.rstrip('/')
|
||||
self.api_key = api_key
|
||||
self.timeout = timeout
|
||||
self.session = requests.Session()
|
||||
|
||||
if api_key:
|
||||
self.session.headers.update({
|
||||
'Authorization': f'Bearer {api_key}'
|
||||
})
|
||||
|
||||
self.session.headers.update({
|
||||
'Content-Type': 'application/json'
|
||||
})
|
||||
|
||||
def get_offerings(
|
||||
self,
|
||||
capacity_tier: Optional[int] = None,
|
||||
institutional_type: Optional[str] = None
|
||||
) -> List[IRUOffering]:
|
||||
"""
|
||||
Get all IRU offerings
|
||||
|
||||
Args:
|
||||
capacity_tier: Filter by capacity tier (1-5)
|
||||
institutional_type: Filter by institutional type
|
||||
|
||||
Returns:
|
||||
List of IRU offerings
|
||||
"""
|
||||
params = {}
|
||||
if capacity_tier:
|
||||
params['capacityTier'] = capacity_tier
|
||||
if institutional_type:
|
||||
params['institutionalType'] = institutional_type
|
||||
|
||||
response = self._request(
|
||||
'GET',
|
||||
'/api/v1/iru/marketplace/offerings',
|
||||
params=params
|
||||
)
|
||||
|
||||
return response['data']
|
||||
|
||||
def get_offering(self, offering_id: str) -> IRUOffering:
|
||||
"""
|
||||
Get offering by ID
|
||||
|
||||
Args:
|
||||
offering_id: Offering ID
|
||||
|
||||
Returns:
|
||||
IRU offering details
|
||||
"""
|
||||
response = self._request(
|
||||
'GET',
|
||||
f'/api/v1/iru/marketplace/offerings/{offering_id}'
|
||||
)
|
||||
|
||||
return response['data']
|
||||
|
||||
def submit_inquiry(self, inquiry: IRUInquiry) -> Dict[str, Any]:
|
||||
"""
|
||||
Submit initial inquiry
|
||||
|
||||
Args:
|
||||
inquiry: Inquiry details
|
||||
|
||||
Returns:
|
||||
Inquiry result with inquiry ID and status
|
||||
"""
|
||||
response = self._request(
|
||||
'POST',
|
||||
'/api/v1/iru/marketplace/inquiries',
|
||||
json=inquiry.dict()
|
||||
)
|
||||
|
||||
return response['data']
|
||||
|
||||
def get_inquiry_status(self, inquiry_id: str) -> Dict[str, Any]:
|
||||
"""
|
||||
Get inquiry status
|
||||
|
||||
Args:
|
||||
inquiry_id: Inquiry ID
|
||||
|
||||
Returns:
|
||||
Inquiry status details
|
||||
"""
|
||||
response = self._request(
|
||||
'GET',
|
||||
f'/api/v1/iru/marketplace/inquiries/{inquiry_id}'
|
||||
)
|
||||
|
||||
return response['data']
|
||||
|
||||
def calculate_pricing(
|
||||
self,
|
||||
offering_id: str,
|
||||
usage_profile: Optional[Dict[str, Any]] = None
|
||||
) -> Dict[str, Any]:
|
||||
"""
|
||||
Calculate pricing for an offering
|
||||
|
||||
Args:
|
||||
offering_id: Offering ID
|
||||
usage_profile: Optional usage profile
|
||||
|
||||
Returns:
|
||||
Pricing breakdown
|
||||
"""
|
||||
params = {}
|
||||
if usage_profile:
|
||||
import json
|
||||
params['usageProfile'] = json.dumps(usage_profile)
|
||||
|
||||
response = self._request(
|
||||
'GET',
|
||||
f'/api/v1/iru/marketplace/offerings/{offering_id}/pricing',
|
||||
params=params
|
||||
)
|
||||
|
||||
return response['data']
|
||||
|
||||
def get_dashboard(self) -> Dict[str, Any]:
|
||||
"""
|
||||
Get participant dashboard
|
||||
|
||||
Returns:
|
||||
Dashboard data
|
||||
"""
|
||||
response = self._request(
|
||||
'GET',
|
||||
'/api/v1/iru/portal/dashboard'
|
||||
)
|
||||
|
||||
return response['data']
|
||||
|
||||
def get_service_health(self, subscription_id: str) -> Dict[str, Any]:
|
||||
"""
|
||||
Get service health
|
||||
|
||||
Args:
|
||||
subscription_id: Subscription ID
|
||||
|
||||
Returns:
|
||||
Service health data
|
||||
"""
|
||||
response = self._request(
|
||||
'GET',
|
||||
f'/api/v1/iru/portal/monitoring/{subscription_id}/health'
|
||||
)
|
||||
|
||||
return response['data']
|
||||
|
||||
def get_deployment_status(self, subscription_id: str) -> Dict[str, Any]:
|
||||
"""
|
||||
Get deployment status
|
||||
|
||||
Args:
|
||||
subscription_id: Subscription ID
|
||||
|
||||
Returns:
|
||||
Deployment status
|
||||
"""
|
||||
response = self._request(
|
||||
'GET',
|
||||
f'/api/v1/iru/portal/deployment/{subscription_id}'
|
||||
)
|
||||
|
||||
return response['data']
|
||||
|
||||
def _request(
|
||||
self,
|
||||
method: str,
|
||||
path: str,
|
||||
params: Optional[Dict[str, Any]] = None,
|
||||
json: Optional[Dict[str, Any]] = None
|
||||
) -> Dict[str, Any]:
|
||||
"""Make HTTP request"""
|
||||
url = f"{self.api_base_url}{path}"
|
||||
|
||||
try:
|
||||
response = self.session.request(
|
||||
method=method,
|
||||
url=url,
|
||||
params=params,
|
||||
json=json,
|
||||
timeout=self.timeout
|
||||
)
|
||||
response.raise_for_status()
|
||||
return response.json()
|
||||
except requests.exceptions.RequestException as e:
|
||||
raise Exception(f"API request failed: {str(e)}")
|
||||
89
sdk/python/dbis_iru/types.py
Normal file
89
sdk/python/dbis_iru/types.py
Normal file
@@ -0,0 +1,89 @@
|
||||
"""
|
||||
DBIS IRU Types
|
||||
"""
|
||||
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional
|
||||
from datetime import datetime
|
||||
|
||||
|
||||
@dataclass
|
||||
class IRUOffering:
|
||||
"""IRU Offering"""
|
||||
id: str
|
||||
offering_id: str
|
||||
name: str
|
||||
description: Optional[str] = None
|
||||
capacity_tier: int = 3
|
||||
institutional_type: str = "CommercialBank"
|
||||
base_price: Optional[float] = None
|
||||
currency: str = "USD"
|
||||
|
||||
def dict(self):
|
||||
"""Convert to dictionary"""
|
||||
return {
|
||||
'id': self.id,
|
||||
'offeringId': self.offering_id,
|
||||
'name': self.name,
|
||||
'description': self.description,
|
||||
'capacityTier': self.capacity_tier,
|
||||
'institutionalType': self.institutional_type,
|
||||
'basePrice': self.base_price,
|
||||
'currency': self.currency,
|
||||
}
|
||||
|
||||
|
||||
@dataclass
|
||||
class IRUInquiry:
|
||||
"""IRU Inquiry"""
|
||||
offering_id: str
|
||||
organization_name: str
|
||||
institutional_type: str
|
||||
jurisdiction: str
|
||||
contact_email: str
|
||||
contact_phone: Optional[str] = None
|
||||
contact_name: str = ""
|
||||
estimated_volume: Optional[str] = None
|
||||
expected_go_live: Optional[datetime] = None
|
||||
|
||||
def dict(self):
|
||||
"""Convert to dictionary"""
|
||||
data = {
|
||||
'offeringId': self.offering_id,
|
||||
'organizationName': self.organization_name,
|
||||
'institutionalType': self.institutional_type,
|
||||
'jurisdiction': self.jurisdiction,
|
||||
'contactEmail': self.contact_email,
|
||||
'contactName': self.contact_name,
|
||||
}
|
||||
|
||||
if self.contact_phone:
|
||||
data['contactPhone'] = self.contact_phone
|
||||
if self.estimated_volume:
|
||||
data['estimatedVolume'] = self.estimated_volume
|
||||
if self.expected_go_live:
|
||||
data['expectedGoLive'] = self.expected_go_live.isoformat()
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@dataclass
|
||||
class IRUSubscription:
|
||||
"""IRU Subscription"""
|
||||
subscription_id: str
|
||||
offering_id: str
|
||||
subscription_status: str
|
||||
activation_date: Optional[datetime] = None
|
||||
|
||||
def dict(self):
|
||||
"""Convert to dictionary"""
|
||||
data = {
|
||||
'subscriptionId': self.subscription_id,
|
||||
'offeringId': self.offering_id,
|
||||
'subscriptionStatus': self.subscription_status,
|
||||
}
|
||||
|
||||
if self.activation_date:
|
||||
data['activationDate'] = self.activation_date.isoformat()
|
||||
|
||||
return data
|
||||
41
sdk/python/setup.py
Normal file
41
sdk/python/setup.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
DBIS IRU Python SDK Setup
|
||||
"""
|
||||
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
with open("README.md", "r", encoding="utf-8") as fh:
|
||||
long_description = fh.read()
|
||||
|
||||
setup(
|
||||
name="dbis-iru-sdk",
|
||||
version="1.0.0",
|
||||
author="DBIS",
|
||||
description="DBIS IRU Python SDK",
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
url="https://github.com/dbis/iru-sdk-python",
|
||||
packages=find_packages(),
|
||||
classifiers=[
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Financial and Insurance Industry",
|
||||
"License :: OSI Approved :: MIT License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: 3.11",
|
||||
],
|
||||
python_requires=">=3.8",
|
||||
install_requires=[
|
||||
"requests>=2.28.0",
|
||||
],
|
||||
extras_require={
|
||||
"dev": [
|
||||
"pytest>=7.0.0",
|
||||
"pytest-cov>=4.0.0",
|
||||
"black>=22.0.0",
|
||||
"mypy>=1.0.0",
|
||||
],
|
||||
},
|
||||
)
|
||||
33
sdk/typescript/package.json
Normal file
33
sdk/typescript/package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@dbis/iru-sdk",
|
||||
"version": "1.0.0",
|
||||
"description": "DBIS IRU TypeScript/JavaScript SDK",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
"scripts": {
|
||||
"build": "tsc",
|
||||
"test": "jest",
|
||||
"lint": "eslint src/**/*.ts"
|
||||
},
|
||||
"keywords": [
|
||||
"dbis",
|
||||
"iru",
|
||||
"banking",
|
||||
"sdk"
|
||||
],
|
||||
"author": "DBIS",
|
||||
"license": "MIT",
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.0.0",
|
||||
"typescript": "^5.0.0",
|
||||
"jest": "^29.0.0",
|
||||
"@types/jest": "^29.0.0",
|
||||
"eslint": "^8.0.0",
|
||||
"@typescript-eslint/eslint-plugin": "^6.0.0",
|
||||
"@typescript-eslint/parser": "^6.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"typescript": ">=4.0.0"
|
||||
}
|
||||
}
|
||||
204
sdk/typescript/src/index.ts
Normal file
204
sdk/typescript/src/index.ts
Normal file
@@ -0,0 +1,204 @@
|
||||
// DBIS IRU TypeScript/JavaScript SDK
|
||||
// Client library for IRU integration
|
||||
|
||||
export interface IRUClientConfig {
|
||||
apiBaseUrl: string;
|
||||
apiKey?: string;
|
||||
timeout?: number;
|
||||
}
|
||||
|
||||
export interface IRUOffering {
|
||||
id: string;
|
||||
offeringId: string;
|
||||
name: string;
|
||||
description?: string;
|
||||
capacityTier: number;
|
||||
institutionalType: string;
|
||||
basePrice?: number;
|
||||
currency: string;
|
||||
}
|
||||
|
||||
export interface IRUInquiry {
|
||||
offeringId: string;
|
||||
organizationName: string;
|
||||
institutionalType: string;
|
||||
jurisdiction: string;
|
||||
contactEmail: string;
|
||||
contactPhone?: string;
|
||||
contactName: string;
|
||||
estimatedVolume?: string;
|
||||
expectedGoLive?: Date;
|
||||
}
|
||||
|
||||
export interface IRUSubscription {
|
||||
subscriptionId: string;
|
||||
offeringId: string;
|
||||
subscriptionStatus: string;
|
||||
activationDate?: Date;
|
||||
}
|
||||
|
||||
export class IRUClient {
|
||||
private config: IRUClientConfig;
|
||||
private baseUrl: string;
|
||||
|
||||
constructor(config: IRUClientConfig) {
|
||||
this.config = {
|
||||
timeout: 30000,
|
||||
...config,
|
||||
};
|
||||
this.baseUrl = config.apiBaseUrl.replace(/\/$/, '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all IRU offerings
|
||||
*/
|
||||
async getOfferings(filters?: {
|
||||
capacityTier?: number;
|
||||
institutionalType?: string;
|
||||
}): Promise<IRUOffering[]> {
|
||||
const params = new URLSearchParams();
|
||||
if (filters?.capacityTier) {
|
||||
params.append('capacityTier', filters.capacityTier.toString());
|
||||
}
|
||||
if (filters?.institutionalType) {
|
||||
params.append('institutionalType', filters.institutionalType);
|
||||
}
|
||||
|
||||
const response = await this.request<{ success: boolean; data: IRUOffering[] }>(
|
||||
`/api/v1/iru/marketplace/offerings${params.toString() ? `?${params.toString()}` : ''}`
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get offering by ID
|
||||
*/
|
||||
async getOffering(offeringId: string): Promise<IRUOffering> {
|
||||
const response = await this.request<{ success: boolean; data: IRUOffering }>(
|
||||
`/api/v1/iru/marketplace/offerings/${offeringId}`
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Submit inquiry
|
||||
*/
|
||||
async submitInquiry(inquiry: IRUInquiry): Promise<{ inquiryId: string; status: string; message: string }> {
|
||||
const response = await this.request<{ success: boolean; data: { inquiryId: string; status: string; message: string } }>(
|
||||
'/api/v1/iru/marketplace/inquiries',
|
||||
{
|
||||
method: 'POST',
|
||||
body: JSON.stringify(inquiry),
|
||||
}
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get inquiry status
|
||||
*/
|
||||
async getInquiryStatus(inquiryId: string): Promise<any> {
|
||||
const response = await this.request<{ success: boolean; data: any }>(
|
||||
`/api/v1/iru/marketplace/inquiries/${inquiryId}`
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate pricing
|
||||
*/
|
||||
async calculatePricing(offeringId: string, usageProfile?: any): Promise<any> {
|
||||
const params = usageProfile ? `?usageProfile=${encodeURIComponent(JSON.stringify(usageProfile))}` : '';
|
||||
const response = await this.request<{ success: boolean; data: any }>(
|
||||
`/api/v1/iru/marketplace/offerings/${offeringId}/pricing${params}`
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get dashboard
|
||||
*/
|
||||
async getDashboard(): Promise<any> {
|
||||
const response = await this.request<{ success: boolean; data: any }>(
|
||||
'/api/v1/iru/portal/dashboard'
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get service health
|
||||
*/
|
||||
async getServiceHealth(subscriptionId: string): Promise<any> {
|
||||
const response = await this.request<{ success: boolean; data: any }>(
|
||||
`/api/v1/iru/portal/monitoring/${subscriptionId}/health`
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get deployment status
|
||||
*/
|
||||
async getDeploymentStatus(subscriptionId: string): Promise<any> {
|
||||
const response = await this.request<{ success: boolean; data: any }>(
|
||||
`/api/v1/iru/portal/deployment/${subscriptionId}`
|
||||
);
|
||||
|
||||
return response.data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make HTTP request
|
||||
*/
|
||||
private async request<T>(path: string, options: RequestInit = {}): Promise<T> {
|
||||
const url = `${this.baseUrl}${path}`;
|
||||
const headers: HeadersInit = {
|
||||
'Content-Type': 'application/json',
|
||||
...options.headers,
|
||||
};
|
||||
|
||||
if (this.config.apiKey) {
|
||||
headers['Authorization'] = `Bearer ${this.config.apiKey}`;
|
||||
}
|
||||
|
||||
const controller = new AbortController();
|
||||
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
||||
|
||||
try {
|
||||
const response = await fetch(url, {
|
||||
...options,
|
||||
headers,
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
if (!response.ok) {
|
||||
const error = await response.json().catch(() => ({ message: response.statusText }));
|
||||
throw new Error(error.message || `HTTP ${response.status}`);
|
||||
}
|
||||
|
||||
return await response.json();
|
||||
} catch (error) {
|
||||
clearTimeout(timeoutId);
|
||||
if (error instanceof Error && error.name === 'AbortError') {
|
||||
throw new Error('Request timeout');
|
||||
}
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Export convenience function
|
||||
export function createIRUClient(config: IRUClientConfig): IRUClient {
|
||||
return new IRUClient(config);
|
||||
}
|
||||
|
||||
// Default export
|
||||
export default IRUClient;
|
||||
Reference in New Issue
Block a user