Refactor Freebit integration by removing the legacy FreebitService and updating module structure to utilize FreebitOrchestratorService. Streamline service dependencies and improve maintainability across various modules. Update import paths and clean up unused code to enhance overall organization.
This commit is contained in:
parent
9fafd227b9
commit
7703392f58
@ -1,27 +1,17 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { FreebitService } from "./freebit.service";
|
||||
import {
|
||||
FreebitAuthService,
|
||||
FreebitClientService,
|
||||
FreebitMapperService,
|
||||
FreebitOperationsService,
|
||||
FreebitOrchestratorService,
|
||||
} from "./services";
|
||||
import { FreebitOrchestratorService } from "./services/freebit-orchestrator.service";
|
||||
import { FreebitMapperService } from "./services/freebit-mapper.service";
|
||||
import { FreebitOperationsService } from "./services/freebit-operations.service";
|
||||
|
||||
@Module({
|
||||
providers: [
|
||||
// Core services
|
||||
FreebitAuthService,
|
||||
FreebitClientService,
|
||||
FreebitMapperService,
|
||||
FreebitOperationsService,
|
||||
FreebitOrchestratorService,
|
||||
|
||||
// Main service (for backward compatibility)
|
||||
FreebitService,
|
||||
],
|
||||
exports: [
|
||||
FreebitService,
|
||||
// Export orchestrator in case other services need direct access
|
||||
FreebitOrchestratorService,
|
||||
],
|
||||
|
||||
@ -1,132 +0,0 @@
|
||||
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");
|
||||
}
|
||||
}
|
||||
@ -9,7 +9,7 @@ import {
|
||||
type AccountData,
|
||||
type UpsertResult,
|
||||
} from "./services/salesforce-account.service";
|
||||
import type { SalesforceAccountRecord } from "@customer-portal/domain";
|
||||
import type { SalesforceAccountRecord, SalesforceOrderRecord } from "@customer-portal/domain";
|
||||
|
||||
/**
|
||||
* Clean Salesforce Service - Only includes actually used functionality
|
||||
@ -74,13 +74,13 @@ export class SalesforceService implements OnModuleInit {
|
||||
return this.accountService.getById(accountId);
|
||||
}
|
||||
|
||||
async updateAccount(accountId: string, updates: Record<string, unknown>): Promise<void> {
|
||||
async updateAccount(accountId: string, updates: Partial<SalesforceAccountRecord>): Promise<void> {
|
||||
return this.accountService.update(accountId, updates);
|
||||
}
|
||||
|
||||
// === ORDER METHODS (For Order Provisioning) ===
|
||||
|
||||
async updateOrder(orderData: { Id: string; [key: string]: unknown }): Promise<void> {
|
||||
async updateOrder(orderData: Partial<SalesforceOrderRecord> & { Id: string }): Promise<void> {
|
||||
try {
|
||||
if (!this.connection.isConnected()) {
|
||||
throw new Error("Salesforce connection not available");
|
||||
@ -110,7 +110,7 @@ export class SalesforceService implements OnModuleInit {
|
||||
}
|
||||
}
|
||||
|
||||
async getOrder(orderId: string): Promise<Record<string, unknown> | null> {
|
||||
async getOrder(orderId: string): Promise<SalesforceOrderRecord | null> {
|
||||
try {
|
||||
if (!this.connection.isConnected()) {
|
||||
throw new Error("Salesforce connection not available");
|
||||
@ -124,7 +124,7 @@ export class SalesforceService implements OnModuleInit {
|
||||
FROM Order
|
||||
WHERE Id = '${orderId}'
|
||||
LIMIT 1`
|
||||
)) as { records: Record<string, unknown>[]; totalSize: number };
|
||||
)) as { records: SalesforceOrderRecord[]; totalSize: number };
|
||||
|
||||
return result.records?.[0] || null;
|
||||
} catch (error) {
|
||||
|
||||
@ -140,7 +140,7 @@ export class SalesforceAccountService {
|
||||
}
|
||||
}
|
||||
|
||||
async update(accountId: string, updates: Record<string, unknown>): Promise<void> {
|
||||
async update(accountId: string, updates: Partial<SalesforceAccountRecord>): Promise<void> {
|
||||
const validAccountId = this.validateId(accountId);
|
||||
|
||||
try {
|
||||
|
||||
@ -218,7 +218,7 @@ export class SalesforceConnection {
|
||||
|
||||
// Return a wrapper that handles session expiration for SObject operations
|
||||
return {
|
||||
create: async (data: Record<string, unknown>) => {
|
||||
create: async (data: object) => {
|
||||
try {
|
||||
if (!this.isConnected()) {
|
||||
this.logger.warn("Salesforce not connected; attempting to establish connection");
|
||||
@ -247,7 +247,7 @@ export class SalesforceConnection {
|
||||
}
|
||||
},
|
||||
|
||||
update: async (data: Record<string, unknown> & { Id: string }) => {
|
||||
update: async (data: object & { Id: string }) => {
|
||||
try {
|
||||
if (!this.isConnected()) {
|
||||
this.logger.warn("Salesforce not connected; attempting to establish connection");
|
||||
|
||||
@ -206,10 +206,6 @@ export class WhmcsConnectionOrchestratorService implements OnModuleInit {
|
||||
return this.apiMethods.getPaymentMethods(params);
|
||||
}
|
||||
|
||||
// Legacy method name for backward compatibility
|
||||
async getPayMethods(params: WhmcsGetPayMethodsParams) {
|
||||
return this.getPaymentMethods(params);
|
||||
}
|
||||
|
||||
async getPaymentGateways() {
|
||||
return this.apiMethods.getPaymentGateways();
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { Injectable, NotFoundException, Inject } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
import { WhmcsConnectionService } from "./whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service";
|
||||
import { WhmcsCacheService } from "../cache/whmcs-cache.service";
|
||||
import {
|
||||
WhmcsValidateLoginParams,
|
||||
@ -12,7 +12,7 @@ import {
|
||||
@Injectable()
|
||||
export class WhmcsClientService {
|
||||
constructor(
|
||||
private readonly connectionService: WhmcsConnectionService,
|
||||
private readonly connectionService: WhmcsConnectionOrchestratorService,
|
||||
private readonly cacheService: WhmcsCacheService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
) {}
|
||||
|
||||
@ -1,197 +0,0 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service";
|
||||
import type {
|
||||
WhmcsInvoicesResponse,
|
||||
WhmcsInvoiceResponse,
|
||||
WhmcsProductsResponse,
|
||||
WhmcsClientResponse,
|
||||
WhmcsSsoResponse,
|
||||
WhmcsValidateLoginResponse,
|
||||
WhmcsAddClientResponse,
|
||||
WhmcsCatalogProductsResponse,
|
||||
WhmcsPayMethodsResponse,
|
||||
WhmcsPaymentGatewaysResponse,
|
||||
WhmcsCreateInvoiceResponse,
|
||||
WhmcsUpdateInvoiceResponse,
|
||||
WhmcsCapturePaymentResponse,
|
||||
WhmcsGetInvoicesParams,
|
||||
WhmcsGetClientsProductsParams,
|
||||
WhmcsCreateSsoTokenParams,
|
||||
WhmcsValidateLoginParams,
|
||||
WhmcsAddClientParams,
|
||||
WhmcsGetPayMethodsParams,
|
||||
WhmcsCreateInvoiceParams,
|
||||
WhmcsUpdateInvoiceParams,
|
||||
WhmcsCapturePaymentParams,
|
||||
} from "../types/whmcs-api.types";
|
||||
|
||||
// Re-export the config interface for backward compatibility
|
||||
export interface WhmcsApiConfig {
|
||||
baseUrl: string;
|
||||
identifier: string;
|
||||
secret: string;
|
||||
timeout?: number;
|
||||
retryAttempts?: number;
|
||||
retryDelay?: number;
|
||||
adminUsername?: string;
|
||||
adminPasswordHash?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* WHMCS Connection Service - now acts as a facade to the orchestrator service
|
||||
* Maintains backward compatibility while delegating to modular services
|
||||
*/
|
||||
@Injectable()
|
||||
export class WhmcsConnectionService {
|
||||
constructor(
|
||||
private readonly orchestrator: WhmcsConnectionOrchestratorService
|
||||
) {}
|
||||
|
||||
// ==========================================
|
||||
// HEALTH CHECK METHODS
|
||||
// ==========================================
|
||||
|
||||
async healthCheck(): Promise<boolean> {
|
||||
return this.orchestrator.healthCheck();
|
||||
}
|
||||
|
||||
async isAvailable(): Promise<boolean> {
|
||||
return this.orchestrator.isAvailable();
|
||||
}
|
||||
|
||||
async getSystemInfo(): Promise<unknown> {
|
||||
return this.orchestrator.getSystemInfo();
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// CLIENT API METHODS
|
||||
// ==========================================
|
||||
|
||||
async getClientDetails(clientId: number): Promise<WhmcsClientResponse> {
|
||||
return this.orchestrator.getClientDetails(clientId);
|
||||
}
|
||||
|
||||
async getClientDetailsByEmail(email: string): Promise<WhmcsClientResponse> {
|
||||
return this.orchestrator.getClientDetailsByEmail(email);
|
||||
}
|
||||
|
||||
async updateClient(
|
||||
clientId: number,
|
||||
updateData: Partial<WhmcsClientResponse["client"]>
|
||||
): Promise<{ result: string }> {
|
||||
return this.orchestrator.updateClient(clientId, updateData);
|
||||
}
|
||||
|
||||
async addClient(params: WhmcsAddClientParams): Promise<WhmcsAddClientResponse> {
|
||||
return this.orchestrator.addClient(params);
|
||||
}
|
||||
|
||||
async validateLogin(params: WhmcsValidateLoginParams): Promise<WhmcsValidateLoginResponse> {
|
||||
return this.orchestrator.validateLogin(params);
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// INVOICE API METHODS
|
||||
// ==========================================
|
||||
|
||||
async getInvoices(params: WhmcsGetInvoicesParams = {}): Promise<WhmcsInvoicesResponse> {
|
||||
return this.orchestrator.getInvoices(params);
|
||||
}
|
||||
|
||||
async getInvoice(invoiceId: number): Promise<WhmcsInvoiceResponse> {
|
||||
return this.orchestrator.getInvoice(invoiceId);
|
||||
}
|
||||
|
||||
async createInvoice(params: WhmcsCreateInvoiceParams): Promise<WhmcsCreateInvoiceResponse> {
|
||||
return this.orchestrator.createInvoice(params);
|
||||
}
|
||||
|
||||
async updateInvoice(params: WhmcsUpdateInvoiceParams): Promise<WhmcsUpdateInvoiceResponse> {
|
||||
return this.orchestrator.updateInvoice(params);
|
||||
}
|
||||
|
||||
async capturePayment(params: WhmcsCapturePaymentParams): Promise<WhmcsCapturePaymentResponse> {
|
||||
return this.orchestrator.capturePayment(params);
|
||||
}
|
||||
|
||||
|
||||
// ==========================================
|
||||
// PRODUCT/SUBSCRIPTION API METHODS
|
||||
// ==========================================
|
||||
|
||||
async getClientsProducts(params: WhmcsGetClientsProductsParams): Promise<WhmcsProductsResponse> {
|
||||
return this.orchestrator.getClientsProducts(params);
|
||||
}
|
||||
|
||||
async getCatalogProducts(): Promise<WhmcsCatalogProductsResponse> {
|
||||
return this.orchestrator.getCatalogProducts();
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// PAYMENT API METHODS
|
||||
// ==========================================
|
||||
|
||||
async getPaymentMethods(params: WhmcsGetPayMethodsParams): Promise<WhmcsPayMethodsResponse> {
|
||||
return this.orchestrator.getPaymentMethods(params);
|
||||
}
|
||||
|
||||
async getPaymentGateways(): Promise<WhmcsPaymentGatewaysResponse> {
|
||||
return this.orchestrator.getPaymentGateways();
|
||||
}
|
||||
|
||||
// Legacy method name for backward compatibility
|
||||
async getPayMethods(params: WhmcsGetPayMethodsParams): Promise<WhmcsPayMethodsResponse> {
|
||||
return this.getPaymentMethods(params);
|
||||
}
|
||||
|
||||
async getProducts(): Promise<WhmcsCatalogProductsResponse> {
|
||||
return this.orchestrator.getProducts() as Promise<WhmcsCatalogProductsResponse>;
|
||||
}
|
||||
|
||||
async addOrder(params: Record<string, unknown>) {
|
||||
return this.orchestrator.addOrder(params);
|
||||
}
|
||||
|
||||
async getOrders(params: Record<string, unknown> = {}) {
|
||||
return this.orchestrator.getOrders(params);
|
||||
}
|
||||
|
||||
async acceptOrder(orderId: number): Promise<{ result: string }> {
|
||||
return this.orchestrator.acceptOrder(orderId);
|
||||
}
|
||||
|
||||
async cancelOrder(orderId: number): Promise<{ result: string }> {
|
||||
return this.orchestrator.cancelOrder(orderId);
|
||||
}
|
||||
|
||||
getBaseUrl(): string {
|
||||
return this.orchestrator.getBaseUrl();
|
||||
}
|
||||
|
||||
// ==========================================
|
||||
// SSO API METHODS
|
||||
// ==========================================
|
||||
|
||||
async createSsoToken(params: WhmcsCreateSsoTokenParams): Promise<WhmcsSsoResponse> {
|
||||
return this.orchestrator.createSsoToken(params);
|
||||
}
|
||||
|
||||
|
||||
// ==========================================
|
||||
// UTILITY METHODS
|
||||
// ==========================================
|
||||
|
||||
/**
|
||||
* Get connection statistics
|
||||
*/
|
||||
getConnectionStats() {
|
||||
return this.orchestrator.getConnectionStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get configuration (sanitized for logging)
|
||||
*/
|
||||
getConfig() {
|
||||
return this.orchestrator.getConfig();
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@ import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { Injectable, NotFoundException, Inject } from "@nestjs/common";
|
||||
import { Invoice, InvoiceList, invoiceListSchema, invoiceSchema } from "@customer-portal/domain";
|
||||
import { WhmcsConnectionService } from "./whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service";
|
||||
import { InvoiceTransformerService } from "../transformers/services/invoice-transformer.service";
|
||||
import { WhmcsCacheService } from "../cache/whmcs-cache.service";
|
||||
import {
|
||||
@ -26,7 +26,7 @@ export interface InvoiceFilters {
|
||||
export class WhmcsInvoiceService {
|
||||
constructor(
|
||||
@Inject(Logger) private readonly logger: Logger,
|
||||
private readonly connectionService: WhmcsConnectionService,
|
||||
private readonly connectionService: WhmcsConnectionOrchestratorService,
|
||||
private readonly invoiceTransformer: InvoiceTransformerService,
|
||||
private readonly cacheService: WhmcsCacheService
|
||||
) {}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { WhmcsConnectionService } from "./whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
|
||||
export interface WhmcsOrderItem {
|
||||
@ -32,7 +32,7 @@ export interface WhmcsOrderResult {
|
||||
@Injectable()
|
||||
export class WhmcsOrderService {
|
||||
constructor(
|
||||
private readonly connection: WhmcsConnectionService,
|
||||
private readonly connection: WhmcsConnectionOrchestratorService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
) {}
|
||||
|
||||
@ -165,7 +165,7 @@ export class WhmcsOrderService {
|
||||
*/
|
||||
async hasPaymentMethod(clientId: number): Promise<boolean> {
|
||||
try {
|
||||
const response = (await this.connection.getPayMethods({
|
||||
const response = (await this.connection.getPaymentMethods({
|
||||
clientid: clientId,
|
||||
})) as unknown as Record<string, unknown>;
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@ import {
|
||||
PaymentGatewayList,
|
||||
PaymentMethod,
|
||||
} from "@customer-portal/domain";
|
||||
import { WhmcsConnectionService } from "./whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service";
|
||||
import { PaymentTransformerService } from "../transformers/services/payment-transformer.service";
|
||||
import { WhmcsCacheService } from "../cache/whmcs-cache.service";
|
||||
import type {
|
||||
@ -20,7 +20,7 @@ import type {
|
||||
export class WhmcsPaymentService {
|
||||
constructor(
|
||||
@Inject(Logger) private readonly logger: Logger,
|
||||
private readonly connectionService: WhmcsConnectionService,
|
||||
private readonly connectionService: WhmcsConnectionOrchestratorService,
|
||||
private readonly paymentTransformer: PaymentTransformerService,
|
||||
private readonly cacheService: WhmcsCacheService
|
||||
) {}
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { Injectable, Inject } from "@nestjs/common";
|
||||
import { WhmcsConnectionService } from "./whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service";
|
||||
import { WhmcsCreateSsoTokenParams } from "../types/whmcs-api.types";
|
||||
|
||||
@Injectable()
|
||||
export class WhmcsSsoService {
|
||||
constructor(
|
||||
@Inject(Logger) private readonly logger: Logger,
|
||||
private readonly connectionService: WhmcsConnectionService
|
||||
private readonly connectionService: WhmcsConnectionOrchestratorService
|
||||
) {}
|
||||
|
||||
/**
|
||||
|
||||
@ -2,7 +2,7 @@ import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { Injectable, NotFoundException, Inject } from "@nestjs/common";
|
||||
import { Subscription, SubscriptionList } from "@customer-portal/domain";
|
||||
import { WhmcsConnectionService } from "./whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "../connection/services/whmcs-connection-orchestrator.service";
|
||||
import { SubscriptionTransformerService } from "../transformers/services/subscription-transformer.service";
|
||||
import { WhmcsCacheService } from "../cache/whmcs-cache.service";
|
||||
import { WhmcsGetClientsProductsParams } from "../types/whmcs-api.types";
|
||||
@ -15,7 +15,7 @@ export interface SubscriptionFilters {
|
||||
export class WhmcsSubscriptionService {
|
||||
constructor(
|
||||
@Inject(Logger) private readonly logger: Logger,
|
||||
private readonly connectionService: WhmcsConnectionService,
|
||||
private readonly connectionService: WhmcsConnectionOrchestratorService,
|
||||
private readonly subscriptionTransformer: SubscriptionTransformerService,
|
||||
private readonly cacheService: WhmcsCacheService
|
||||
) {}
|
||||
|
||||
@ -40,12 +40,12 @@ export class SubscriptionTransformerService {
|
||||
const subscription: Subscription = {
|
||||
id: Number(whmcsProduct.id),
|
||||
serviceId: Number(whmcsProduct.id), // In WHMCS, product ID is the service ID
|
||||
productName: DataUtils.safeString(whmcsProduct.productname || whmcsProduct.name, "Unknown Product"),
|
||||
domain: DataUtils.safeString(whmcsProduct.domain),
|
||||
productName: whmcsProduct.productname || whmcsProduct.name,
|
||||
domain: whmcsProduct.domain,
|
||||
status: StatusNormalizer.normalizeProductStatus(whmcsProduct.status),
|
||||
cycle: normalizedCycle,
|
||||
amount: this.getProductAmount(whmcsProduct),
|
||||
currency: DataUtils.safeString(whmcsProduct.currencycode, "JPY"),
|
||||
currency: whmcsProduct.currencycode,
|
||||
nextDue: DataUtils.formatDate(whmcsProduct.nextduedate),
|
||||
registrationDate: DataUtils.formatDate(whmcsProduct.regdate) || new Date().toISOString(),
|
||||
customFields: this.extractCustomFields(whmcsProduct.customfields),
|
||||
@ -107,7 +107,7 @@ export class SubscriptionTransformerService {
|
||||
if (field && typeof field === "object" && field.name && field.value) {
|
||||
// Normalize field name (remove special characters, convert to camelCase)
|
||||
const normalizedName = this.normalizeFieldName(field.name);
|
||||
fields[normalizedName] = DataUtils.safeString(field.value);
|
||||
fields[normalizedName] = field.value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -141,36 +141,4 @@ export class DataUtils {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe string conversion with fallback
|
||||
*/
|
||||
static safeString(value: unknown, fallback = ""): string {
|
||||
if (value === null || value === undefined) return fallback;
|
||||
return String(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe number conversion with fallback
|
||||
*/
|
||||
static safeNumber(value: unknown, fallback = 0): number {
|
||||
if (typeof value === "number") return value;
|
||||
if (typeof value === "string") {
|
||||
const parsed = parseFloat(value);
|
||||
return isNaN(parsed) ? fallback : parsed;
|
||||
}
|
||||
return fallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Safe boolean conversion
|
||||
*/
|
||||
static safeBoolean(value: unknown): boolean {
|
||||
if (typeof value === "boolean") return value;
|
||||
if (typeof value === "string") {
|
||||
const lower = value.toLowerCase();
|
||||
return lower === "true" || lower === "1" || lower === "yes" || lower === "on";
|
||||
}
|
||||
if (typeof value === "number") return value !== 0;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ import { Module } from "@nestjs/common";
|
||||
import { ConfigModule } from "@nestjs/config";
|
||||
import { WhmcsCacheService } from "./cache/whmcs-cache.service";
|
||||
import { WhmcsService } from "./whmcs.service";
|
||||
import { WhmcsConnectionService } from "./services/whmcs-connection.service";
|
||||
import { WhmcsInvoiceService } from "./services/whmcs-invoice.service";
|
||||
import { WhmcsSubscriptionService } from "./services/whmcs-subscription.service";
|
||||
import { WhmcsClientService } from "./services/whmcs-client.service";
|
||||
@ -31,8 +30,6 @@ import { WhmcsApiMethodsService } from "./connection/services/whmcs-api-methods.
|
||||
SubscriptionTransformerService,
|
||||
PaymentTransformerService,
|
||||
TransformationValidator,
|
||||
// Legacy connection service (now facade)
|
||||
WhmcsConnectionService,
|
||||
// New modular connection services
|
||||
WhmcsConnectionOrchestratorService,
|
||||
WhmcsConfigService,
|
||||
@ -51,7 +48,6 @@ import { WhmcsApiMethodsService } from "./connection/services/whmcs-api-methods.
|
||||
],
|
||||
exports: [
|
||||
WhmcsService,
|
||||
WhmcsConnectionService,
|
||||
WhmcsConnectionOrchestratorService,
|
||||
WhmcsTransformerOrchestratorService,
|
||||
WhmcsCacheService,
|
||||
|
||||
@ -8,7 +8,7 @@ import type {
|
||||
PaymentMethodList,
|
||||
PaymentGatewayList,
|
||||
} from "@customer-portal/domain";
|
||||
import { WhmcsConnectionService } from "./services/whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "./connection/services/whmcs-connection-orchestrator.service";
|
||||
import type { Address } from "@customer-portal/domain";
|
||||
import { WhmcsInvoiceService, InvoiceFilters } from "./services/whmcs-invoice.service";
|
||||
import {
|
||||
@ -32,7 +32,7 @@ import { Logger } from "nestjs-pino";
|
||||
@Injectable()
|
||||
export class WhmcsService {
|
||||
constructor(
|
||||
private readonly connectionService: WhmcsConnectionService,
|
||||
private readonly connectionService: WhmcsConnectionOrchestratorService,
|
||||
private readonly invoiceService: WhmcsInvoiceService,
|
||||
private readonly subscriptionService: WhmcsSubscriptionService,
|
||||
private readonly clientService: WhmcsClientService,
|
||||
|
||||
@ -12,7 +12,7 @@ import {
|
||||
import { MappingsService } from "@bff/modules/id-mappings/mappings.service";
|
||||
import { SalesforceConnection } from "@bff/integrations/salesforce/services/salesforce-connection.service";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { WhmcsConnectionService } from "@bff/integrations/whmcs/services/whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "@bff/integrations/whmcs/connection/services/whmcs-connection-orchestrator.service";
|
||||
|
||||
@Injectable()
|
||||
export class SimCatalogService extends BaseCatalogService {
|
||||
@ -20,7 +20,7 @@ export class SimCatalogService extends BaseCatalogService {
|
||||
sf: SalesforceConnection,
|
||||
@Inject(Logger) logger: Logger,
|
||||
private mappingsService: MappingsService,
|
||||
private whmcs: WhmcsConnectionService
|
||||
private whmcs: WhmcsConnectionOrchestratorService
|
||||
) {
|
||||
super(sf, logger);
|
||||
}
|
||||
|
||||
@ -19,7 +19,9 @@ import {
|
||||
ApiBearerAuth,
|
||||
ApiParam,
|
||||
} from "@nestjs/swagger";
|
||||
import { InvoicesService } from "./invoices.service";
|
||||
import { InvoicesOrchestratorService } from "./services/invoices-orchestrator.service";
|
||||
import { WhmcsService } from "@bff/integrations/whmcs/whmcs.service";
|
||||
import { MappingsService } from "@bff/modules/id-mappings/mappings.service";
|
||||
|
||||
import type {
|
||||
Invoice,
|
||||
@ -39,7 +41,11 @@ interface AuthenticatedRequest {
|
||||
@Controller("invoices")
|
||||
@ApiBearerAuth()
|
||||
export class InvoicesController {
|
||||
constructor(private readonly invoicesService: InvoicesService) {}
|
||||
constructor(
|
||||
private readonly invoicesService: InvoicesOrchestratorService,
|
||||
private readonly whmcsService: WhmcsService,
|
||||
private readonly mappingsService: MappingsService
|
||||
) {}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({
|
||||
@ -104,7 +110,11 @@ export class InvoicesController {
|
||||
})
|
||||
@ApiOkResponse({ description: "List of payment methods" })
|
||||
async getPaymentMethods(@Request() req: AuthenticatedRequest): Promise<PaymentMethodList> {
|
||||
return this.invoicesService.getPaymentMethods(req.user.id);
|
||||
const mapping = await this.mappingsService.findByUserId(req.user.id);
|
||||
if (!mapping?.whmcsClientId) {
|
||||
throw new Error("WHMCS client mapping not found");
|
||||
}
|
||||
return this.whmcsService.getPaymentMethods(mapping.whmcsClientId, req.user.id);
|
||||
}
|
||||
|
||||
@Get("payment-gateways")
|
||||
@ -114,7 +124,7 @@ export class InvoicesController {
|
||||
})
|
||||
@ApiOkResponse({ description: "List of payment gateways" })
|
||||
async getPaymentGateways(): Promise<PaymentGatewayList> {
|
||||
return this.invoicesService.getPaymentGateways();
|
||||
return this.whmcsService.getPaymentGateways();
|
||||
}
|
||||
|
||||
@Post("payment-methods/refresh")
|
||||
@ -126,10 +136,14 @@ export class InvoicesController {
|
||||
@ApiOkResponse({ description: "Payment methods cache refreshed" })
|
||||
async refreshPaymentMethods(@Request() req: AuthenticatedRequest): Promise<PaymentMethodList> {
|
||||
// Invalidate cache first
|
||||
await this.invoicesService.invalidatePaymentMethodsCache(req.user.id);
|
||||
await this.whmcsService.invalidatePaymentMethodsCache(req.user.id);
|
||||
|
||||
// Return fresh payment methods
|
||||
return this.invoicesService.getPaymentMethods(req.user.id);
|
||||
const mapping = await this.mappingsService.findByUserId(req.user.id);
|
||||
if (!mapping?.whmcsClientId) {
|
||||
throw new Error("WHMCS client mapping not found");
|
||||
}
|
||||
return this.whmcsService.getPaymentMethods(mapping.whmcsClientId, req.user.id);
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
@ -201,7 +215,20 @@ export class InvoicesController {
|
||||
throw new BadRequestException('Target must be "view", "download", or "pay"');
|
||||
}
|
||||
|
||||
return this.invoicesService.createInvoiceSsoLink(req.user.id, invoiceId);
|
||||
const mapping = await this.mappingsService.findByUserId(req.user.id);
|
||||
if (!mapping?.whmcsClientId) {
|
||||
throw new Error("WHMCS client mapping not found");
|
||||
}
|
||||
|
||||
const ssoResult = await this.whmcsService.createSsoToken(
|
||||
mapping.whmcsClientId,
|
||||
invoiceId ? `index.php?rp=/invoice/${invoiceId}` : undefined
|
||||
);
|
||||
|
||||
return {
|
||||
url: ssoResult.url,
|
||||
expiresAt: ssoResult.expiresAt,
|
||||
};
|
||||
}
|
||||
|
||||
@Post(":id/payment-link")
|
||||
@ -241,12 +268,23 @@ export class InvoicesController {
|
||||
throw new BadRequestException("Payment method ID must be a positive number");
|
||||
}
|
||||
|
||||
return this.invoicesService.createInvoicePaymentLink(
|
||||
req.user.id,
|
||||
const mapping = await this.mappingsService.findByUserId(req.user.id);
|
||||
if (!mapping?.whmcsClientId) {
|
||||
throw new Error("WHMCS client mapping not found");
|
||||
}
|
||||
|
||||
const ssoResult = await this.whmcsService.createPaymentSsoToken(
|
||||
mapping.whmcsClientId,
|
||||
invoiceId,
|
||||
gatewayName || "stripe",
|
||||
"/"
|
||||
paymentMethodIdNum,
|
||||
gatewayName || "stripe"
|
||||
);
|
||||
|
||||
return {
|
||||
url: ssoResult.url,
|
||||
expiresAt: ssoResult.expiresAt,
|
||||
gatewayName: gatewayName || "stripe",
|
||||
};
|
||||
}
|
||||
|
||||
private validatePositiveInteger(
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import { Module } from "@nestjs/common";
|
||||
import { InvoicesController } from "./invoices.controller";
|
||||
import { InvoicesService } from "./invoices.service";
|
||||
import { WhmcsModule } from "@bff/integrations/whmcs/whmcs.module";
|
||||
import { MappingsModule } from "@bff/modules/id-mappings/mappings.module";
|
||||
// New modular invoice services
|
||||
@ -13,14 +12,12 @@ import { InvoiceValidatorService } from "./validators/invoice-validator.service"
|
||||
imports: [WhmcsModule, MappingsModule],
|
||||
controllers: [InvoicesController],
|
||||
providers: [
|
||||
// Legacy service (now facade)
|
||||
InvoicesService,
|
||||
// New modular services
|
||||
InvoicesOrchestratorService,
|
||||
InvoiceRetrievalService,
|
||||
InvoiceHealthService,
|
||||
InvoiceValidatorService,
|
||||
],
|
||||
exports: [InvoicesService, InvoicesOrchestratorService],
|
||||
exports: [InvoicesOrchestratorService],
|
||||
})
|
||||
export class InvoicesModule {}
|
||||
|
||||
@ -1,215 +0,0 @@
|
||||
import { Injectable } from "@nestjs/common";
|
||||
import { InvoicesOrchestratorService } from "./services/invoices-orchestrator.service";
|
||||
import { WhmcsService } from "@bff/integrations/whmcs/whmcs.service";
|
||||
import { MappingsService } from "@bff/modules/id-mappings/mappings.service";
|
||||
import type {
|
||||
Invoice,
|
||||
InvoiceList,
|
||||
InvoiceSsoLink,
|
||||
InvoicePaymentLink,
|
||||
PaymentMethodList,
|
||||
PaymentGatewayList,
|
||||
} from "@customer-portal/domain";
|
||||
|
||||
// Re-export the interface for backward compatibility
|
||||
export interface GetInvoicesOptions {
|
||||
page?: number;
|
||||
limit?: number;
|
||||
status?: "Paid" | "Unpaid" | "Cancelled" | "Overdue" | "Collections";
|
||||
}
|
||||
|
||||
/**
|
||||
* Invoices Service - now acts as a facade to the orchestrator service
|
||||
* Maintains backward compatibility while delegating to modular services
|
||||
*/
|
||||
@Injectable()
|
||||
export class InvoicesService {
|
||||
constructor(
|
||||
private readonly orchestrator: InvoicesOrchestratorService,
|
||||
private readonly whmcsService: WhmcsService,
|
||||
private readonly mappingsService: MappingsService
|
||||
) {}
|
||||
|
||||
/**
|
||||
* Get paginated invoices for a user
|
||||
*/
|
||||
async getInvoices(userId: string, options: GetInvoicesOptions = {}): Promise<InvoiceList> {
|
||||
return this.orchestrator.getInvoices(userId, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get individual invoice by ID
|
||||
*/
|
||||
async getInvoiceById(userId: string, invoiceId: number): Promise<Invoice> {
|
||||
return this.orchestrator.getInvoiceById(userId, invoiceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create SSO link for invoice management
|
||||
*/
|
||||
async createInvoiceSsoLink(userId: string, invoiceId?: number): Promise<InvoiceSsoLink> {
|
||||
const mapping = await this.mappingsService.findByUserId(userId);
|
||||
if (!mapping?.whmcsClientId) {
|
||||
throw new Error("WHMCS client mapping not found");
|
||||
}
|
||||
|
||||
const ssoResult = await this.whmcsService.createSsoToken(
|
||||
mapping.whmcsClientId,
|
||||
invoiceId ? `index.php?rp=/invoice/${invoiceId}` : undefined
|
||||
);
|
||||
|
||||
return {
|
||||
url: ssoResult.url,
|
||||
expiresAt: ssoResult.expiresAt,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get invoices by status
|
||||
*/
|
||||
async getInvoicesByStatus(
|
||||
userId: string,
|
||||
status: "Paid" | "Unpaid" | "Cancelled" | "Overdue" | "Collections",
|
||||
options: Pick<GetInvoicesOptions, "page" | "limit"> = {}
|
||||
): Promise<InvoiceList> {
|
||||
return this.orchestrator.getInvoicesByStatus(userId, status, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get unpaid invoices for a user
|
||||
*/
|
||||
async getUnpaidInvoices(
|
||||
userId: string,
|
||||
options: Pick<GetInvoicesOptions, "page" | "limit"> = {}
|
||||
): Promise<InvoiceList> {
|
||||
return this.orchestrator.getUnpaidInvoices(userId, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get overdue invoices for a user
|
||||
*/
|
||||
async getOverdueInvoices(
|
||||
userId: string,
|
||||
options: Pick<GetInvoicesOptions, "page" | "limit"> = {}
|
||||
): Promise<InvoiceList> {
|
||||
return this.orchestrator.getOverdueInvoices(userId, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get paid invoices for a user
|
||||
*/
|
||||
async getPaidInvoices(
|
||||
userId: string,
|
||||
options: Pick<GetInvoicesOptions, "page" | "limit"> = {}
|
||||
): Promise<InvoiceList> {
|
||||
return this.orchestrator.getPaidInvoices(userId, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get cancelled invoices for a user
|
||||
*/
|
||||
async getCancelledInvoices(
|
||||
userId: string,
|
||||
options: Pick<GetInvoicesOptions, "page" | "limit"> = {}
|
||||
): Promise<InvoiceList> {
|
||||
return this.orchestrator.getCancelledInvoices(userId, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get invoices in collections for a user
|
||||
*/
|
||||
async getCollectionsInvoices(
|
||||
userId: string,
|
||||
options: Pick<GetInvoicesOptions, "page" | "limit"> = {}
|
||||
): Promise<InvoiceList> {
|
||||
return this.orchestrator.getCollectionsInvoices(userId, options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create payment link for a specific invoice
|
||||
*/
|
||||
async createInvoicePaymentLink(
|
||||
userId: string,
|
||||
invoiceId: number,
|
||||
gatewayName: string,
|
||||
returnUrl: string
|
||||
): Promise<InvoicePaymentLink> {
|
||||
const mapping = await this.mappingsService.findByUserId(userId);
|
||||
if (!mapping?.whmcsClientId) {
|
||||
throw new Error("WHMCS client mapping not found");
|
||||
}
|
||||
|
||||
const ssoResult = await this.whmcsService.createPaymentSsoToken(
|
||||
mapping.whmcsClientId,
|
||||
invoiceId,
|
||||
undefined,
|
||||
gatewayName
|
||||
);
|
||||
|
||||
return {
|
||||
url: ssoResult.url,
|
||||
expiresAt: ssoResult.expiresAt,
|
||||
gatewayName,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get payment methods for a user
|
||||
*/
|
||||
async getPaymentMethods(userId: string): Promise<PaymentMethodList> {
|
||||
const mapping = await this.mappingsService.findByUserId(userId);
|
||||
if (!mapping?.whmcsClientId) {
|
||||
throw new Error("WHMCS client mapping not found");
|
||||
}
|
||||
return this.whmcsService.getPaymentMethods(mapping.whmcsClientId, userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get available payment gateways
|
||||
*/
|
||||
async getPaymentGateways(): Promise<PaymentGatewayList> {
|
||||
return this.whmcsService.getPaymentGateways();
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidate payment methods cache for a user
|
||||
*/
|
||||
async invalidatePaymentMethodsCache(userId: string): Promise<void> {
|
||||
return this.whmcsService.invalidatePaymentMethodsCache(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Health check for invoice service
|
||||
*/
|
||||
async healthCheck(): Promise<{ status: string; details: unknown }> {
|
||||
const health = await this.orchestrator.healthCheck();
|
||||
return {
|
||||
status: health.status,
|
||||
details: health.details,
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get service statistics
|
||||
*/
|
||||
getServiceStats() {
|
||||
return this.orchestrator.getServiceStats();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if user has any invoices
|
||||
*/
|
||||
async hasInvoices(userId: string): Promise<boolean> {
|
||||
return this.orchestrator.hasInvoices(userId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get invoice count by status
|
||||
*/
|
||||
async getInvoiceCountByStatus(
|
||||
userId: string,
|
||||
status: "Paid" | "Unpaid" | "Cancelled" | "Overdue" | "Collections"
|
||||
): Promise<number> {
|
||||
return this.orchestrator.getInvoiceCountByStatus(userId, status);
|
||||
}
|
||||
}
|
||||
@ -2,7 +2,7 @@ import { Injectable, BadRequestException, Inject } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { ZodError } from "zod";
|
||||
import { MappingsService } from "@bff/modules/id-mappings/mappings.service";
|
||||
import { WhmcsConnectionService } from "@bff/integrations/whmcs/services/whmcs-connection.service";
|
||||
import { WhmcsConnectionOrchestratorService } from "@bff/integrations/whmcs/connection/services/whmcs-connection-orchestrator.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
import {
|
||||
createOrderRequestSchema,
|
||||
@ -20,7 +20,7 @@ export class OrderValidator {
|
||||
constructor(
|
||||
@Inject(Logger) private readonly logger: Logger,
|
||||
private readonly mappings: MappingsService,
|
||||
private readonly whmcs: WhmcsConnectionService,
|
||||
private readonly whmcs: WhmcsConnectionOrchestratorService,
|
||||
private readonly pricebookService: OrderPricebookService
|
||||
) {}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { FreebitService } from "@bff/integrations/freebit/freebit.service";
|
||||
import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service";
|
||||
import type { FulfillmentOrderDetails, FulfillmentOrderItem } from "../types/fulfillment.types";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
|
||||
@ -12,7 +12,7 @@ export interface SimFulfillmentRequest {
|
||||
@Injectable()
|
||||
export class SimFulfillmentService {
|
||||
constructor(
|
||||
private readonly freebit: FreebitService,
|
||||
private readonly freebit: FreebitOrchestratorService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
) {}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject, BadRequestException } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { FreebitService } from "@bff/integrations/freebit/freebit.service";
|
||||
import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service";
|
||||
import { SimValidationService } from "./sim-validation.service";
|
||||
import { SimNotificationService } from "./sim-notification.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
@ -8,7 +8,7 @@ import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
@Injectable()
|
||||
export class EsimManagementService {
|
||||
constructor(
|
||||
private readonly freebitService: FreebitService,
|
||||
private readonly freebitService: FreebitOrchestratorService,
|
||||
private readonly simValidation: SimValidationService,
|
||||
private readonly simNotification: SimNotificationService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject, BadRequestException } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { FreebitService } from "@bff/integrations/freebit/freebit.service";
|
||||
import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service";
|
||||
import { SimValidationService } from "./sim-validation.service";
|
||||
import { SimNotificationService } from "./sim-notification.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
@ -9,7 +9,7 @@ import type { SimCancelRequest } from "../types/sim-requests.types";
|
||||
@Injectable()
|
||||
export class SimCancellationService {
|
||||
constructor(
|
||||
private readonly freebitService: FreebitService,
|
||||
private readonly freebitService: FreebitOrchestratorService,
|
||||
private readonly simValidation: SimValidationService,
|
||||
private readonly simNotification: SimNotificationService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { FreebitService } from "@bff/integrations/freebit/freebit.service";
|
||||
import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service";
|
||||
import { SimValidationService } from "./sim-validation.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
import type { SimDetails } from "@bff/integrations/freebit/interfaces/freebit.types";
|
||||
@ -8,7 +8,7 @@ import type { SimDetails } from "@bff/integrations/freebit/interfaces/freebit.ty
|
||||
@Injectable()
|
||||
export class SimDetailsService {
|
||||
constructor(
|
||||
private readonly freebitService: FreebitService,
|
||||
private readonly freebitService: FreebitOrchestratorService,
|
||||
private readonly simValidation: SimValidationService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
) {}
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject, BadRequestException } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { FreebitService } from "@bff/integrations/freebit/freebit.service";
|
||||
import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service";
|
||||
import { SimValidationService } from "./sim-validation.service";
|
||||
import { SimNotificationService } from "./sim-notification.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
@ -12,7 +12,7 @@ import type {
|
||||
@Injectable()
|
||||
export class SimPlanService {
|
||||
constructor(
|
||||
private readonly freebitService: FreebitService,
|
||||
private readonly freebitService: FreebitOrchestratorService,
|
||||
private readonly simValidation: SimValidationService,
|
||||
private readonly simNotification: SimNotificationService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject, BadRequestException } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { FreebitService } from "@bff/integrations/freebit/freebit.service";
|
||||
import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service";
|
||||
import { WhmcsService } from "@bff/integrations/whmcs/whmcs.service";
|
||||
import { MappingsService } from "@bff/modules/id-mappings/mappings.service";
|
||||
import { SimValidationService } from "./sim-validation.service";
|
||||
@ -11,7 +11,7 @@ import type { SimTopUpRequest } from "../types/sim-requests.types";
|
||||
@Injectable()
|
||||
export class SimTopUpService {
|
||||
constructor(
|
||||
private readonly freebitService: FreebitService,
|
||||
private readonly freebitService: FreebitOrchestratorService,
|
||||
private readonly whmcsService: WhmcsService,
|
||||
private readonly mappingsService: MappingsService,
|
||||
private readonly simValidation: SimValidationService,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, Inject } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { FreebitService } from "@bff/integrations/freebit/freebit.service";
|
||||
import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service";
|
||||
import { SimValidationService } from "./sim-validation.service";
|
||||
import { SimUsageStoreService } from "../../sim-usage-store.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
@ -14,7 +14,7 @@ import { BadRequestException } from "@nestjs/common";
|
||||
@Injectable()
|
||||
export class SimUsageService {
|
||||
constructor(
|
||||
private readonly freebitService: FreebitService,
|
||||
private readonly freebitService: FreebitOrchestratorService,
|
||||
private readonly simValidation: SimValidationService,
|
||||
private readonly usageStore: SimUsageStoreService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { Injectable, BadRequestException, Inject } from "@nestjs/common";
|
||||
import { Logger } from "nestjs-pino";
|
||||
import { FreebitService } from "@bff/integrations/freebit/freebit.service";
|
||||
import { FreebitOrchestratorService } from "@bff/integrations/freebit/services/freebit-orchestrator.service";
|
||||
import { WhmcsService } from "@bff/integrations/whmcs/whmcs.service";
|
||||
import { MappingsService } from "@bff/modules/id-mappings/mappings.service";
|
||||
import { getErrorMessage } from "@bff/core/utils/error.util";
|
||||
@ -31,7 +31,7 @@ export interface SimOrderActivationRequest {
|
||||
@Injectable()
|
||||
export class SimOrderActivationService {
|
||||
constructor(
|
||||
private readonly freebit: FreebitService,
|
||||
private readonly freebit: FreebitOrchestratorService,
|
||||
private readonly whmcs: WhmcsService,
|
||||
private readonly mappings: MappingsService,
|
||||
@Inject(Logger) private readonly logger: Logger
|
||||
|
||||
@ -53,7 +53,6 @@ export class UsersService {
|
||||
};
|
||||
}
|
||||
|
||||
// Remove the old toUser method as we're using toDomainUser directly
|
||||
|
||||
private validateEmail(email: string): string {
|
||||
return normalizeAndValidateEmail(email);
|
||||
|
||||
@ -128,7 +128,6 @@ export {
|
||||
contactFormToRequest,
|
||||
} from "./forms/profile";
|
||||
|
||||
// Order and subscription form schemas were legacy-specific; remove exports if not in use
|
||||
|
||||
// SIM configuration forms
|
||||
export {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user