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

const blackCarBaseUrlV1 = '/api/v1/trip/blackcar';
const blackCarBaseUrlV2 = '/api/v2/trip/blackcar';
export class BlackCarInterceptApis {
  static interceptBlackCarApis() {
    SharedIntercepts.intercepts();

    //################## BlackCar SEARCHES ##################

    cy.intercept('POST', new RegExp(`${blackCarBaseUrlV1}/searches/`)).as(
      'waitForCheckout'
    );
    cy.intercept('GET', new RegExp(`${blackCarBaseUrlV2}/searches/`)).as(
      'waitForBlackCarSearch'
    );
    cy.intercept(
      'GET',
      new RegExp(`${blackCarBaseUrlV1}/searches/${guidRegex}/contracts/${guidRegex}`)
    ).as('waitForBlackCarContract');
    cy.intercept(
      'GET',
      new RegExp(`${blackCarBaseUrlV1}/searches/${guidRegex}/matchingTrips\\?.+`)
    ).as('waitForBlackCarMatchingTrips');

    cy.intercept('GET', new RegExp(`/api/user/autocomplete/airline\\?.+`)).as(
      'waitForAirlines'
    );

    cy.intercept('POST', new RegExp('/user/promotions/llc/join')).as(
      'waitForPromotionsJoin'
    );
    cy.intercept('GET', new RegExp('api/delegate/delegatedUsers\\?.+')).as(
      'waitForDelegatedUsers'
    );
  }
}
