2025-08-28 16:57:57 +09:00
|
|
|
import { Controller, Get, Request } from "@nestjs/common";
|
2025-08-22 17:02:49 +09:00
|
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from "@nestjs/swagger";
|
2025-09-24 18:00:49 +09:00
|
|
|
import type {
|
2025-09-18 11:22:22 +09:00
|
|
|
InternetAddonCatalogItem,
|
|
|
|
|
InternetInstallationCatalogItem,
|
|
|
|
|
InternetPlanCatalogItem,
|
2025-09-24 18:00:49 +09:00
|
|
|
SimCatalogProduct,
|
2025-09-18 11:22:22 +09:00
|
|
|
SimActivationFeeCatalogItem,
|
2025-09-24 18:00:49 +09:00
|
|
|
VpnCatalogProduct,
|
|
|
|
|
} from "@customer-portal/domain";
|
|
|
|
|
import { InternetCatalogService } from "./services/internet-catalog.service";
|
|
|
|
|
import { SimCatalogService } from "./services/sim-catalog.service";
|
2025-09-18 11:22:22 +09:00
|
|
|
import { VpnCatalogService } from "./services/vpn-catalog.service";
|
2025-08-20 18:02:50 +09:00
|
|
|
|
2025-08-21 15:24:40 +09:00
|
|
|
@ApiTags("catalog")
|
|
|
|
|
@Controller("catalog")
|
2025-08-22 17:02:49 +09:00
|
|
|
@ApiBearerAuth()
|
2025-08-20 18:02:50 +09:00
|
|
|
export class CatalogController {
|
2025-08-27 20:01:46 +09:00
|
|
|
constructor(
|
|
|
|
|
private internetCatalog: InternetCatalogService,
|
|
|
|
|
private simCatalog: SimCatalogService,
|
|
|
|
|
private vpnCatalog: VpnCatalogService
|
|
|
|
|
) {}
|
2025-08-20 18:02:50 +09:00
|
|
|
|
2025-08-28 16:57:57 +09:00
|
|
|
@Get("internet/plans")
|
2025-08-27 20:01:46 +09:00
|
|
|
@ApiOperation({ summary: "Get Internet plans filtered by customer eligibility" })
|
2025-09-18 11:22:22 +09:00
|
|
|
async getInternetPlans(
|
|
|
|
|
@Request() req: { user: { id: string } }
|
|
|
|
|
): Promise<InternetPlanCatalogItem[]> {
|
2025-08-27 20:01:46 +09:00
|
|
|
const userId = req.user?.id;
|
|
|
|
|
if (!userId) {
|
|
|
|
|
// Fallback to all plans if no user context
|
|
|
|
|
return this.internetCatalog.getPlans();
|
|
|
|
|
}
|
|
|
|
|
return this.internetCatalog.getPlansForUser(userId);
|
2025-08-27 10:54:05 +09:00
|
|
|
}
|
|
|
|
|
|
2025-08-28 16:57:57 +09:00
|
|
|
@Get("internet/addons")
|
2025-08-27 20:01:46 +09:00
|
|
|
@ApiOperation({ summary: "Get Internet add-ons" })
|
2025-09-18 11:22:22 +09:00
|
|
|
async getInternetAddons(): Promise<InternetAddonCatalogItem[]> {
|
2025-08-27 20:01:46 +09:00
|
|
|
return this.internetCatalog.getAddons();
|
2025-08-27 10:54:05 +09:00
|
|
|
}
|
|
|
|
|
|
2025-08-28 16:57:57 +09:00
|
|
|
@Get("internet/installations")
|
2025-08-27 20:01:46 +09:00
|
|
|
@ApiOperation({ summary: "Get Internet installations" })
|
2025-09-18 11:22:22 +09:00
|
|
|
async getInternetInstallations(): Promise<InternetInstallationCatalogItem[]> {
|
2025-08-27 20:01:46 +09:00
|
|
|
return this.internetCatalog.getInstallations();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 16:57:57 +09:00
|
|
|
@Get("sim/plans")
|
2025-08-27 20:01:46 +09:00
|
|
|
@ApiOperation({ summary: "Get SIM plans filtered by user's existing services" })
|
2025-09-24 18:00:49 +09:00
|
|
|
async getSimPlans(@Request() req: { user: { id: string } }): Promise<SimCatalogProduct[]> {
|
2025-08-27 20:01:46 +09:00
|
|
|
const userId = req.user?.id;
|
|
|
|
|
if (!userId) {
|
|
|
|
|
// Fallback to all regular plans if no user context
|
|
|
|
|
const allPlans = await this.simCatalog.getPlans();
|
2025-09-18 11:22:22 +09:00
|
|
|
return allPlans.filter(plan => !plan.simHasFamilyDiscount);
|
2025-08-27 20:01:46 +09:00
|
|
|
}
|
|
|
|
|
return this.simCatalog.getPlansForUser(userId);
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 16:57:57 +09:00
|
|
|
@Get("sim/activation-fees")
|
2025-08-27 20:01:46 +09:00
|
|
|
@ApiOperation({ summary: "Get SIM activation fees" })
|
2025-09-18 11:22:22 +09:00
|
|
|
async getSimActivationFees(): Promise<SimActivationFeeCatalogItem[]> {
|
2025-08-27 20:01:46 +09:00
|
|
|
return this.simCatalog.getActivationFees();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 16:57:57 +09:00
|
|
|
@Get("sim/addons")
|
2025-08-27 20:01:46 +09:00
|
|
|
@ApiOperation({ summary: "Get SIM add-ons" })
|
2025-09-24 18:00:49 +09:00
|
|
|
async getSimAddons(): Promise<SimCatalogProduct[]> {
|
2025-08-27 20:01:46 +09:00
|
|
|
return this.simCatalog.getAddons();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 16:57:57 +09:00
|
|
|
@Get("vpn/plans")
|
2025-08-27 20:01:46 +09:00
|
|
|
@ApiOperation({ summary: "Get VPN plans" })
|
2025-09-24 18:00:49 +09:00
|
|
|
async getVpnPlans(): Promise<VpnCatalogProduct[]> {
|
2025-08-27 20:01:46 +09:00
|
|
|
return this.vpnCatalog.getPlans();
|
|
|
|
|
}
|
|
|
|
|
|
2025-08-28 16:57:57 +09:00
|
|
|
@Get("vpn/activation-fees")
|
2025-08-27 20:01:46 +09:00
|
|
|
@ApiOperation({ summary: "Get VPN activation fees" })
|
2025-09-24 18:00:49 +09:00
|
|
|
async getVpnActivationFees(): Promise<VpnCatalogProduct[]> {
|
2025-08-27 20:01:46 +09:00
|
|
|
return this.vpnCatalog.getActivationFees();
|
2025-08-27 10:54:05 +09:00
|
|
|
}
|
2025-08-28 16:57:57 +09:00
|
|
|
}
|