import { guidRegex } from '@utility-lib/index';
import { SharedIntercepts } from '@intercepts-lib/index';

const hotelEndPoint = '/api/v1/trip/hotel';
export class HotelInterceptApis {
  static interceptHotelApis() {
    SharedIntercepts.intercepts();

    // ############################## HOTEL CONTRACTS ##############################
    cy.intercept(
      'GET',
      new RegExp(`${hotelEndPoint}/searches/${guidRegex}/contracts/${guidRegex}`)
    ).as('waitForHotelContract');
    cy.intercept(
      'POST',
      RegExp(
        `hotel/searches/${guidRegex}/hotels/${guidRegex}/rooms/${guidRegex}/contract`
      )
    ).as('waitForRoomSelected');

    // ############################## HOTEL TRIPS ##############################
    cy.intercept(
      'GET',
      new RegExp(`${hotelEndPoint}/searches/${guidRegex}/matchingTrips\\?.+`)
    ).as('waitForMatchingTrips');
    cy.intercept('GET', new RegExp('/api/user/trips/timeline\\?.+')).as(
      'waitForTripTimeline'
    );

    cy.intercept('GET', new RegExp('/api/invoices/v2/sync_status')).as(
      'waitForInvoiceSyncStatus'
    );

    //###################### HOTEL SEARCHES ##############################
    cy.intercept('POST', new RegExp(`${hotelEndPoint}/searches/`)).as('waitForCheckout');
    cy.intercept('GET', new RegExp(`${hotelEndPoint}/change/searches/`)).as(
      'waitForChangeHotel'
    );

    //###################### HOTEL BOOKING ##############################
    cy.intercept('DELETE', /api\/user\/trips/).as('waitForNewBookingCreated');
    cy.intercept('POST', /api\/v1\/trip\/tripFee\/searches/).as('bookedChangeHotel');
    cy.intercept(
      'GET',
      new RegExp(`trip/hotel/searches/${guidRegex}/hotels/${guidRegex}/recommendations`)
    ).as('waitForRecommendations');

    cy.intercept('GET', /api\/v1\/trip\/hotel\/extension\/searches/).as(
      'waitForExtendHotel'
    );
  }
}
