public JiraApiClient GetClientWithNewSettings(JiraSettings jiraSettings) { _jiraSettingsStorage.Set(jiraSettings); JiraApiClient result = new JiraApiClient(jiraSettings); return result; }
private void HandleOkClick(object sender, RoutedEventArgs e) { List<string> validationErrors = new List<string>(); if (!Uri.IsWellFormedUriString(_baseUrlTextBox.Text, UriKind.Absolute)) { validationErrors.Add("Base URL is invalid."); } if (string.IsNullOrEmpty(_userNameTextBox.Text)) { validationErrors.Add("User name cannot be empty."); } if (string.IsNullOrEmpty(_passwordBox.Password)) { validationErrors.Add("Password cannot be empty."); } if (validationErrors.Any()) { MessageBox.Show(this, string.Join(Environment.NewLine, validationErrors), "Invalid values", MessageBoxButton.OK, MessageBoxImage.Error); } else { ProvidedSettings = new JiraSettings(new Uri(_baseUrlTextBox.Text), _userNameTextBox.Text, _passwordBox.Password); DialogResult = true; } }
public JiraApiClient(JiraSettings jiraSettings) { _baseUrl = jiraSettings.BaseUrl; _restClient = new RestClient(new Uri(jiraSettings.BaseUrl, "rest/api/2")) { Authenticator = new HttpBasicAuthenticator(jiraSettings.UserName, jiraSettings.Password) }; _restClient.AddHandler("application/json", new DynamicJsonDeserializer()); }