69 lines
1.6 KiB
TypeScript
69 lines
1.6 KiB
TypeScript
import {
|
|
IsEmail,
|
|
IsString,
|
|
IsEnum,
|
|
IsOptional,
|
|
IsUrl,
|
|
} from 'class-validator';
|
|
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
|
|
export class SocialAuthDto {
|
|
@ApiProperty({
|
|
example: 'google',
|
|
description: 'OAuth provider',
|
|
enum: ['google', 'facebook', 'twitter', 'apple'],
|
|
})
|
|
@IsEnum(['google', 'facebook', 'twitter', 'apple'], {
|
|
message: 'Provider must be google, facebook, twitter, or apple',
|
|
})
|
|
provider: 'google' | 'facebook' | 'twitter' | 'apple';
|
|
|
|
@ApiProperty({
|
|
example: '123456789',
|
|
description: 'Provider user ID',
|
|
})
|
|
@IsString()
|
|
providerId: string;
|
|
|
|
@ApiProperty({
|
|
example: 'john@example.com',
|
|
description: 'User email from OAuth provider',
|
|
})
|
|
@IsEmail({}, { message: 'Please provide a valid email address' })
|
|
email: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'John Doe',
|
|
description: 'User name from OAuth provider',
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
name?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'https://example.com/avatar.jpg',
|
|
description: 'User avatar URL from OAuth provider',
|
|
})
|
|
@IsOptional()
|
|
@IsUrl({}, { message: 'Avatar must be a valid URL' })
|
|
avatar?: string;
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'USER',
|
|
description: 'User role (USER or AGENT)',
|
|
enum: ['USER', 'AGENT'],
|
|
default: 'USER',
|
|
})
|
|
@IsOptional()
|
|
@IsEnum(['USER', 'AGENT'], { message: 'Role must be either USER or AGENT' })
|
|
role?: 'USER' | 'AGENT';
|
|
|
|
@ApiPropertyOptional({
|
|
example: 'uuid-of-agent-type',
|
|
description: 'Agent type ID (required when role is AGENT)',
|
|
})
|
|
@IsOptional()
|
|
@IsString()
|
|
agentTypeId?: string;
|
|
}
|