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

174 lines
3.4 KiB
TypeScript

import {
CustomerType,
PaymentMethodType,
TspProviderResponseStatus,
} from '@/generated/prisma/enums'
import { ApiProperty } from '@nestjs/swagger'
import { Type } from 'class-transformer'
import {
IsBoolean,
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
}
export class ProviderCommonResponse {
@ApiProperty({ enum: TspProviderResponseStatus })
@IsEnum(TspProviderResponseStatus)
status: TspProviderResponseStatus
@ApiProperty({ required: false, nullable: true, type: Object })
@IsOptional()
@IsObject()
provider_response?: Object
@ApiProperty({ required: true })
@IsBoolean()
hasError: boolean
@ApiProperty({ required: false, nullable: true })
@IsOptional()
@IsString()
message?: string | null
@ApiProperty({ required: false, nullable: true })
@IsOptional()
@IsString()
error_message?: string
@ApiProperty({ required: false, nullable: true, type: Object })
@IsOptional()
@IsObject()
fiscal_warnings?: Object
@ApiProperty({ required: false, nullable: true, type: Object })
@IsOptional()
@IsObject()
validation_errors?: Object
@ApiProperty({ required: true })
@IsDateString()
received_at: string
}