Class VCR

java.lang.Object
com.easypost.easyvcr.VCR

public final class VCR extends Object
Built-in VCR tool for EasyVCR.
  • Constructor Details

    • VCR

      public VCR(AdvancedSettings advancedSettings)
      Constructor for VCR.
      Parameters:
      advancedSettings - Advanced settings for the VCR.
    • VCR

      public VCR()
      Constructor for VCR.
  • Method Details

    • getCassetteName

      public String getCassetteName()
      Gets the name of the current cassette in the VCR.
      Returns:
      The name of the current cassette in the VCR.
    • getHttpUrlConnection

      public RecordableURL getHttpUrlConnection(URL url) throws MalformedURLException, VCRException
      Retrieve a pre-configured RecordableURL object that will use the VCR.
      Parameters:
      url - The URL to use to create the RecordableURL object.
      Returns:
      A pre-configured RecordableURL object that will use the VCR.
      Throws:
      MalformedURLException - If the URL is malformed.
      VCRException - If the cassette is not loaded.
    • getHttpUrlConnection

      public RecordableURL getHttpUrlConnection(String url) throws MalformedURLException, VCRException
      Retrieve a pre-configured RecordableURL object that will use the VCR.
      Parameters:
      url - The URL string to use to create the RecordableURL object.
      Returns:
      A pre-configured RecordableURL object that will use the VCR.
      Throws:
      MalformedURLException - If the URL is malformed.
      VCRException - If the cassette is not loaded.
    • getMode

      public Mode getMode()
      Gets the current operating mode of the VCR.
      Returns:
      The current operating mode of the VCR.
    • getAdvancedSettings

      public AdvancedSettings getAdvancedSettings()
      Get the advanced settings for the VCR.
      Returns:
      Advanced settings for the VCR.
    • setAdvancedSettings

      public void setAdvancedSettings(AdvancedSettings advancedSettings)
      Set the advanced settings for the VCR.
      Parameters:
      advancedSettings - Advanced settings for the VCR.
    • eject

      public void eject()
      Remove the current cassette from the VCR.
    • erase

      public void erase()
      Erase the cassette in the VCR.
    • insert

      public void insert(Cassette cassette)
      Add a cassette to the VCR (or replace the current one).
      Parameters:
      cassette - The cassette to add to the VCR.
    • pause

      public void pause()
      Enable passthrough mode on the VCR (HTTP requests will be made as normal).
    • record

      public void record()
      Enable recording mode on the VCR.
    • replay

      public void replay()
      Enable playback mode on the VCR.
    • recordIfNeeded

      public void recordIfNeeded()
      Enable auto mode on the VCR (record if needed, replay otherwise).