public ValidationResult Initialise(Uri apiEndpoint, string token,
                                           ForkMode?forkModeFromSettings, Platform?platformFromSettings)
        {
            var platformSettingsReader = FindPlatformSettingsReader(platformFromSettings, apiEndpoint);

            if (platformSettingsReader != null)
            {
                _platform = platformSettingsReader.Platform;
            }
            else
            {
                return(ValidationResult.Failure($"Unable to find collaboration platform for uri {apiEndpoint}"));
            }

            Settings.BaseApiUrl = UriFormats.EnsureTrailingSlash(apiEndpoint);
            Settings.Token      = token;
            Settings.ForkMode   = forkModeFromSettings;
            platformSettingsReader.UpdateCollaborationPlatformSettings(Settings);

            var result = ValidateSettings();

            if (!result.IsSuccess)
            {
                return(result);
            }

            CreateForPlatform();

            return(ValidationResult.Success);
        }
Beispiel #2
0
        public void TrailingSlashIsAddedWhenMissing()
        {
            var input = new Uri("http://test.com/api/path");

            var output = UriFormats.EnsureTrailingSlash(input);

            Assert.That(output.ToString(), Is.EqualTo("http://test.com/api/path/"));
        }
Beispiel #3
0
        public void Initialise(Uri apiEndpoint, string token, ForkMode?forkModeFromSettings)
        {
            var platformSettingsReader = SettingsReaderForPlatform(apiEndpoint);

            _platform = platformSettingsReader.Platform;

            _nuKeeperLogger.Normal($"Matched uri '{apiEndpoint}' to collaboration platform '{_platform}'");

            Settings.BaseApiUrl = UriFormats.EnsureTrailingSlash(apiEndpoint);
            Settings.Token      = token;
            Settings.ForkMode   = forkModeFromSettings;
            platformSettingsReader.UpdateCollaborationPlatformSettings(Settings);

            ValidateSettings();
            CreateForPlatform();
        }