| @@ -43,7 +43,7 @@ export class DistanceDonation extends Donation { | ||||
|   /** | ||||
|    * Turns this entity into it's response class. | ||||
|    */ | ||||
|   public toResponse() { | ||||
|     return new Error("NotImplemented"); | ||||
|   public toResponse(): DistanceDonation { | ||||
|     return null; | ||||
|   } | ||||
| } | ||||
|   | ||||
| @@ -3,6 +3,7 @@ import { | ||||
|   IsNotEmpty | ||||
| } from "class-validator"; | ||||
| import { Entity, ManyToOne, PrimaryGeneratedColumn, TableInheritance } from "typeorm"; | ||||
| import { ResponseDonation } from '../responses/ResponseDonation'; | ||||
| import { Donor } from './Donor'; | ||||
|  | ||||
| /** | ||||
| @@ -31,12 +32,13 @@ export abstract class Donation { | ||||
|    * The donation's amount in cents (or whatever your currency's smallest unit is.). | ||||
|    * The exact implementation may differ for each type of donation. | ||||
|    */ | ||||
|   abstract amount: number; | ||||
|   public abstract get amount(): number; | ||||
|  | ||||
|  | ||||
|   /** | ||||
|    * Turns this entity into it's response class. | ||||
|    */ | ||||
|   public toResponse() { | ||||
|     return new Error("NotImplemented"); | ||||
|   public toResponse(): ResponseDonation { | ||||
|     return new ResponseDonation(this); | ||||
|   } | ||||
| } | ||||
| @@ -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); | ||||
|   } | ||||
| } | ||||
| @@ -3,9 +3,9 @@ import { Donation } from '../entities/Donation'; | ||||
| import { ResponseDonor } from './ResponseDonor'; | ||||
| 
 | ||||
| /** | ||||
|  * Defines the donation response interface. | ||||
|  * Defines the donation response. | ||||
| */ | ||||
| export abstract class IResponseDonation { | ||||
| export class ResponseDonation { | ||||
|     /** | ||||
|      * The donation's id. | ||||
|      */ | ||||
| @@ -26,7 +26,7 @@ export abstract class IResponseDonation { | ||||
|     amount: number; | ||||
| 
 | ||||
|     /** | ||||
|      * Creates a IResponseDonation object from a scan. | ||||
|      * Creates a ResponseDonation object from a scan. | ||||
|      * @param donation The donation the response shall be build for. | ||||
|      */ | ||||
|     public constructor(donation: Donation) { | ||||
		Reference in New Issue
	
	Block a user