Files
psp_api/src/modules/tspProviders/dto/common.dto.ts
T

130 lines
2.5 KiB
TypeScript
Raw Normal View History

import { CustomerType, PaymentMethodType } from '@/generated/prisma/enums'
import { ApiProperty } from '@nestjs/swagger'
import { Type } from 'class-transformer'
import {
IsDateString,
IsEnum,
IsNumber,
IsObject,
IsOptional,
IsString,
Min,
ValidateNested,
} from 'class-validator'
export class CustomerUnknownInfoDto {
@ApiProperty({})
@IsString()
@IsOptional()
name: string
@ApiProperty({})
@IsString()
@IsOptional()
economic_code: string
}
export class CustomerLegalInfoDto {
@ApiProperty({ required: true })
@IsString()
name: string
@ApiProperty({ required: true })
@IsString()
economic_code: string
}
export class CustomerIndividualInfoDto {
@ApiProperty({ required: true })
@IsString()
first_name: string
@ApiProperty({ required: true })
@IsString()
last_name: string
@ApiProperty({ required: true })
@IsString()
national_id: string
@ApiProperty({ required: true })
@IsString()
mobile_number: string
}
export class CustomerInfoDto {
@ApiProperty({ required: true, enum: CustomerType })
@IsEnum(CustomerType)
type: CustomerType
@ApiProperty({})
@Type(() => CustomerLegalInfoDto)
@ValidateNested({ each: true })
legal_info?: CustomerLegalInfoDto
@ApiProperty({})
@Type(() => CustomerIndividualInfoDto)
@ValidateNested({ each: true })
individual_info?: CustomerIndividualInfoDto
@ApiProperty({})
@Type(() => CustomerUnknownInfoDto)
@ValidateNested({ each: true })
unknown_info?: CustomerUnknownInfoDto
}
export class TerminalInfoDto {
@ApiProperty({ required: false })
@IsOptional()
@IsString()
tracking_code?: string
@ApiProperty({ required: false })
@IsOptional()
@IsString()
card_number?: string
}
export class PaymentInfoDto {
@ApiProperty({ required: true, enum: PaymentMethodType })
@IsEnum(PaymentMethodType)
payment_method: PaymentMethodType
@ApiProperty({ required: true })
@IsNumber({ allowInfinity: false, allowNaN: false })
@Min(0)
amount: number
@ApiProperty({ required: false })
@IsOptional()
@IsDateString()
paid_at?: Date
@ApiProperty({ type: TerminalInfoDto })
@IsOptional()
@IsObject()
terminal_info: TerminalInfoDto
}
export class goldTypePayload {
@ApiProperty({ required: false })
@IsOptional()
@IsString()
karat: string
@ApiProperty({ required: false })
@IsOptional()
@IsString()
profit: string
@ApiProperty({ required: false })
@IsOptional()
@IsString()
wages: string
@ApiProperty({ required: false })
@IsOptional()
@IsString()
commission: string
}