import {UploadMetaModel} from './uploadMetaModel';
import {PayInModel} from './pay-in.model';
import {PayInAAARowModel} from './Pay.In.AAA.Row.model';



export class UploadAnalysisModel {
  public Id: number;
  public Funders: string[];
  public Mime: string;
  public PayIn: PayInModel[];

  public AAA?: PayInAAARowModel[];

  public IsDuplicate: boolean;
  public Uid?: string;  // client side unique id when upload
  public Input?: UploadMetaModel;

  constructor(payload: Partial<UploadAnalysisModel>){
    this.Id = payload.Id || 0 ;
    this.Funders = payload.Funders || [];
    this.Mime = payload.Mime || '';
    if ( payload.PayIn && payload.PayIn.length > 0 ) {
      this.PayIn = [];
    }else{
      this.PayIn = [];
      if ( payload.PayIn ) {
        payload.PayIn.forEach(
          v => {
            const pi = new PayInModel(v);
            this.PayIn.push(pi);
          }
        );
      }
    }

    this.AAA = [];
    if ( payload.AAA ) {
      payload.AAA.forEach( v => { this.AAA.push(new PayInAAARowModel(v)); });
    }

    this.IsDuplicate = payload.IsDuplicate || false;
    this.Uid = payload.Uid || '' ;
    this.Input = new UploadMetaModel(payload.Input || {});
  }

}
