- Rename integration orchestrators to facades: - WhmcsConnectionOrchestratorService → WhmcsConnectionFacade - FreebitOperationsService → FreebitFacade - SalesforceService → SalesforceFacade - Rename module orchestrator: - SimOrchestratorService → SimOrchestrator - Rename aggregators for clarity: - MeStatusService → MeStatusAggregator - UserProfileService → UserProfileAggregator - Move integration facades to dedicated facades/ folders: - whmcs/facades/whmcs.facade.ts - salesforce/facades/salesforce.facade.ts - freebit/facades/freebit.facade.ts This establishes clearer architectural boundaries between: - Facades: unified entry points for integration subsystems - Orchestrators: coordinate workflows across multiple services - Aggregators: read-only data composition from multiple sources Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
125 lines
3.3 KiB
TypeScript
125 lines
3.3 KiB
TypeScript
import { Injectable } from "@nestjs/common";
|
|
import { SimOrchestrator } from "./sim-management/services/sim-orchestrator.service.js";
|
|
import type {
|
|
SimDetails,
|
|
SimUsage,
|
|
SimTopUpHistory,
|
|
SimTopUpRequest,
|
|
SimPlanChangeRequest,
|
|
SimCancelRequest,
|
|
SimTopUpHistoryRequest,
|
|
SimFeaturesUpdateRequest,
|
|
SimReissueRequest,
|
|
} from "@customer-portal/domain/sim";
|
|
|
|
@Injectable()
|
|
export class SimManagementService {
|
|
constructor(private readonly simOrchestrator: SimOrchestrator) {}
|
|
|
|
/**
|
|
* Debug method to check subscription data for SIM services
|
|
*/
|
|
async debugSimSubscription(
|
|
userId: string,
|
|
subscriptionId: number
|
|
): Promise<Record<string, unknown>> {
|
|
return this.simOrchestrator.debugSimSubscription(userId, subscriptionId);
|
|
}
|
|
|
|
/**
|
|
* Debug method to query Freebit directly for any account's details
|
|
*/
|
|
async getSimDetailsDebug(account: string): Promise<SimDetails> {
|
|
return this.simOrchestrator.getSimDetailsDirectly(account);
|
|
}
|
|
|
|
// This method is now handled by SimValidationService internally
|
|
|
|
/**
|
|
* Get SIM details for a subscription
|
|
*/
|
|
async getSimDetails(userId: string, subscriptionId: number): Promise<SimDetails> {
|
|
return this.simOrchestrator.getSimDetails(userId, subscriptionId);
|
|
}
|
|
|
|
/**
|
|
* Get SIM data usage for a subscription
|
|
*/
|
|
async getSimUsage(userId: string, subscriptionId: number): Promise<SimUsage> {
|
|
return this.simOrchestrator.getSimUsage(userId, subscriptionId);
|
|
}
|
|
|
|
/**
|
|
* Top up SIM data quota with payment processing
|
|
* Pricing: 1GB = 500 JPY
|
|
*/
|
|
async topUpSim(userId: string, subscriptionId: number, request: SimTopUpRequest): Promise<void> {
|
|
return this.simOrchestrator.topUpSim(userId, subscriptionId, request);
|
|
}
|
|
|
|
/**
|
|
* Get SIM top-up history
|
|
*/
|
|
async getSimTopUpHistory(
|
|
userId: string,
|
|
subscriptionId: number,
|
|
request: SimTopUpHistoryRequest
|
|
): Promise<SimTopUpHistory> {
|
|
return this.simOrchestrator.getSimTopUpHistory(userId, subscriptionId, request);
|
|
}
|
|
|
|
/**
|
|
* Change SIM plan
|
|
*/
|
|
async changeSimPlan(
|
|
userId: string,
|
|
subscriptionId: number,
|
|
request: SimPlanChangeRequest
|
|
): Promise<{ ipv4?: string; ipv6?: string }> {
|
|
return this.simOrchestrator.changeSimPlan(userId, subscriptionId, request);
|
|
}
|
|
|
|
/**
|
|
* Update SIM features (voicemail, call waiting, roaming, network type)
|
|
*/
|
|
async updateSimFeatures(
|
|
userId: string,
|
|
subscriptionId: number,
|
|
request: SimFeaturesUpdateRequest
|
|
): Promise<void> {
|
|
return this.simOrchestrator.updateSimFeatures(userId, subscriptionId, request);
|
|
}
|
|
|
|
/**
|
|
* Cancel SIM service
|
|
*/
|
|
async cancelSim(
|
|
userId: string,
|
|
subscriptionId: number,
|
|
request: SimCancelRequest = {}
|
|
): Promise<void> {
|
|
return this.simOrchestrator.cancelSim(userId, subscriptionId, request);
|
|
}
|
|
|
|
/**
|
|
* Reissue eSIM profile
|
|
*/
|
|
async reissueEsimProfile(userId: string, subscriptionId: number, newEid?: string): Promise<void> {
|
|
const request: SimReissueRequest = newEid ? { newEid } : {};
|
|
return this.simOrchestrator.reissueEsimProfile(userId, subscriptionId, request);
|
|
}
|
|
|
|
/**
|
|
* Get comprehensive SIM information (details + usage combined)
|
|
*/
|
|
async getSimInfo(
|
|
userId: string,
|
|
subscriptionId: number
|
|
): Promise<{
|
|
details: SimDetails;
|
|
usage: SimUsage;
|
|
}> {
|
|
return this.simOrchestrator.getSimInfo(userId, subscriptionId);
|
|
}
|
|
}
|