29 lines
		
	
	
		
			792 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			29 lines
		
	
	
		
			792 B
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { IsInt, IsPositive } from 'class-validator';
 | |
| import { FixedDonation } from '../../entities/FixedDonation';
 | |
| import { CreateDonation } from './CreateDonation';
 | |
| 
 | |
| /**
 | |
|  * This class is used to create a new FixedDonation entity from a json body (post request).
 | |
|  */
 | |
| export class CreateAnonymousDonation extends CreateDonation {
 | |
| 
 | |
|     /**
 | |
|      * The donation's amount.
 | |
|      * The unit is your currency's smallest unit (default: euro cent).
 | |
|      */
 | |
|     @IsInt()
 | |
|     @IsPositive()
 | |
|     amount: number;
 | |
| 
 | |
|     /**
 | |
|      * Creates a new FixedDonation entity from this.
 | |
|      */
 | |
|     public async toEntity(): Promise<FixedDonation> {
 | |
|         let newDonation = new FixedDonation;
 | |
| 
 | |
|         newDonation.amount = this.amount;
 | |
|         newDonation.paidAmount = this.amount;
 | |
| 
 | |
|         return newDonation;
 | |
|     }
 | |
| } |