- Updated address retrieval in user service to replace billing info with a dedicated address method. - Adjusted API endpoints to use `PATCH /api/me/address` for address updates instead of billing updates. - Enhanced documentation to reflect changes in address management processes and API usage. - Removed deprecated types and services related to billing address handling, streamlining the codebase.
81 lines
2.6 KiB
TypeScript
81 lines
2.6 KiB
TypeScript
import { Controller, Get, Request } from "@nestjs/common";
|
|
import { ApiTags, ApiOperation, ApiBearerAuth } from "@nestjs/swagger";
|
|
import { InternetCatalogService } from "./services/internet-catalog.service";
|
|
import { SimCatalogService } from "./services/sim-catalog.service";
|
|
import { VpnCatalogService } from "./services/vpn-catalog.service";
|
|
import {
|
|
InternetProduct,
|
|
SimProduct,
|
|
VpnProduct,
|
|
} from "@customer-portal/domain";
|
|
|
|
@ApiTags("catalog")
|
|
@Controller("catalog")
|
|
@ApiBearerAuth()
|
|
export class CatalogController {
|
|
constructor(
|
|
private internetCatalog: InternetCatalogService,
|
|
private simCatalog: SimCatalogService,
|
|
private vpnCatalog: VpnCatalogService
|
|
) {}
|
|
|
|
@Get("internet/plans")
|
|
@ApiOperation({ summary: "Get Internet plans filtered by customer eligibility" })
|
|
async getInternetPlans(@Request() req: { user: { id: string } }): Promise<InternetProduct[]> {
|
|
const userId = req.user?.id;
|
|
if (!userId) {
|
|
// Fallback to all plans if no user context
|
|
return this.internetCatalog.getPlans();
|
|
}
|
|
return this.internetCatalog.getPlansForUser(userId);
|
|
}
|
|
|
|
@Get("internet/addons")
|
|
@ApiOperation({ summary: "Get Internet add-ons" })
|
|
async getInternetAddons(): Promise<InternetProduct[]> {
|
|
return this.internetCatalog.getAddons();
|
|
}
|
|
|
|
@Get("internet/installations")
|
|
@ApiOperation({ summary: "Get Internet installations" })
|
|
async getInternetInstallations(): Promise<InternetProduct[]> {
|
|
return this.internetCatalog.getInstallations();
|
|
}
|
|
|
|
@Get("sim/plans")
|
|
@ApiOperation({ summary: "Get SIM plans filtered by user's existing services" })
|
|
async getSimPlans(@Request() req: { user: { id: string } }): Promise<SimProduct[]> {
|
|
const userId = req.user?.id;
|
|
if (!userId) {
|
|
// Fallback to all regular plans if no user context
|
|
const allPlans = await this.simCatalog.getPlans();
|
|
return allPlans.filter(plan => !plan.hasFamilyDiscount);
|
|
}
|
|
return this.simCatalog.getPlansForUser(userId);
|
|
}
|
|
|
|
@Get("sim/activation-fees")
|
|
@ApiOperation({ summary: "Get SIM activation fees" })
|
|
async getSimActivationFees(): Promise<SimProduct[]> {
|
|
return this.simCatalog.getActivationFees();
|
|
}
|
|
|
|
@Get("sim/addons")
|
|
@ApiOperation({ summary: "Get SIM add-ons" })
|
|
async getSimAddons(): Promise<SimProduct[]> {
|
|
return this.simCatalog.getAddons();
|
|
}
|
|
|
|
@Get("vpn/plans")
|
|
@ApiOperation({ summary: "Get VPN plans" })
|
|
async getVpnPlans(): Promise<VpnProduct[]> {
|
|
return this.vpnCatalog.getPlans();
|
|
}
|
|
|
|
@Get("vpn/activation-fees")
|
|
@ApiOperation({ summary: "Get VPN activation fees" })
|
|
async getVpnActivationFees(): Promise<VpnProduct[]> {
|
|
return this.vpnCatalog.getActivationFees();
|
|
}
|
|
}
|