import { HttpClient } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { environment } from "src/environments/environment";

@Injectable()
export class HotelBookingManagementService {

    private headers = { 'Content-Type': 'application/json; charset=utf-8' };

    constructor(private http: HttpClient) {
        if(sessionStorage.getItem('userId')){
            this.headers['LoggedInUser'] = sessionStorage.getItem('userId');
        }
    }

    // listing page
    getAllAgency() {
        return this.http.get<any>(environment.APIBaseUrl + '/AgencyDetail/GetAllAffiliates', { headers: this.headers })
    }
    getAllCompany() {
        return this.http.get<any>(environment.APIBaseUrl + '/CompanyMaster/GetAllCompanyDetails', { headers: this.headers })
    }
    getAllEntity() {
        return this.http.get<any>(environment.APIBaseUrl + '/EntityMaster/GetAllEntity', { headers: this.headers })
    }
    getAllHotelSupplier() {
        return this.http.get<any>(environment.APIBaseUrl + '/HotelSupplier/GetAllHotelSupplier', { headers: this.headers })
    }
    getAllHotelSupplierV2() {
        return this.http.get<any>(environment.APIBaseUrl + '/HotelSupplierV2/GetAllHotelSupplierV2s', { headers: this.headers })
    }
    getAllHotelCountry() {
        return this.http.get<any>(environment.APIBaseUrl + '/hotel/CountryList/en', { headers: this.headers })
    }
    getAllHotelCityByCountry(country_code) {
        return this.http.get<any>(environment.APIBaseUrl + '/hotel/CityList/' + country_code+ '/en', { headers: this.headers })
    }
    getHotelBookingList(reqData) {
        return this.http.post<any>(environment.APIBaseUrl + '/HotelBooking/GetBookingList', reqData, { headers: this.headers })
    }
    bookingQualityCheck(trip_tbl_id) {
        return this.http.post<any>(environment.APIBaseUrl + '/Booking/UpdateQualityCheck/' + trip_tbl_id, null, { headers: this.headers })
    }

    // View page
    getAllCurrency() {
        return this.http.get<any>(environment.APIBaseUrl + '/CurrencyMaster/GetAllCurrencies', { headers: this.headers })
    }
    getCustomerDetails(trip_id) {
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/GetCustomerDetails/${trip_id}`, { headers: this.headers })
    }
    GetItenaryDetails(trip_id) {
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/GetItenaryDetails/${trip_id}`, { headers: this.headers })
    }
    getPassengerDetails(trip_id) {
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/GetPassengerDetails/${trip_id}`, { headers: this.headers })
    }
    getCostingDetails(trip_id) {
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/GetCostingDetails/${trip_id}`, { headers: this.headers })
    }
    getPaymentDetails(trip_id) {
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/GetPaymentDetails/${trip_id}`, { headers: this.headers })
    }
    getDocumentDetails(trip_id) {
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/GetDocumentDetails/${trip_id}`, { headers: this.headers })
    }
    getNotesDetail(trip_id) {
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/GetNotesDetail/${trip_id}`, { headers: this.headers })
    }
    getHotelBookingDetail(booking_id) {
        const org_id = sessionStorage.getItem('org_id');
        return this.http.get<any>(`${environment.hotelApiBaseUrl}/hotel/BookingDetails?org_id=${org_id}&booking_id=${booking_id}`, { headers: this.headers })
    }
    saveConfirmationNumber(reqData) {
        return this.http.post<any>(`${environment.APIBaseUrl}/HotelBooking/SaveConfirmationNumber`, reqData, { headers: this.headers })
    }
    saveNotesDetail(reqData){
        return this.http.post<any>(`${environment.APIBaseUrl}/HotelBooking/SaveNotesDetail`, reqData, { headers: this.headers })
    }
    printInvoiceDocument(document_number){
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/SendInvoiceEmail/${document_number}`, { headers: this.headers })
    }
    sendInvoiceDocumentMail(document_number, email_id){
        return this.http.get<any>(`${environment.APIBaseUrl}/HotelBooking/SendInvoiceEmail/${document_number}/${email_id}`, { headers: this.headers })
    }
    sendItineraryDocumentMail(reqData){
        return this.http.post<any>(`${environment.APIBaseUrl}/HotelBooking/SendItineraryEmail`, reqData, { headers: this.headers })
    }
    sendVoucherDocumentMail(reqData){
        return this.http.post<any>(`${environment.APIBaseUrl}/HotelBooking/SendVoucherEmail`, reqData, { headers: this.headers })
    }
    UpdateBooking(reqData){
        return this.http.post<any>(`${environment.APIBaseUrl}/HotelBooking/UpdateBooking`, reqData, { headers: this.headers })
    };
    GethotelCityName(reqData){
        return this.http.post<any>(`${environment.hotelApiBaseUrl}/hotel/hotelcitylist`, reqData, { headers: this.headers })
    };
    GetCancelBooking(reqData){
        return this.http.post<any>(`${environment.hotelApiBaseUrl}/hotel/cancelfee`, reqData, { headers: this.headers })
    };
}
