import { HttpStatus } from '@nestjs/common/enums/http-status.enum'; // full path to work in the browser import { AxiosRequestConfig } from 'axios'; import { Exclude, Expose } from 'class-transformer'; import { IsDate, IsEnum, IsInt, IsMongoId, IsNotEmpty, IsOptional, IsString } from 'class-validator'; import { IVendorAudit, VendorAuditActionEnum, VendorAuditTypeEnum, VendorProviderEnum } from '../interface'; export class VendorAuditModel implements IVendorAudit { constructor() { this.retries = 0; this.httpStatus = 0; } @Exclude() readonly _id: string | any; @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsString({ always: true }) merchantId: string; @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsString({ always: true }) storeId: string; /** * Optional for backward compatibility with v1 */ @Expose({ groups: ['read', 'write'], since: 2 }) @IsNotEmpty({ always: true }) @IsMongoId({ always: true }) vendorId?: string; @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsString({ always: true }) userId: string; /** * If true, the order has been sent to the pos system. * Otherwise it was not sent. */ @Expose({ groups: ['read', 'write'], since: 2 }) @IsNotEmpty({ always: true }) @IsString({ always: true }) isLiveMode: boolean; @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsString({ always: true }) type: VendorAuditTypeEnum | VendorProviderEnum; @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsString({ always: true }) action: VendorAuditActionEnum; /** * Optional for backward compatibility with v1 * Can be zero, if data from v1 or if request is not executed due to a network error */ @Expose({ groups: ['read', 'write'], since: 2 }) @IsOptional({ always: true }) @IsEnum(HttpStatus, { always: true }) httpStatus?: HttpStatus; @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsString({ always: true }) orderNumber: string; @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsString({ always: true }) orderId: string; @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsString({ always: true }) recipient_name: string; /** * Optional for backward compatibility with v1 * Can be undefined, if data from v1 or if request is not executed due to a network error */ @Expose({ groups: ['write'], since: 2 }) @IsOptional({ always: true }) request?: AxiosRequestConfig; /** * Can be undefined, if request is not executed due to a network error */ @Expose({ groups: ['write'] }) @IsOptional({ always: true }) response?: object; /** * Can be -1 if something went wrong */ @Expose({ groups: ['read', 'write'] }) @IsNotEmpty({ always: true }) @IsInt({ always: true }) retries: number; @Expose({ groups: ['write'], since: 2 }) @IsOptional({ always: true }) trace?: any[]; @Expose({ groups: ['read'], since: 2 }) @IsDate() readonly created_at: Date; @Expose({ groups: ['read'] }) @IsDate() readonly updated_at: Date; }