All files / app/services reviews.service.ts

44.44% Statements 32/72
100% Branches 3/3
50% Functions 2/4
44.44% Lines 32/72

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 731x 1x 1x 1x 1x 1x 1x 1x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x           17x 17x   17x 17x 17x 17x 17x 17x                                     17x 17x                                 17x  
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Injectable, inject } from '@angular/core';
import { environment } from '@environments/environment';
 
@Injectable({
	providedIn: 'root',
})
export class ReviewsService {
	private http = inject(HttpClient);
 
	private tripMenus: any;
	private isLoaded = false;
	headers: HttpHeaders = new HttpHeaders({
		Accept: 'application/vnd.api+json',
		'Content-Type': 'application/vnd.api+json',
	});
 
	getHomePageReviews(): any {
		return new Promise<any>((resolve, reject) => {
			this.http.get<any>(environment.apiBaseUrl + '/v3/marketing/traveler_reviews').subscribe(
				(response) => {
					if (response.success) {
						resolve(response);
					} else {
						reject();
					}
				},
				(error) => {
					reject(error);
				},
			);
		});
	}
 
	getTripDetailsPageReviews(cities: any[]): any {
		console.log(cities);
		return new Promise<any>((resolve, reject) => {
			this.http
				.get<any>(environment.apiBaseUrl + '/v3/marketing/traveler_reviews?cities=' + cities + '&marketing_trip=true')
				.subscribe(
					(response) => {
						if (response.success) {
							resolve(response);
						} else {
							reject();
						}
					},
					(error) => {
						reject(error);
					},
				);
		});
	}
 
	getCityDetailsPageReviews(cities: any): any {
		console.log(cities);
		return new Promise<any>((resolve, reject) => {
			this.http.get<any>(environment.apiBaseUrl + '/v3/marketing/traveler_reviews?cities=' + cities).subscribe(
				(response) => {
					if (response.success) {
						resolve(response);
					} else {
						reject();
					}
				},
				(error) => {
					reject(error);
				},
			);
		});
	}
}