mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 23:28:11 +00:00
177 lines
8.9 KiB
TypeScript
177 lines
8.9 KiB
TypeScript
import { IsString, IsArray, ValidateNested, IsOptional, IsInt, IsEnum, IsDateString } from 'class-validator';
|
|
import { Type } from 'class-transformer';
|
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { Currency, IdDocumentType } from '@prisma/client';
|
|
|
|
export class PassengerInputDto {
|
|
@ApiProperty() @IsString() seatId: string;
|
|
@ApiPropertyOptional({ description: '**TRANSIT / ROUND_TRIP_TRANSIT:** Seat ID on leg-2 schedule' }) @IsOptional() @IsString() leg2SeatId?: string;
|
|
@ApiProperty({ example: 'Abebe Kebede' }) @IsString() passengerName: string;
|
|
@ApiProperty({ example: '1990-05-15', description: 'Date of birth (YYYY-MM-DD) for age calculation. Age <5 = CHILD (first free), Age ≥5 = ADULT (full fare)' }) @IsDateString() dateOfBirth: string;
|
|
@ApiProperty({ example: 'NATIONAL_ID', enum: IdDocumentType, description: 'NATIONAL_ID for Ethiopians (Verifayda verified), PASSPORT for others' }) @IsEnum(IdDocumentType) idDocumentType: IdDocumentType;
|
|
@ApiPropertyOptional({ example: 'ET123456789', description: 'Ethiopian national ID - verified via Verifayda 2.0 (NOT stored in database)' }) @IsOptional() @IsString() idDocumentNumber?: string;
|
|
@ApiPropertyOptional({ example: 'P1234567', description: 'Passport number for non-Ethiopian passengers (no verification)' }) @IsOptional() @IsString() passportNumber?: string;
|
|
@ApiPropertyOptional({ example: 'Djibouti', description: 'Passport issuing country for non-Ethiopians' }) @IsOptional() @IsString() passportCountry?: string;
|
|
@ApiPropertyOptional({ example: 'Ethiopian', description: 'Ethiopian (Verifayda + Telebirr/CBE/eBirr), Djiboutian (Passport + Waafi), Other (Passport + Card)' }) @IsOptional() @IsString() nationality?: string;
|
|
}
|
|
|
|
export class RoundTripPassengerDto {
|
|
@ApiProperty({ description: 'Outbound journey seat ID', example: 'seat-uuid-outbound' })
|
|
@IsString() outboundSeatId: string;
|
|
|
|
@ApiProperty({ description: 'Return journey seat ID', example: 'seat-uuid-return' })
|
|
@IsString() returnSeatId: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP_TRANSIT:** Outbound leg-2 seat ID' })
|
|
@IsOptional() @IsString() outboundLeg2SeatId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP_TRANSIT:** Return leg-2 seat ID' })
|
|
@IsOptional() @IsString() returnLeg2SeatId?: string;
|
|
|
|
@ApiProperty({
|
|
example: 'Abebe Kebede',
|
|
description: 'Full passenger name (will be verified via Verifayda for Ethiopian nationals)'
|
|
})
|
|
@IsString() passengerName: string;
|
|
|
|
@ApiProperty({
|
|
example: '1990-05-15',
|
|
description: 'Date of birth (YYYY-MM-DD) for age calculation. Age <5 = CHILD (first child FREE), Age ≥5 = ADULT (full fare for both legs)'
|
|
})
|
|
@IsDateString() dateOfBirth: string;
|
|
|
|
@ApiProperty({
|
|
example: 'NATIONAL_ID',
|
|
enum: IdDocumentType,
|
|
description: 'NATIONAL_ID for Ethiopians (Verifayda verified), PASSPORT for others'
|
|
})
|
|
@IsEnum(IdDocumentType) idDocumentType: IdDocumentType;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'ET123456789',
|
|
description: 'Ethiopian national ID - verified via Verifayda 2.0 (NOT stored in database)'
|
|
})
|
|
@IsOptional() @IsString() idDocumentNumber?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'P1234567',
|
|
description: 'Passport number for non-Ethiopian passengers (no verification)'
|
|
})
|
|
@IsOptional() @IsString() passportNumber?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'Djibouti',
|
|
description: 'Passport issuing country for non-Ethiopians'
|
|
})
|
|
@IsOptional() @IsString() passportCountry?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'Ethiopian',
|
|
description: 'Ethiopian (Verifayda + Telebirr/CBE/eBirr), Djiboutian (Passport + Waafi), Other (Passport + Card)'
|
|
})
|
|
@IsOptional() @IsString() nationality?: string;
|
|
}
|
|
|
|
export class CreateBookingDto {
|
|
@ApiProperty({ description: 'Passenger ID' })
|
|
@IsString() passengerId: string;
|
|
|
|
@ApiProperty({ description: 'Outbound schedule ID' })
|
|
@IsString() scheduleId: string;
|
|
|
|
@ApiProperty({ description: 'Outbound seat hold ID' })
|
|
@IsString() holdId: string;
|
|
|
|
@ApiProperty({ example: 'station-uuid', description: 'Outbound origin station UUID (must match the hold)' })
|
|
@IsString() originStationId: string;
|
|
|
|
@ApiProperty({ example: 'station-uuid', description: 'Outbound destination station UUID (must match the hold)' })
|
|
@IsString() destinationStationId: string;
|
|
|
|
@ApiProperty({ example: 'seat-class-uuid', description: 'Outbound seat class UUID (Economy Regular, Economy Bed, VIP Bed)' })
|
|
@IsString() seatClassId: string;
|
|
|
|
@ApiProperty({
|
|
example: 'ONE_WAY',
|
|
enum: ['ONE_WAY', 'ROUND_TRIP', 'TRANSIT', 'ROUND_TRIP_TRANSIT'],
|
|
description: `Booking type:\n\n**ONE_WAY:** Single journey\n\n**ROUND_TRIP:** Outbound + return, single PNR\n\n**TRANSIT:** Single journey via connecting train, single PNR, single ticket\n\n**ROUND_TRIP_TRANSIT:** Round trip where one or both directions use a connecting train`,
|
|
default: 'ONE_WAY'
|
|
})
|
|
@IsOptional() @IsString() bookingType?: string;
|
|
|
|
@ApiProperty({
|
|
type: [PassengerInputDto],
|
|
description: `Passenger array - type depends on bookingType:\n\n**For ONE_WAY:** PassengerInputDto[]\n- Each passenger has: seatId, passengerName, dateOfBirth, etc.\n\n**For ROUND_TRIP:** RoundTripPassengerDto[]\n- Each passenger has: outboundSeatId, returnSeatId, passengerName, dateOfBirth, etc.\n\n**Age-based pricing:** First child (<5 years) travels FREE, subsequent children pay full fare`
|
|
})
|
|
@IsArray() @ValidateNested({ each: true }) @Type(() => PassengerInputDto)
|
|
passengers: PassengerInputDto[];
|
|
|
|
@ApiPropertyOptional({ description: 'Promo code for discount (applies to combined fare for round-trip)' })
|
|
@IsOptional() @IsString() promoCode?: string;
|
|
|
|
@ApiPropertyOptional({ description: 'Loyalty points to redeem (applies to combined fare for round-trip)' })
|
|
@IsOptional() @IsInt() loyaltyRedemptionPoints?: number;
|
|
|
|
@ApiPropertyOptional({ example: 'DJF', enum: Currency, description: 'Display currency for fare breakdown (ETB, DJF, USD). Transaction always in ETB.' })
|
|
@IsOptional() @IsEnum(Currency) displayCurrency?: Currency;
|
|
|
|
// Transit-specific fields
|
|
@ApiPropertyOptional({ description: '**TRANSIT / ROUND_TRIP_TRANSIT:** Leg-2 schedule ID' })
|
|
@IsOptional() @IsString() leg2ScheduleId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**TRANSIT / ROUND_TRIP_TRANSIT:** Leg-2 seat hold ID' })
|
|
@IsOptional() @IsString() leg2HoldId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**TRANSIT / ROUND_TRIP_TRANSIT:** Transit (connecting) station UUID' })
|
|
@IsOptional() @IsString() transitStationId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**TRANSIT / ROUND_TRIP_TRANSIT:** Leg-2 destination station UUID' })
|
|
@IsOptional() @IsString() leg2DestinationStationId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**TRANSIT / ROUND_TRIP_TRANSIT:** Leg-2 seat class ID (defaults to outbound seatClassId)' })
|
|
@IsOptional() @IsString() leg2SeatClassId?: string;
|
|
|
|
// Round-trip transit: return direction transit fields
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP_TRANSIT:** Return leg-1 schedule ID' })
|
|
@IsOptional() @IsString() returnScheduleId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP / ROUND_TRIP_TRANSIT:** Return origin station ID' })
|
|
@IsOptional() @IsString() returnOriginStationId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP / ROUND_TRIP_TRANSIT:** Return destination station ID' })
|
|
@IsOptional() @IsString() returnDestinationStationId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP / ROUND_TRIP_TRANSIT:** Return seat hold ID' })
|
|
@IsOptional() @IsString() returnHoldId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP / ROUND_TRIP_TRANSIT:** Return seat class ID' })
|
|
@IsOptional() @IsString() returnSeatClassId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP_TRANSIT:** Return leg-2 schedule ID' })
|
|
@IsOptional() @IsString() returnLeg2ScheduleId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP_TRANSIT:** Return leg-2 seat hold ID' })
|
|
@IsOptional() @IsString() returnLeg2HoldId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP_TRANSIT:** Return transit (connecting) station UUID' })
|
|
@IsOptional() @IsString() returnTransitStationId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP_TRANSIT:** Return leg-2 destination station UUID' })
|
|
@IsOptional() @IsString() returnLeg2DestinationStationId?: string;
|
|
|
|
@ApiPropertyOptional({ description: '**ROUND_TRIP_TRANSIT:** Return leg-2 seat class ID' })
|
|
@IsOptional() @IsString() returnLeg2SeatClassId?: string;
|
|
}
|
|
|
|
export class ModifyBookingDto {
|
|
@ApiProperty() @IsString() bookingRef: string;
|
|
@ApiProperty({ example: 'schedule-uuid' }) @IsString() newScheduleId: string;
|
|
@ApiProperty({ type: [String] }) @IsArray() newSeatIds: string[];
|
|
@ApiPropertyOptional() @IsOptional() @IsString() reason?: string;
|
|
}
|
|
|
|
export class CancelBookingDto {
|
|
@ApiProperty() @IsString() bookingRef: string;
|
|
@ApiPropertyOptional() @IsOptional() @IsString() reason?: string;
|
|
}
|