import { ApiProperty } from '@nestjs/swagger' ; import BN from 'bn.js' ; import { Expose , Transform } from 'class-transformer' ; import { IsArray } from 'class-validator' ; import { CreateBidDTO } from '../order/create-bid.dto' ; export class DemandSummaryDTO < TProduct > { constructor ( bids ) { this . bids = bids ; } @ ApiProperty ( { type : [ CreateBidDTO ] } ) @ IsArray ( ) @ Expose ( ) bids : CreateBidDTO < TProduct > [ ] ; @ ApiProperty ( { type : String , example : '500' } ) @ Transform ( ( v ) => v . toString ( 10 ) ) @ Expose ( ) get volume ( ) : BN { return this . bids . reduce ( ( sum , item ) => sum . add ( new BN ( item . volume ) ) , new BN ( 0 ) ) ; } }