Implemented the donation response

ref #66
This commit is contained in:
2021-01-12 18:16:09 +01:00
parent 02bb634257
commit 6c53701a59
4 changed files with 31 additions and 11 deletions

View File

@@ -1,5 +1,6 @@
import { IsInt, IsPositive } from "class-validator";
import { ChildEntity, Column } from "typeorm";
import { ResponseDonation } from '../responses/ResponseDonation';
import { Donation } from "./Donation";
/**
@@ -11,16 +12,33 @@ export class FixedDonation extends Donation {
/**
* The donation's amount in cents (or whatever your currency's smallest unit is.).
* This is the "real" value used by fixed donations.
*/
@Column()
@IsInt()
@IsPositive()
amount: number;
private _amount: number;
/**
* The donation's amount in cents (or whatever your currency's smallest unit is.).
*/
@IsInt()
@IsPositive()
public get amount(): number {
return this._amount;
}
/**
* The donation's amount in cents (or whatever your currency's smallest unit is.).
*/
public set amount(value: number) {
this._amount = value;
}
/**
* Turns this entity into it's response class.
*/
public toResponse() {
return new Error("NotImplemented");
public toResponse(): ResponseDonation {
return new ResponseDonation(this);
}
}