Implemented the distance donation response

ref #66
This commit is contained in:
2021-01-12 18:20:36 +01:00
parent 6c53701a59
commit 55f72c35a6
2 changed files with 39 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
import { IsInt, IsObject, IsPositive } from 'class-validator';
import { DistanceDonation } from '../entities/DistanceDonation';
import { ResponseDonation } from './ResponseDonation';
import { ResponseRunner } from './ResponseRunner';
/**
* Defines the distance donation response.
*/
export class ResponseDistanceDonation extends ResponseDonation {
/**
* The donation's associated runner.
* Used as the source of the donation's distance.
*/
@IsObject()
runner: ResponseRunner;
/**
* The donation's amount donated per distance.
* The amount the donor set to be donated per kilometer that the runner ran.
*/
@IsInt()
@IsPositive()
amountPerDistance: number;
/**
* Creates a ResponseDistanceDonation object from a scan.
* @param donation The distance donation the response shall be build for.
*/
public constructor(donation: DistanceDonation) {
super(donation);
this.runner = donation.runner.toResponse();
this.amountPerDistance = donation.amountPerDistance;
}
}