import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger'; import { IsDateString, IsOptional, Matches } from 'class-validator'; import { AccountReferenceDto } from './account-reference.dto'; import { MoneyDto } from '../common/money.dto'; export class UpcomingEventsQueryDto { @ApiPropertyOptional({ format: 'date', description: 'Inclusive start date (YYYY-MM-DD). Defaults to today in UTC.', }) @IsOptional() @Matches(/^\d{4}-\d{2}-\d{2}$/) @IsDateString({ strict: true }) from?: string; @ApiPropertyOptional({ format: 'date', description: 'Inclusive end date (YYYY-MM-DD). Defaults to 30 days after from.', }) @IsOptional() @Matches(/^\d{4}-\d{2}-\d{2}$/) @IsDateString({ strict: true }) to?: string; } export class UpcomingEventDto { @ApiPropertyOptional({ type: AccountReferenceDto }) account?: AccountReferenceDto; @ApiProperty({ enum: ['coupon', 'dividend', 'maturity', 'offer'] }) type: 'coupon' | 'dividend' | 'maturity' | 'offer'; @ApiProperty({ format: 'date' }) date: string; @ApiProperty({ enum: ['event', 'registry'] }) dateKind: 'event' | 'registry'; @ApiProperty({ type: String, nullable: true }) figi: string | null; @ApiProperty({ type: String, nullable: true }) instrumentUid: string | null; @ApiProperty() ticker: string; @ApiProperty() displayName: string; @ApiProperty({ type: String, nullable: true }) isin: string | null; @ApiProperty({ type: String, nullable: true }) logoName: string | null; @ApiProperty({ type: MoneyDto, nullable: true }) projectedAmount: MoneyDto | null; } export class UpcomingEventsDto { @ApiProperty() accountId: string; @ApiProperty({ format: 'date-time' }) calculatedAt: string; @ApiProperty({ type: UpcomingEventDto, isArray: true }) events: UpcomingEventDto[]; @ApiProperty({ type: MoneyDto, isArray: true }) incomeTotalsByCurrency: MoneyDto[]; }