示例#1
0
        private void SaveTraktUserSettings(ITraktUserSettings traktUserSettings, string path)
        {
            string serializedSettings = TraktSerializationService.SerializeAsync(traktUserSettings).Result;
            string settingsFilePath   = Path.Combine(path, FileName.UserSettings.Value);

            _fileOperations.FileWriteAllText(settingsFilePath, serializedSettings, Encoding.UTF8);
        }
示例#2
0
        public void AuthorizeUser()
        {
            try
            {
                ITraktAuthorization      authorization           = _traktClient.GetAuthorization(PinCode);
                ITraktUserSettings       traktUserSettings       = _traktClient.GetTraktUserSettings();
                ITraktSyncLastActivities traktSyncLastActivities = _traktClient.GetLastActivities();

                string traktUserHomePath = _mediaPortalServices.GetTraktUserHomePath();
                if (!_fileOperations.DirectoryExists(traktUserHomePath))
                {
                    _fileOperations.CreateDirectory(traktUserHomePath);
                }

                SaveTraktAuthorization(authorization, traktUserHomePath);
                SaveTraktUserSettings(traktUserSettings, traktUserHomePath);
                SaveLastSyncActivities(traktSyncLastActivities, traktUserHomePath);

                TestStatus       = "[Trakt.AuthorizationSucceed]";
                IsUserAuthorized = true;
            }
            catch (Exception ex)
            {
                TestStatus = "[Trakt.AuthorizationFailed]";
                _mediaPortalServices.GetLogger().Error(ex);
                IsUserAuthorized = false;
            }
        }
示例#3
0
        public async Task Test_TraktUsersModule_GetSettings()
        {
            TraktClient client = TestUtility.GetOAuthMockClient(GET_SETTINGS_URI, SETTINGS_JSON);
            TraktResponse <ITraktUserSettings> response = await client.Users.GetSettingsAsync();

            response.Should().NotBeNull();
            response.IsSuccess.Should().BeTrue();
            response.HasValue.Should().BeTrue();
            response.Value.Should().NotBeNull();

            ITraktUserSettings responseValue = response.Value;

            responseValue.User.Should().NotBeNull();
            responseValue.User.Username.Should().Be("justin");
            responseValue.User.IsPrivate.Should().BeFalse();
            responseValue.User.Name.Should().Be("Justin Nemeth");
            responseValue.User.IsVIP.Should().BeTrue();
            responseValue.User.IsVIP_EP.Should().BeFalse();
            responseValue.User.JoinedAt.Should().HaveValue().And.Be(DateTime.Parse("2010-09-25T17:49:25.000Z").ToUniversalTime());
            responseValue.User.Location.Should().Be("San Diego, CA");
            responseValue.User.About.Should().Be("Co-founder of trakt.");
            responseValue.User.Gender.Should().Be("male");
            responseValue.User.Age.Should().Be(32);
            responseValue.User.Images.Should().NotBeNull();
            responseValue.User.Images.Avatar.Should().NotBeNull();
            responseValue.User.Images.Avatar.Full.Should().Be("https://secure.gravatar.com/avatar/30c2f0dfbc39e48656f40498aa871e33?r=pg&s=256");
            responseValue.Account.Should().NotBeNull();
            responseValue.Account.TimeZoneId.Should().Be("America/Los_Angeles");
            responseValue.Account.Time24Hr.Should().BeFalse();
            responseValue.Account.CoverImage.Should().Be("https://walter.trakt.us/images/movies/000/001/545/fanarts/original/0abb604492.jpg?1406095042");
            responseValue.Connections.Should().NotBeNull();
            responseValue.Connections.Facebook.Should().BeTrue();
            responseValue.Connections.Twitter.Should().BeTrue();
            responseValue.Connections.Google.Should().BeTrue();
            responseValue.Connections.Tumblr.Should().BeFalse();
            responseValue.Connections.Medium.Should().BeFalse();
            responseValue.Connections.Slack.Should().BeFalse();
            responseValue.SharingText.Should().NotBeNull();
            responseValue.SharingText.Watching.Should().Be("I'm watching [item]");
            responseValue.SharingText.Watched.Should().Be("I just watched [item]");
        }