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 (this.Url != null) {
    bool hasMatch = _LegacyPathRegex.hasMatch(this.Url!.path);
    if (hasMatch) {
      return this._GetLegacyUserSettingsAtUrl<TSettings>(
          newSettings, emailAddress, this.Url);
    }

    // this.Uri is intended for Autodiscover SOAP service, convert to Legacy endpoint URL.
    Uri autodiscoverUrl = UriHelper.concat(this.Url, _AutodiscoverLegacyPath);
    return this._GetLegacyUserSettingsAtUrl<TSettings>(
        newSettings, emailAddress, autodiscoverUrl);
  }

  // If Domain is specified, figure out the endpoint Url and call service.
  else if (!StringUtils.IsNullOrEmpty(this.Domain)) {
    Uri autodiscoverUrl = Uri.parse(
        _AutodiscoverLegacyHttpsUrl.replaceAll("{0}", this.Domain!));
    return this._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 this.InternalGetLegacyUserSettings<TSettings>(newSettings,
        emailAddress, redirectionEmailAddresses, currentHopOutParam);
  }
}