import { IsString, IsOptional, IsIn } from 'class-validator';
import { ApiProperty } from '@nestjs/swagger';
import type { SmsPurpose } from './sms.types';

export class SendSmsCodeDto {
  @ApiProperty({ example: '13800138000', description: '本地手机号，不含国家区号' })
  @IsString()
  phone!: string;

  @ApiProperty({ example: '86', description: '国家区号，不含 +' })
  @IsString()
  countryCode!: string;

  @ApiProperty({ required: false })
  @IsOptional()
  @IsString()
  locale?: string;

  @ApiProperty({ required: false, enum: ['register', 'reset_password'] })
  @IsOptional()
  @IsIn(['register', 'reset_password'])
  purpose?: SmsPurpose;
}

export class VerifySmsCodeDto {
  @ApiProperty()
  @IsString()
  phone!: string;

  @ApiProperty()
  @IsString()
  countryCode!: string;

  @ApiProperty()
  @IsString()
  code!: string;

  @ApiProperty()
  @IsString()
  sessionId!: string;
}
