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

const liquidBaseUrl = '/api/liquid/user';

export class LRMApiIntercept {
  static interceptLRMApis() {
    SharedIntercepts.intercepts();

    // Heartbeat
    cy.intercept('POST', '/link/heartbeat').as('waitForLRMToken');

    // Save Business Contact Details
    cy.intercept('PUT', new RegExp(`${liquidBaseUrl}/upsell/businessInfo/complete`)).as(
      'waitForSaveBusinessContactDetails'
    );

    // Save Financial Details
    cy.intercept('PUT', new RegExp(`${liquidBaseUrl}/upsell/financialInfo/complete`)).as(
      'waitForSaveFinancialDetails'
    );

    // Ownership Info Application
    cy.intercept('PUT', new RegExp(`${liquidBaseUrl}/upsell/ownershipInfo/complete`)).as(
      'ownerShipInfoApplication'
    );

    // Save Executive Info Details
    cy.intercept('PUT', new RegExp(`${liquidBaseUrl}/upsell/executiveInfo/complete`)).as(
      'waitForSaveExecutiveInfoDetails'
    );

    // Iframe
    cy.intercept('POST', new RegExp(`${liquidBaseUrl}/plaid`)).as('waitForIframe');

    // Load Application
    cy.intercept('GET', '**/riskOps/selfSellApplications/*').as('selfSellApplications');

    // Upsell Liquid Application
    cy.intercept('POST', new RegExp(`${liquidBaseUrl}/upsell/liquidApplication`)).as(
      'upsellLiquidApplication'
    );
  }
}
