code: public void alternateCalls(
              String connId,
              String heldConnId,
              KeyValueCollection reasons,
              KeyValueCollection extensions
      ) throws WorkspaceApiException {
          try {
              VoicecallsidalternateData alternateData = new VoicecallsidalternateData();
              alternateData.setHeldConnId(heldConnId);
              alternateData.setReasons(Util.toKVList(reasons));
              alternateData.setExtensions(Util.toKVList(extensions));
              AlternateData data = new AlternateData();
              data.data(alternateData);
  
              ApiSuccessResponse response = this.voiceApi.alternate(connId, data);
              throwIfNotOk("alternateCalls", response);
          } catch (ApiException e) {
              throw new WorkspaceApiException("alternateCalls failed.", e);
          }
      }
docs: Alternate two calls so that you retrieve a call on hold and place the established call on hold instead.
  This is a shortcut for doing `holdCall()` and `retrieveCall()` separately.
  @param connId The connection ID of the established call that should be placed on hold.
  @param heldConnId The connection ID of the held call that should be retrieved.
  @param reasons Information on causes for, and results of, actions taken by the user of the current DN. For details about reasons, refer to the [*Genesys Events and Models Reference Manual*](https://docs.genesys.com/Documentation/System/Current/GenEM/Reasons). (optional)
  @param extensions Media device/hardware reason codes and similar information. For details about extensions, refer to the [*Genesys Events and Models Reference Manual*](https://docs.genesys.com/Documentation/System/Current/GenEM/Extensions). (optional)