All files / app/classes wizard.class.ts

97.75% Statements 87/89
62.5% Branches 5/8
83.33% Functions 5/6
97.75% Lines 87/89

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 901x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 1x 1x     1x 35x 35x 1x 11x 11x 1x 1x 15x 15x 15x 15x 15x 1x 15x 15x 15x 1x  
import { TripInterface } from '../interfaces/trip.interface';
import { RoomClass } from './room.class';
 
export class WizardClass {
	id!: string;
	type!: string;
	city_ids!: string[];
	include_overnight!: number;
	purchased_flights!: boolean;
	days_set!: boolean;
	status!: string;
	min_trip_length!: number;
	currency_from_ip!: string;
	arrive_day!: string;
	depart_day!: string;
	arrive_city_id!: string;
	depart_city_id!: string;
	hotel_requested_stars!: number;
	hotel_include_breakfast!: boolean;
	hotel_include_non_refundable!: boolean;
	additional_comments!: string;
	additional_destinations!: string;
	trip_pace!: string;
	stage_of_trip!: string;
	max_budget_per_person!: number;
	currency!: string;
	budget_importance!: string;
	interests!: string[];
	hotel_requested_preferences!: string[];
	hotel_occupancy_rooms_count!: number;
	hotel_occupancy_rooms!: RoomClass[];
	finishRedirectUrl!: string;
	client_celebration!: string;
	hotel_requested_bed_preference!: string;
 
	fromJson(json: TripInterface): void {
		this.id = json.data.id;
		this.type = json.data.type;
 
		this.city_ids = json.data?.attributes['city-ids'];
		this.include_overnight = json.data?.attributes['include-overnight'];
		this.purchased_flights = json.data?.attributes['purchased-flights'];
		this.days_set = json.data?.attributes['days-set'];
		this.status = json.data?.attributes['status'];
		this.min_trip_length = json.data?.attributes['min-trip-length'];
		this.currency_from_ip = json.data?.attributes['currency-from-ip'];
		this.arrive_day = json.data?.attributes['arrive-day'];
		this.depart_day = json.data?.attributes['depart-day'];
		this.arrive_city_id = json.data?.attributes['arrive-city-id'];
		this.depart_city_id = json.data?.attributes['depart-city-id'];
		this.hotel_requested_stars = json.data?.attributes['hotel-requested-stars'];
		this.hotel_include_breakfast = json.data?.attributes['hotel-include-breakfast'];
		this.hotel_include_non_refundable = json.data?.attributes['hotel-include-non-refundable'];
		this.additional_comments = json.data?.attributes['additional-comments'];
		this.interests = json.data?.attributes['interest-ids'];
		this.hotel_requested_preferences = json.data?.attributes['hotel-requested-preferences'];
		this.additional_destinations = json.data?.attributes['additional-destinations'];
		this.trip_pace = json.data?.attributes['trip-pace'];
		this.stage_of_trip = json.data?.attributes['stage-of-trip'];
		this.max_budget_per_person = json.data?.attributes['max-budget-per-person'];
		this.budget_importance = json.data?.attributes['budget-importance'];
		this.finishRedirectUrl = json.data?.attributes['finish-redirect-url'];
		this.hotel_occupancy_rooms_count = json.data?.attributes['hotel-occupancy-rooms-count'];
		this.hotel_occupancy_rooms = json.data?.attributes['hotel-occupancy-rooms'].map((room) => new RoomClass(room));
		this.client_celebration = json.data?.attributes['client-celebration'];
		this.hotel_requested_bed_preference = json.data?.attributes['hotel-requested-bed-preference'];
	}
 
	getId(): string {
		return this.id;
	}
	getCities(): string[] {
		return this.city_ids;
	}
	getInterests(): string[] {
		return this.interests;
	}
 
	getDays(): number {
		const arrive = new Date(this.arrive_day);
		const depart = new Date(this.depart_day);
		const time = Math.abs(depart.getTime() - arrive.getTime());
		return Math.ceil(time / (1000 * 3600 * 24)) + 1;
	}
	getDaysString(): string {
		const days = this.getDays();
		return days + ' day' + (days > 1 ? 's' : '');
	}
}