132 lines
3.2 KiB
TypeScript
132 lines
3.2 KiB
TypeScript
import { Injectable } from "@nestjs/common";
|
|
import { FreebitOrchestratorService } from "./services/freebit-orchestrator.service";
|
|
import type {
|
|
SimDetails,
|
|
SimUsage,
|
|
SimTopUpHistory,
|
|
} from "./interfaces/freebit.types";
|
|
import type { MnpData } from "@customer-portal/domain";
|
|
|
|
@Injectable()
|
|
export class FreebitService {
|
|
constructor(
|
|
private readonly orchestrator: FreebitOrchestratorService
|
|
) {}
|
|
|
|
/**
|
|
* Get SIM account details
|
|
*/
|
|
async getSimDetails(account: string): Promise<SimDetails> {
|
|
return this.orchestrator.getSimDetails(account);
|
|
}
|
|
|
|
/**
|
|
* Get SIM usage information
|
|
*/
|
|
async getSimUsage(account: string): Promise<SimUsage> {
|
|
return this.orchestrator.getSimUsage(account);
|
|
}
|
|
|
|
/**
|
|
* Top up SIM data quota
|
|
*/
|
|
async topUpSim(
|
|
account: string,
|
|
quotaMb: number,
|
|
options: { description?: string } = {}
|
|
): Promise<void> {
|
|
return this.orchestrator.topUpSim(account, quotaMb, options);
|
|
}
|
|
|
|
/**
|
|
* Get SIM top-up history
|
|
*/
|
|
async getSimTopUpHistory(
|
|
account: string,
|
|
fromDate: string,
|
|
toDate: string
|
|
): Promise<SimTopUpHistory> {
|
|
return this.orchestrator.getSimTopUpHistory(account, fromDate, toDate);
|
|
}
|
|
|
|
/**
|
|
* Change SIM plan
|
|
*/
|
|
async changeSimPlan(
|
|
account: string,
|
|
newPlanCode: string,
|
|
options: { assignGlobalIp?: boolean; scheduledAt?: string } = {}
|
|
): Promise<{ ipv4?: string; ipv6?: string }> {
|
|
return this.orchestrator.changeSimPlan(account, newPlanCode, options);
|
|
}
|
|
|
|
/**
|
|
* Update SIM features
|
|
*/
|
|
async updateSimFeatures(
|
|
account: string,
|
|
features: {
|
|
voiceMailEnabled?: boolean;
|
|
callWaitingEnabled?: boolean;
|
|
internationalRoamingEnabled?: boolean;
|
|
networkType?: "4G" | "5G";
|
|
}
|
|
): Promise<void> {
|
|
return this.orchestrator.updateSimFeatures(account, features);
|
|
}
|
|
|
|
/**
|
|
* Cancel SIM service
|
|
*/
|
|
async cancelSim(account: string, scheduledAt?: string): Promise<void> {
|
|
return this.orchestrator.cancelSim(account, scheduledAt);
|
|
}
|
|
|
|
/**
|
|
* Reissue eSIM profile (simple)
|
|
*/
|
|
async reissueEsimProfile(account: string): Promise<void> {
|
|
return this.orchestrator.reissueEsimProfile(account);
|
|
}
|
|
|
|
/**
|
|
* Reissue eSIM profile with enhanced options
|
|
*/
|
|
async reissueEsimProfileEnhanced(
|
|
account: string,
|
|
newEid: string,
|
|
options: { oldEid?: string; planCode?: string } = {}
|
|
): Promise<void> {
|
|
return this.orchestrator.reissueEsimProfileEnhanced(account, newEid, options);
|
|
}
|
|
|
|
/**
|
|
* Health check
|
|
*/
|
|
async healthCheck(): Promise<boolean> {
|
|
return this.orchestrator.healthCheck();
|
|
}
|
|
|
|
/**
|
|
* Activate eSIM account (for backward compatibility)
|
|
*/
|
|
async activateEsimAccountNew(params: {
|
|
account: string;
|
|
eid: string;
|
|
planSku: string;
|
|
simType: "eSIM" | "Physical SIM";
|
|
activationType: "Immediate" | "Scheduled";
|
|
scheduledAt?: string;
|
|
mnp?: MnpData;
|
|
}): Promise<void> {
|
|
// For eSIM, use the enhanced reissue method
|
|
if (params.simType === "eSIM") {
|
|
return this.orchestrator.reissueEsimProfileEnhanced(params.account, params.eid, {
|
|
planCode: params.planSku,
|
|
});
|
|
}
|
|
|
|
// For Physical SIM, this would be a different operation
|
|
throw new Error("Physical SIM activation not implemented in this method");
|
|
}
|
|
} |