public override async Task <ITraktEpisodeCheckinPostResponse> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var sharingReader = new SharingObjectJsonReader();
                var episodeReader = new EpisodeObjectJsonReader();
                var showReader    = new ShowObjectJsonReader();
                ITraktEpisodeCheckinPostResponse checkinEpisodeResponse = new TraktEpisodeCheckinPostResponse();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_ID:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedLongValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            checkinEpisodeResponse.Id = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_WATCHED_AT:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            checkinEpisodeResponse.WatchedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_SHARING:
                        checkinEpisodeResponse.Sharing = await sharingReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_EPISODE:
                        checkinEpisodeResponse.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SHOW:
                        checkinEpisodeResponse.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(checkinEpisodeResponse);
            }

            return(await Task.FromResult(default(ITraktEpisodeCheckinPostResponse)));
        }
        public override async Task <ITraktAuthorization> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktAuthorization)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktAuthorization traktAuthorization = new TraktAuthorization();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_ACCESS_TOKEN:
                        traktAuthorization.AccessToken = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_REFRESH_TOKEN:
                        traktAuthorization.RefreshToken = await jsonReader.ReadAsStringAsync(cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SCOPE:
                        traktAuthorization.Scope = await JsonReaderHelper.ReadEnumerationValueAsync <TraktAccessScope>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_EXPIRES_IN:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedIntegerValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktAuthorization.ExpiresInSeconds = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_TOKEN_TYPE:
                        traktAuthorization.TokenType = await JsonReaderHelper.ReadEnumerationValueAsync <TraktAccessTokenType>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_CREATED_AT:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedLongValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktAuthorization.CreatedAtTimestamp = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_IGNORE_EXPIRATION:
                        if (CompleteDeserialization)
                        {
                            bool?ignoreExpiration = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                            traktAuthorization.IgnoreExpiration = ignoreExpiration ?? false;
                        }
                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktAuthorization);
            }

            return(await Task.FromResult(default(ITraktAuthorization)));
        }
        public override async Task <ITraktEpisodeScrobblePostResponse> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var sharingReader = new SharingObjectJsonReader();
                var episodeReader = new EpisodeObjectJsonReader();
                var showReader    = new ShowObjectJsonReader();
                ITraktEpisodeScrobblePostResponse episodeScrobbleResponse = new TraktEpisodeScrobblePostResponse();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_ID:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedLongValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            episodeScrobbleResponse.Id = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_ACTION:
                        episodeScrobbleResponse.Action = await JsonReaderHelper.ReadEnumerationValueAsync <TraktScrobbleActionType>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_PROGRESS:
                    {
                        var value = await JsonReaderHelper.ReadFloatValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            episodeScrobbleResponse.Progress = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_SHARING:
                        episodeScrobbleResponse.Sharing = await sharingReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_EPISODE:
                        episodeScrobbleResponse.Episode = await episodeReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SHOW:
                        episodeScrobbleResponse.Show = await showReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(episodeScrobbleResponse);
            }

            return(await Task.FromResult(default(ITraktEpisodeScrobblePostResponse)));
        }
        public override async Task <ITraktHistoryItem> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            CheckJsonTextReader(jsonReader);

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                var movieObjectReader   = new MovieObjectJsonReader();
                var showObjectReader    = new ShowObjectJsonReader();
                var seasonObjectReader  = new SeasonObjectJsonReader();
                var episodeObjectReader = new EpisodeObjectJsonReader();

                ITraktHistoryItem traktHistoryItem = new TraktHistoryItem();

                while (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.PropertyName)
                {
                    var propertyName = jsonReader.Value.ToString();

                    switch (propertyName)
                    {
                    case JsonProperties.PROPERTY_NAME_ID:
                    {
                        var value = await JsonReaderHelper.ReadUnsignedLongValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktHistoryItem.Id = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_WATCHED_AT:
                    {
                        var value = await JsonReaderHelper.ReadDateTimeValueAsync(jsonReader, cancellationToken);

                        if (value.First)
                        {
                            traktHistoryItem.WatchedAt = value.Second;
                        }

                        break;
                    }

                    case JsonProperties.PROPERTY_NAME_ACTION:
                        traktHistoryItem.Action = await JsonReaderHelper.ReadEnumerationValueAsync <TraktHistoryActionType>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_TYPE:
                        traktHistoryItem.Type = await JsonReaderHelper.ReadEnumerationValueAsync <TraktSyncItemType>(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_MOVIE:
                        traktHistoryItem.Movie = await movieObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SHOW:
                        traktHistoryItem.Show = await showObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_SEASON:
                        traktHistoryItem.Season = await seasonObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    case JsonProperties.PROPERTY_NAME_EPISODE:
                        traktHistoryItem.Episode = await episodeObjectReader.ReadObjectAsync(jsonReader, cancellationToken);

                        break;

                    default:
                        await JsonReaderHelper.ReadAndIgnoreInvalidContentAsync(jsonReader, cancellationToken);

                        break;
                    }
                }

                return(traktHistoryItem);
            }

            return(await Task.FromResult(default(ITraktHistoryItem)));
        }