import BaseEntity from '../../common/entities/BaseEntity'; import ValidableInterface from '../../common/interfaces/ValidableInterface'; export default class Stop extends BaseEntity implements ValidableInterface { protected _name: string; protected _administrative_authority_name: string; protected _administrative_authority_id: string; protected _administrative_authority_full_name: string; protected _passenger_description: string; protected _driver_description: string; protected _latitude: string; protected _longitude: string; protected _address: string; protected _postal_code: string; protected _images: Array = []; protected _number_of_routes: number; protected _number_of_journeys: number; protected _stop_group_id: string; protected _stop_group_name: string; get name(): string { return this._name; } set name(value: string) { this._name = value; } get administrative_authority_name(): string { return this._administrative_authority_name; } set administrative_authority_name(value: string) { this._administrative_authority_name = value; } get administrative_authority_id(): string { return this._administrative_authority_id; } set administrative_authority_id(value: string) { this._administrative_authority_id = value; } get administrative_authority_full_name(): string { return this._administrative_authority_full_name; } set administrative_authority_full_name(value: string) { this._administrative_authority_full_name = value; } get passenger_description(): string { return this._passenger_description; } set passenger_description(value: string) { this._passenger_description = value; } get driver_description(): string { return this._driver_description; } set driver_description(value: string) { this._driver_description = value; } get latitude(): string { return this._latitude; } set latitude(value: string) { this._latitude = value; } get longitude(): string { return this._longitude; } set longitude(value: string) { this._longitude = value; } get address(): string { return this._address; } set address(value: string) { this._address = value; } get postal_code(): string { return this._postal_code; } set postal_code(value: string) { this._postal_code = value; } get images(): Array { return this._images; } set images(value: Array) { this._images = value; } get number_of_routes(): number { return this._number_of_routes; } set number_of_routes(value: number) { this._number_of_routes = value; } get number_of_journeys(): number { return this._number_of_journeys; } set number_of_journeys(value: number) { this._number_of_journeys = value; } get stop_group_id(): string { return this._stop_group_id; } set stop_group_id(value: string) { this._stop_group_id = value; } get stop_group_name(): string { return this._stop_group_name; } set stop_group_name(value: string) { this._stop_group_name = value; } getFullName(): string { if (this._stop_group_name) { return '[' + this._stop_group_name + ']' + ' ' + this._name; } return this._name; } isValid(): boolean { return this.invalidFields().length === 0; } invalidFields() { let fields = []; !this.name && fields.push('name'); !this.administrative_authority_name && fields.push('administrative_authority_name'); !this.address && fields.push('address'); !this.latitude && fields.push('latitude'); !this.longitude && fields.push('longitude'); !this.administrative_authority_id && fields.push('administrative_authority_id'); !this.administrative_authority_full_name && fields.push('administrative_authority_full_name'); !this.driver_description && fields.push('driver_description'); !this.passenger_description && fields.push('passenger_description'); return fields; } }