parent
5581c03f77
commit
02bb634257
37
src/models/responses/IResponseDonation.ts
Normal file
37
src/models/responses/IResponseDonation.ts
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
import { IsInt, IsNotEmpty, IsPositive } from "class-validator";
|
||||||
|
import { Donation } from '../entities/Donation';
|
||||||
|
import { ResponseDonor } from './ResponseDonor';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines the donation response interface.
|
||||||
|
*/
|
||||||
|
export abstract class IResponseDonation {
|
||||||
|
/**
|
||||||
|
* The donation's id.
|
||||||
|
*/
|
||||||
|
@IsInt()
|
||||||
|
@IsPositive()
|
||||||
|
id: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The donation's donor.
|
||||||
|
*/
|
||||||
|
@IsNotEmpty()
|
||||||
|
donor: ResponseDonor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The donation's amount in the smalles unit of your currency (default: euro cent).
|
||||||
|
*/
|
||||||
|
@IsInt()
|
||||||
|
amount: number;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a IResponseDonation object from a scan.
|
||||||
|
* @param donation The donation the response shall be build for.
|
||||||
|
*/
|
||||||
|
public constructor(donation: Donation) {
|
||||||
|
this.id = donation.id;
|
||||||
|
this.donor = donation.donor.toResponse();
|
||||||
|
this.amount = donation.amount;
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user