Files
zod-backend/src/customer/dtos/response/customer.response.dto.ts
2025-07-30 14:09:00 +03:00

111 lines
3.1 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { Customer } from '~/customer/entities';
import { CustomerStatus, Gender, KycStatus } from '~/customer/enums';
import { DocumentMetaResponseDto } from '~/document/dtos/response';
export class CustomerResponseDto {
@ApiProperty({ example: '123e4567-e89b-12d3-a456-426614174000' })
id!: string;
@ApiProperty({ example: CustomerStatus.PENDING })
customerStatus!: CustomerStatus;
@ApiProperty({ example: KycStatus.PENDING })
kycStatus!: KycStatus;
@ApiProperty({ example: 'Rejection reason if any' })
rejectionReason!: string | null;
@ApiProperty({ example: 'John' })
firstName!: string;
@ApiProperty({ example: 'Doe' })
lastName!: string;
@ApiProperty({ example: '1990-01-01' })
dateOfBirth!: Date;
@ApiProperty({ example: '123456789' })
nationalId!: string;
@ApiProperty({ example: '2025-01-01' })
nationalIdExpiry!: Date;
@ApiProperty({ example: 'JO' })
countryOfResidence!: string;
@ApiProperty({ example: 'Employee' })
sourceOfIncome!: string;
@ApiProperty({ example: 'Software Development' })
profession!: string;
@ApiProperty({ example: 'Full-time' })
professionType!: string;
@ApiProperty({ example: false })
isPep!: boolean;
@ApiProperty({ example: Gender.MALE })
gender!: string;
@ApiProperty({ example: false })
isJunior!: boolean;
@ApiProperty({ example: true })
isGuardian!: boolean;
@ApiProperty({ example: 12345 })
waitingNumber!: number;
@ApiProperty({ example: 'SA' })
country!: string | null;
@ApiProperty({ example: 'Riyadh' })
region!: string | null;
@ApiProperty({ example: 'Riyadh City' })
city!: string | null;
@ApiProperty({ example: 'Al-Masif' })
neighborhood!: string | null;
@ApiProperty({ example: 'King Fahd Road' })
street!: string | null;
@ApiProperty({ example: '123' })
building!: string | null;
@ApiPropertyOptional({ type: DocumentMetaResponseDto })
profilePicture!: DocumentMetaResponseDto | null;
constructor(customer: Customer) {
this.id = customer.id;
this.customerStatus = customer.customerStatus;
this.kycStatus = customer.kycStatus;
this.rejectionReason = customer.rejectionReason;
this.firstName = customer.firstName;
this.lastName = customer.lastName;
this.dateOfBirth = customer.dateOfBirth;
this.nationalId = customer.nationalId;
this.nationalIdExpiry = customer.nationalIdExpiry;
this.countryOfResidence = customer.countryOfResidence;
this.sourceOfIncome = customer.sourceOfIncome;
this.profession = customer.profession;
this.professionType = customer.professionType;
this.isPep = customer.isPep;
this.gender = customer.gender;
this.isJunior = customer.isJunior;
this.isGuardian = customer.isGuardian;
this.waitingNumber = customer.applicationNumber;
this.country = customer.country;
this.region = customer.region;
this.city = customer.city;
this.neighborhood = customer.neighborhood;
this.street = customer.street;
this.building = customer.building;
this.profilePicture = customer.profilePicture ? new DocumentMetaResponseDto(customer.profilePicture) : null;
}
}