GetLegacyUserSettings<TSettings extends ConfigurationSettingsBase> method

Future<TSettings> GetLegacyUserSettings<TSettings extends ConfigurationSettingsBase>(
  1. TSettings newSettings,
  2. String emailAddress
)
Calls the legacy Autodiscover service to retrieve configuration settings. The email address to retrieve configuration settings for.

Implementation

Future<TSettings> GetLegacyUserSettings<
  TSettings extends ConfigurationSettingsBase
>(TSettings newSettings, String emailAddress) async {
  // If Url is specified, call service directly.
  if (Url != null) {
    bool hasMatch = _LegacyPathRegex.hasMatch(Url!.path);
    if (hasMatch) {
      return _GetLegacyUserSettingsAtUrl<TSettings>(
        newSettings,
        emailAddress,
        Url,
      );
    }

    // this.Uri is intended for Autodiscover SOAP service, convert to Legacy endpoint URL.
    Uri autodiscoverUrl = UriHelper.concat(Url, _AutodiscoverLegacyPath);
    return _GetLegacyUserSettingsAtUrl<TSettings>(
      newSettings,
      emailAddress,
      autodiscoverUrl,
    );
  }
  // If Domain is specified, figure out the endpoint Url and call service.
  else if (!StringUtils.IsNullOrEmpty(Domain)) {
    Uri autodiscoverUrl = Uri.parse(
      _AutodiscoverLegacyHttpsUrl.replaceAll("{0}", Domain!),
    );
    return _GetLegacyUserSettingsAtUrl<TSettings>(
      newSettings,
      emailAddress,
      autodiscoverUrl,
    );
  } else {
    // No Url or Domain specified, need to figure out which endpoint to use.
    OutParam<int> currentHopOutParam = OutParam()..param = 1;
    List<String> redirectionEmailAddresses = <String>[];
    return await InternalGetLegacyUserSettings<TSettings>(
      newSettings,
      emailAddress,
      redirectionEmailAddresses,
      currentHopOutParam,
    );
  }
}