Example #1
0
 public async Task Test_SharingObjectJsonWriter_WriteObject_StringWriter_Exceptions()
 {
     var                   traktJsonWriter = new SharingObjectJsonWriter();
     ITraktSharing         traktSharing    = new TraktSharing();
     Func <Task <string> > action          = () => traktJsonWriter.WriteObjectAsync(default(StringWriter), traktSharing);
     await action.Should().ThrowAsync <ArgumentNullException>();
 }
        public override async Task <ITraktSharing> ReadObjectAsync(JsonTextReader jsonReader, CancellationToken cancellationToken = default)
        {
            if (jsonReader == null)
            {
                return(await Task.FromResult(default(ITraktSharing)));
            }

            if (await jsonReader.ReadAsync(cancellationToken) && jsonReader.TokenType == JsonToken.StartObject)
            {
                ITraktSharing traktSharing = new TraktSharing();

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

                    switch (propertyName)
                    {
                    case JsonProperties.SHARING_PROPERTY_NAME_FACEBOOK:
                        traktSharing.Facebook = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_TWITTER:
                        traktSharing.Twitter = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_GOOGLE:
                        traktSharing.Google = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_TUMBLR:
                        traktSharing.Tumblr = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_MEDIUM:
                        traktSharing.Medium = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

                    case JsonProperties.SHARING_PROPERTY_NAME_SLACK:
                        traktSharing.Slack = await jsonReader.ReadAsBooleanAsync(cancellationToken);

                        break;

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

                        break;
                    }
                }

                return(traktSharing);
            }

            return(await Task.FromResult(default(ITraktSharing)));
        }
        public void TestTraktMovieCommentPostWriteJson()
        {
            var comment = "this is a comment";
            var spoiler = true;
            var sharing = new TraktSharing {
                Facebook = true, Twitter = true, Tumblr = true
            };

            var movieTitle   = "Guardians of the Galaxy";
            var movieYear    = 2014;
            var movieTraktId = 28U;
            var movieSlug    = "guardiangs-of-the-galaxy-2014";
            var movieImdb    = "tt2015381";
            var movieTmdb    = 118340U;

            var movie = new TraktMovie
            {
                Title = movieTitle,
                Year  = movieYear,
                Ids   = new TraktMovieIds
                {
                    Trakt = movieTraktId,
                    Slug  = movieSlug,
                    Imdb  = movieImdb,
                    Tmdb  = movieTmdb
                }
            };

            var movieComment = new TraktMovieCommentPost
            {
                Comment = comment,
                Spoiler = spoiler,
                Sharing = sharing,
                Movie   = movie
            };

            var strJson = JsonConvert.SerializeObject(movieComment);

            strJson.Should().NotBeNullOrEmpty();

            var movieCommentFromJson = JsonConvert.DeserializeObject <TraktMovieCommentPost>(strJson);

            movieCommentFromJson.Should().NotBeNull();
            movieCommentFromJson.Comment.Should().Be(comment);
            movieCommentFromJson.Spoiler.Should().Be(spoiler);
            movieCommentFromJson.Sharing.Should().NotBeNull();
            movieCommentFromJson.Sharing.Facebook.Should().BeTrue();
            movieCommentFromJson.Sharing.Twitter.Should().BeTrue();
            movieCommentFromJson.Sharing.Tumblr.Should().BeTrue();

            movieCommentFromJson.Movie.Should().NotBeNull();
            movieCommentFromJson.Movie.Title.Should().Be(movieTitle);
            movieCommentFromJson.Movie.Year.Should().Be(movieYear);
            movieCommentFromJson.Movie.Ids.Should().NotBeNull();
            movieCommentFromJson.Movie.Ids.Trakt.Should().Be(movieTraktId);
            movieCommentFromJson.Movie.Ids.Slug.Should().Be(movieSlug);
            movieCommentFromJson.Movie.Ids.Imdb.Should().Be(movieImdb);
            movieCommentFromJson.Movie.Ids.Tmdb.Should().Be(movieTmdb);
        }
        public void Test_SharingObjectJsonWriter_WriteObject_JsonWriter_Exceptions()
        {
            var           traktJsonWriter = new SharingObjectJsonWriter();
            ITraktSharing traktSharing    = new TraktSharing();
            Func <Task>   action          = () => traktJsonWriter.WriteObjectAsync(default(JsonTextWriter), traktSharing);

            action.Should().Throw <ArgumentNullException>();
        }
Example #5
0
        public void Test_TraktSharing_Default_Constructor()
        {
            var traktSharing = new TraktSharing();

            traktSharing.Twitter.Should().BeNull();
            traktSharing.Google.Should().BeNull();
            traktSharing.Tumblr.Should().BeNull();
            traktSharing.Medium.Should().BeNull();
            traktSharing.Slack.Should().BeNull();
        }
        public void TestTraktSharingDefaultConstructor()
        {
            var sharing = new TraktSharing();

            sharing.Facebook.Should().NotHaveValue();
            sharing.Twitter.Should().NotHaveValue();
            sharing.Google.Should().NotHaveValue();
            sharing.Tumblr.Should().NotHaveValue();
            sharing.Medium.Should().NotHaveValue();
            sharing.Slack.Should().NotHaveValue();
        }
        public async Task Test_SharingObjectJsonWriter_WriteObject_Object_Only_Slack_Property()
        {
            ITraktSharing traktSharing = new TraktSharing
            {
                Slack = true
            };

            var    traktJsonWriter = new SharingObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktSharing);

            json.Should().Be(@"{""slack"":true}");
        }
Example #8
0
        public async Task Test_SharingObjectJsonWriter_WriteObject_StringWriter_Only_Medium_Property()
        {
            ITraktSharing traktSharing = new TraktSharing
            {
                Medium = true
            };

            using (var stringWriter = new StringWriter())
            {
                var    traktJsonWriter = new SharingObjectJsonWriter();
                string json            = await traktJsonWriter.WriteObjectAsync(stringWriter, traktSharing);

                json.Should().Be(@"{""medium"":true}");
            }
        }
        public void TestTraktShowCommentPostWriteJson()
        {
            var comment = "this is a comment";
            var spoiler = true;
            var sharing = new TraktSharing {
                Facebook = false, Twitter = false, Tumblr = true
            };

            var showTitle   = "Breaking Bad";
            var showTraktId = 1U;
            var showSlug    = "breaking-bad";

            var show = new TraktShow
            {
                Title = showTitle,
                Ids   = new TraktShowIds {
                    Trakt = showTraktId, Slug = showSlug
                }
            };

            var showComment = new TraktShowCommentPost
            {
                Comment = comment,
                Spoiler = spoiler,
                Sharing = sharing,
                Show    = show
            };

            var strJson = JsonConvert.SerializeObject(showComment);

            strJson.Should().NotBeNullOrEmpty();

            var showCommentFromJson = JsonConvert.DeserializeObject <TraktShowCommentPost>(strJson);

            showCommentFromJson.Should().NotBeNull();
            showCommentFromJson.Comment.Should().Be(comment);
            showCommentFromJson.Spoiler.Should().Be(spoiler);
            showCommentFromJson.Sharing.Should().NotBeNull();
            showCommentFromJson.Sharing.Facebook.Should().BeFalse();
            showCommentFromJson.Sharing.Twitter.Should().BeFalse();
            showCommentFromJson.Sharing.Tumblr.Should().BeTrue();

            showCommentFromJson.Show.Should().NotBeNull();
            showCommentFromJson.Show.Title.Should().Be(showTitle);
            showCommentFromJson.Show.Ids.Should().NotBeNull();
            showCommentFromJson.Show.Ids.Trakt.Should().Be(showTraktId);
            showCommentFromJson.Show.Ids.Slug.Should().Be(showSlug);
        }
        public async Task Test_SharingObjectJsonWriter_WriteObject_JsonWriter_Only_Slack_Property()
        {
            ITraktSharing traktSharing = new TraktSharing
            {
                Slack = true
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new SharingObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktSharing);

                    stringWriter.ToString().Should().Be(@"{""slack"":true}");
                }
        }
        public async Task Test_SharingObjectJsonWriter_WriteObject_Object_Complete()
        {
            ITraktSharing traktSharing = new TraktSharing
            {
                Facebook = true,
                Twitter  = true,
                Google   = true,
                Tumblr   = true,
                Medium   = true,
                Slack    = true
            };

            var    traktJsonWriter = new SharingObjectJsonWriter();
            string json            = await traktJsonWriter.WriteObjectAsync(traktSharing);

            json.Should().Be(@"{""facebook"":true,""twitter"":true,""google"":true," +
                             @"""tumblr"":true,""medium"":true,""slack"":true}");
        }
        public void TestTraktEpisodeCommentPostWriteJson()
        {
            var comment = "this is a comment";
            var spoiler = false;
            var sharing = new TraktSharing {
                Facebook = true, Twitter = false, Tumblr = true
            };

            var episodeTraktId = 16U;

            var episode = new TraktEpisode {
                Ids = new TraktEpisodeIds {
                    Trakt = episodeTraktId
                }
            };

            var episodeComment = new TraktEpisodeCommentPost
            {
                Comment = comment,
                Spoiler = spoiler,
                Sharing = sharing,
                Episode = episode
            };

            var strJson = JsonConvert.SerializeObject(episodeComment);

            strJson.Should().NotBeNullOrEmpty();

            var episodeCommentFromJson = JsonConvert.DeserializeObject <TraktEpisodeCommentPost>(strJson);

            episodeCommentFromJson.Should().NotBeNull();
            episodeCommentFromJson.Comment.Should().Be(comment);
            episodeCommentFromJson.Spoiler.Should().Be(spoiler);
            episodeCommentFromJson.Sharing.Should().NotBeNull();
            episodeCommentFromJson.Sharing.Facebook.Should().BeTrue();
            episodeCommentFromJson.Sharing.Twitter.Should().BeFalse();
            episodeCommentFromJson.Sharing.Tumblr.Should().BeTrue();

            episodeCommentFromJson.Episode.Should().NotBeNull();
            episodeCommentFromJson.Episode.Ids.Should().NotBeNull();
            episodeCommentFromJson.Episode.Ids.Trakt.Should().Be(episodeTraktId);
        }
        public async Task Test_SharingObjectJsonWriter_WriteObject_JsonWriter_Complete()
        {
            ITraktSharing traktSharing = new TraktSharing
            {
                Twitter = true,
                Google  = true,
                Tumblr  = true,
                Medium  = true,
                Slack   = true
            };

            using (var stringWriter = new StringWriter())
                using (var jsonWriter = new JsonTextWriter(stringWriter))
                {
                    var traktJsonWriter = new SharingObjectJsonWriter();
                    await traktJsonWriter.WriteObjectAsync(jsonWriter, traktSharing);

                    stringWriter.ToString().Should().Be(@"{""twitter"":true,""google"":true," +
                                                        @"""tumblr"":true,""medium"":true,""slack"":true}");
                }
        }
        public async Task <TraktCommentPostResponse> PostListCommentAsync([NotNull] TraktList list, [NotNull] string comment,
                                                                          bool?containsSpoiler = null, TraktSharing sharing = null)
        {
            ValidateList(list);
            ValidateComment(comment);

            return(await QueryAsync(new TraktCommentPostRequest <TraktListCommentPost>(Client)
            {
                RequestBody = new TraktListCommentPost
                {
                    List = new TraktList {
                        Ids = list.Ids
                    },
                    Comment = comment,
                    Spoiler = containsSpoiler,
                    Sharing = sharing
                }
            }));
        }
        public async Task <TraktCommentPostResponse> PostEpisodeCommentAsync([NotNull] TraktEpisode episode, [NotNull] string comment,
                                                                             bool?containsSpoiler = null, TraktSharing sharing = null)
        {
            ValidateEpisode(episode);
            ValidateComment(comment);

            return(await QueryAsync(new TraktCommentPostRequest <TraktEpisodeCommentPost>(Client)
            {
                RequestBody = new TraktEpisodeCommentPost
                {
                    Episode = new TraktEpisode {
                        Ids = episode.Ids
                    },
                    Comment = comment,
                    Spoiler = containsSpoiler,
                    Sharing = sharing
                }
            }));
        }
        public async Task <TraktCommentPostResponse> PostSeasonCommentAsync([NotNull] TraktSeason season, [NotNull] string comment,
                                                                            bool?containsSpoiler = null, TraktSharing sharing = null)
        {
            ValidateSeason(season);
            ValidateComment(comment);

            return(await QueryAsync(new TraktCommentPostRequest <TraktSeasonCommentPost>(Client)
            {
                RequestBody = new TraktSeasonCommentPost
                {
                    Season = new TraktSeason {
                        Ids = season.Ids
                    },
                    Comment = comment,
                    Spoiler = containsSpoiler,
                    Sharing = sharing
                }
            }));
        }
        public async Task <TraktCommentPostResponse> PostShowCommentAsync([NotNull] TraktShow show, [NotNull] string comment,
                                                                          bool?containsSpoiler = null, TraktSharing sharing = null)
        {
            ValidateShow(show);
            ValidateComment(comment);

            return(await QueryAsync(new TraktCommentPostRequest <TraktShowCommentPost>(Client)
            {
                RequestBody = new TraktShowCommentPost
                {
                    Show = new TraktShow
                    {
                        Title = show.Title,
                        Ids = show.Ids
                    },
                    Comment = comment,
                    Spoiler = containsSpoiler,
                    Sharing = sharing
                }
            }));
        }
        public async Task <TraktCommentPostResponse> PostMovieCommentAsync([NotNull] TraktMovie movie, [NotNull] string comment,
                                                                           bool?containsSpoiler = null, TraktSharing sharing = null)
        {
            ValidateMovie(movie);
            ValidateComment(comment);

            return(await QueryAsync(new TraktCommentPostRequest <TraktMovieCommentPost>(Client)
            {
                RequestBody = new TraktMovieCommentPost
                {
                    Movie = new TraktMovie
                    {
                        Title = movie.Title,
                        Year = movie.Year,
                        Ids = movie.Ids
                    },
                    Comment = comment,
                    Spoiler = containsSpoiler,
                    Sharing = sharing
                }
            }));
        }
Example #19
0
        public async Task <TraktMovieCheckinPostResponse> CheckIntoMovieAsync([NotNull] TraktMovie movie, string appVersion = null, DateTime?appBuildDate = null,
                                                                              string message           = null, TraktSharing sharing = null,
                                                                              string foursquareVenueID = null, string foursquareVenueName = null)
        {
            Validate(movie);

            var requestBody = new TraktMovieCheckinPost
            {
                Movie = new TraktMovie
                {
                    Title = movie.Title,
                    Year  = movie.Year,
                    Ids   = movie.Ids
                },
                Message             = message,
                Sharing             = sharing,
                FoursquareVenueId   = foursquareVenueID,
                FoursquareVenueName = foursquareVenueName
            };

            if (!string.IsNullOrEmpty(appVersion))
            {
                requestBody.AppVersion = appVersion;
            }

            if (appBuildDate.HasValue)
            {
                requestBody.AppDate = appBuildDate.Value.ToTraktDateString();
            }

            return(await QueryAsync(new TraktCheckinRequest <TraktMovieCheckinPostResponse, TraktMovieCheckinPost>(Client)
            {
                RequestBody = requestBody
            }));
        }
Example #20
0
        public async Task <TraktEpisodeCheckinPostResponse> CheckIntoEpisodeWithShowAsync([NotNull] TraktEpisode episode, [NotNull] TraktShow show,
                                                                                          string appVersion        = null, DateTime?appBuildDate      = null,
                                                                                          string message           = null, TraktSharing sharing       = null,
                                                                                          string foursquareVenueID = null, string foursquareVenueName = null)
        {
            Validate(episode, show);

            var requestBody = new TraktEpisodeCheckinPost
            {
                Episode = new TraktEpisode
                {
                    Ids          = episode.Ids,
                    SeasonNumber = episode.SeasonNumber,
                    Number       = episode.Number
                },
                Show = new TraktShow {
                    Title = show.Title
                },
                Message             = message,
                Sharing             = sharing,
                FoursquareVenueId   = foursquareVenueID,
                FoursquareVenueName = foursquareVenueName
            };

            if (!string.IsNullOrEmpty(appVersion))
            {
                requestBody.AppVersion = appVersion;
            }

            if (appBuildDate.HasValue)
            {
                requestBody.AppDate = appBuildDate.Value.ToTraktDateString();
            }

            return(await QueryAsync(new TraktCheckinRequest <TraktEpisodeCheckinPostResponse, TraktEpisodeCheckinPost>(Client)
            {
                RequestBody = requestBody
            }));
        }
Example #21
0
 /// <summary>Check into an episode. This should be tied to a user action to manually indicate they are watching something.
 /// The item will display as watching on the site, then automatically switch to watched status once the duration has elapsed.</summary>
 /// <param name="episodeId">The episode ID</param>
 /// <param name="episodeIdType">The episode ID type</param>
 /// <param name="sharing">Control sharing to any connected social networks</param>
 /// <param name="message">Message used for sharing. If not sent, it will use the watching string in the user settings.</param>
 /// <param name="venueId">Foursquare venue ID</param>
 /// <param name="venueName">Foursquare venue name</param>
 /// <param name="appVersion">Version number of the app</param>
 /// <param name="appDate">Build date of the app</param>
 /// <param name="extended">Changes which properties are populated for standard media objects. By default, minimal data is returned. Change this if additional fields are required in the returned data.</param>
 /// <returns>See summary</returns>
 public async Task <TraktCheckinEpisodeResponse> CheckinEpisodeAsync(string episodeId, TraktTextEpisodeIdType episodeIdType, TraktSharing sharing = null, string message = "", string venueId = "", string venueName = "", string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await CheckinEpisodeAsync(TraktEpisodeFactory.FromId(episodeId, episodeIdType), null, sharing, message, venueId, venueName, appVersion, appDate, extended));
 }
Example #22
0
 /// <summary>Check into a movie. This should be tied to a user action to manually indicate they are watching something.
 /// The item will display as watching on the site, then automatically switch to watched status once the duration has elapsed.</summary>
 /// <param name="movie">The movie</param>
 /// <param name="sharing">Control sharing to any connected social networks</param>
 /// <param name="message">Message used for sharing. If not sent, it will use the watching string in the user settings.</param>
 /// <param name="venueId">Foursquare venue ID</param>
 /// <param name="venueName">Foursquare venue name</param>
 /// <param name="appVersion">Version number of the app</param>
 /// <param name="appDate">Build date of the app</param>
 /// <param name="extended">Changes which properties are populated for standard media objects. By default, minimal data is returned. Change this if additional fields are required in the returned data.</param>
 /// <returns>See summary</returns>
 public async Task <TraktCheckinMovieResponse> CheckinMovieAsync(TraktMovie movie, TraktSharing sharing = null, string message = "", string venueId = "", string venueName = "", string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await SendAsync(new TraktCheckinMovieRequest(Client) {
         RequestBody = new TraktCheckinMovieRequestBody {
             Movie = movie,
             Sharing = sharing,
             Message = message,
             AppVersion = appVersion,
             AppDate = appDate,
             VenueId = venueId,
             VenueName = venueName
         },
         Extended = extended
     }));
 }
Example #23
0
        public void TestTraktEpisodeCheckinPostWriteJson()
        {
            var sharing = new TraktSharing {
                Facebook = true, Twitter = false, Tumblr = true
            };
            var message    = "checkin in now";
            var appVersion = "App Version 1.0.0";
            var appDate    = DateTime.UtcNow.ToString("yyyy-MM-dd");
            var venueId    = "venue id";
            var venueName  = "venue name";

            var episodeNr      = 1;
            var seasonNr       = 1;
            var episodeTitle   = "Pilot";
            var episodeTraktId = 16U;
            var episodeTvdb    = 349232U;
            var episodeImdb    = "tt0959621";
            var episodeTmdb    = 62085U;
            var episodeTvRage  = 637041U;

            var showTitle   = "Breaking Bad";
            var showYear    = 2008;
            var showTraktId = 1U;
            var showSlug    = "breaking-bad";
            var showTvdb    = 81189U;
            var showImdb    = "tt0903747";
            var showTmdb    = 1396U;
            var showTvRage  = 18164U;

            var episode = new TraktEpisode
            {
                SeasonNumber = seasonNr,
                Number       = episodeNr,
                Title        = episodeTitle,
                Ids          = new TraktEpisodeIds
                {
                    Trakt  = episodeTraktId,
                    Tvdb   = episodeTvdb,
                    Imdb   = episodeImdb,
                    Tmdb   = episodeTmdb,
                    TvRage = episodeTvRage
                }
            };

            var show = new TraktShow
            {
                Title = showTitle,
                Year  = showYear,
                Ids   = new TraktShowIds
                {
                    Trakt  = showTraktId,
                    Slug   = showSlug,
                    Tvdb   = showTvdb,
                    Imdb   = showImdb,
                    Tmdb   = showTmdb,
                    TvRage = showTvRage
                }
            };

            var episodeCheckin = new TraktEpisodeCheckinPost
            {
                Sharing             = sharing,
                Message             = message,
                AppVersion          = appVersion,
                AppDate             = appDate,
                FoursquareVenueId   = venueId,
                FoursquareVenueName = venueName,
                Episode             = episode,
                Show = show
            };

            var strJson = JsonConvert.SerializeObject(episodeCheckin);

            strJson.Should().NotBeNullOrEmpty();

            var episodeCheckinFromJson = JsonConvert.DeserializeObject <TraktEpisodeCheckinPost>(strJson);

            episodeCheckinFromJson.Should().NotBeNull();
            episodeCheckinFromJson.Sharing.Should().NotBeNull();
            episodeCheckinFromJson.Sharing.Facebook.Should().BeTrue();
            episodeCheckinFromJson.Sharing.Twitter.Should().BeFalse();
            episodeCheckinFromJson.Sharing.Tumblr.Should().BeTrue();
            episodeCheckinFromJson.Message.Should().Be(message);
            episodeCheckinFromJson.AppVersion.Should().Be(appVersion);
            episodeCheckinFromJson.AppDate.Should().NotBeNull().And.NotBeEmpty().And.Be(appDate);
            episodeCheckinFromJson.FoursquareVenueId.Should().Be(venueId);
            episodeCheckinFromJson.FoursquareVenueName.Should().Be(venueName);

            episodeCheckinFromJson.Episode.Should().NotBeNull();
            episodeCheckinFromJson.Episode.SeasonNumber.Should().Be(seasonNr);
            episodeCheckinFromJson.Episode.Number.Should().Be(episodeNr);
            episodeCheckinFromJson.Episode.Title.Should().Be(episodeTitle);
            episodeCheckinFromJson.Episode.Ids.Should().NotBeNull();
            episodeCheckinFromJson.Episode.Ids.Trakt.Should().Be(episodeTraktId);
            episodeCheckinFromJson.Episode.Ids.Tvdb.Should().Be(episodeTvdb);
            episodeCheckinFromJson.Episode.Ids.Imdb.Should().Be(episodeImdb);
            episodeCheckinFromJson.Episode.Ids.Tmdb.Should().Be(episodeTmdb);
            episodeCheckinFromJson.Episode.Ids.TvRage.Should().Be(episodeTvRage);

            episodeCheckinFromJson.Show.Should().NotBeNull();
            episodeCheckinFromJson.Show.Title.Should().Be(showTitle);
            episodeCheckinFromJson.Show.Year.Should().Be(showYear);
            episodeCheckinFromJson.Show.Ids.Should().NotBeNull();
            episodeCheckinFromJson.Show.Ids.Trakt.Should().Be(showTraktId);
            episodeCheckinFromJson.Show.Ids.Slug.Should().Be(showSlug);
            episodeCheckinFromJson.Show.Ids.Tvdb.Should().Be(showTvdb);
            episodeCheckinFromJson.Show.Ids.Imdb.Should().Be(showImdb);
            episodeCheckinFromJson.Show.Ids.Tmdb.Should().Be(showTmdb);
            episodeCheckinFromJson.Show.Ids.TvRage.Should().Be(showTvRage);
        }
Example #24
0
 /// <summary>Check into a movie. This should be tied to a user action to manually indicate they are watching something.
 /// The item will display as watching on the site, then automatically switch to watched status once the duration has elapsed.</summary>
 /// <param name="movieId">The movie ID</param>
 /// <param name="movieIdType">The movie ID type</param>
 /// <param name="sharing">Control sharing to any connected social networks</param>
 /// <param name="message">Message used for sharing. If not sent, it will use the watching string in the user settings.</param>
 /// <param name="venueId">Foursquare venue ID</param>
 /// <param name="venueName">Foursquare venue name</param>
 /// <param name="appVersion">Version number of the app</param>
 /// <param name="appDate">Build date of the app</param>
 /// <param name="extended">Changes which properties are populated for standard media objects. By default, minimal data is returned. Change this if additional fields are required in the returned data.</param>
 /// <returns>See summary</returns>
 public async Task <TraktCheckinMovieResponse> CheckinMovieAsync(int movieId, TraktNumericMovieIdType movieIdType, TraktSharing sharing = null, string message = "", string venueId = "", string venueName = "", string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await CheckinMovieAsync(TraktMovieFactory.FromId(movieId, movieIdType), sharing, message, venueId, venueName, appVersion, appDate, extended));
 }
        public void TestTraktMovieCheckinPostWriteJson()
        {
            var sharing = new TraktSharing {
                Facebook = true, Twitter = false, Tumblr = false
            };
            var message    = "checkin in now";
            var appVersion = "App Version 1.0.0";
            var appDate    = DateTime.UtcNow.ToString("yyyy-MM-dd");
            var venueId    = "venue id";
            var venueName  = "venue name";

            var movieTitle   = "Guardians of the Galaxy";
            var movieYear    = 2014;
            var movieTraktId = 28U;
            var movieSlug    = "guardiangs-of-the-galaxy-2014";
            var movieImdb    = "tt2015381";
            var movieTmdb    = 118340U;

            var movie = new TraktMovie
            {
                Title = movieTitle,
                Year  = movieYear,
                Ids   = new TraktMovieIds
                {
                    Trakt = movieTraktId,
                    Slug  = movieSlug,
                    Imdb  = movieImdb,
                    Tmdb  = movieTmdb
                }
            };

            var movieCheckin = new TraktMovieCheckinPost
            {
                Sharing             = sharing,
                Message             = message,
                AppVersion          = appVersion,
                AppDate             = appDate,
                FoursquareVenueId   = venueId,
                FoursquareVenueName = venueName,
                Movie = movie
            };

            var strJson = JsonConvert.SerializeObject(movieCheckin);

            strJson.Should().NotBeNullOrEmpty();

            var movieCheckinFromJson = JsonConvert.DeserializeObject <TraktMovieCheckinPost>(strJson);

            movieCheckinFromJson.Should().NotBeNull();
            movieCheckinFromJson.Sharing.Should().NotBeNull();
            movieCheckinFromJson.Sharing.Facebook.Should().BeTrue();
            movieCheckinFromJson.Sharing.Twitter.Should().BeFalse();
            movieCheckinFromJson.Sharing.Tumblr.Should().BeFalse();
            movieCheckinFromJson.Message.Should().Be(message);
            movieCheckinFromJson.AppVersion.Should().Be(appVersion);
            movieCheckinFromJson.AppDate.Should().NotBeNull().And.NotBeEmpty().And.Be(appDate);
            movieCheckinFromJson.FoursquareVenueId.Should().Be(venueId);
            movieCheckinFromJson.FoursquareVenueName.Should().Be(venueName);

            movieCheckinFromJson.Movie.Should().NotBeNull();
            movieCheckinFromJson.Movie.Title.Should().Be(movieTitle);
            movieCheckinFromJson.Movie.Year.Should().Be(movieYear);
            movieCheckinFromJson.Movie.Ids.Should().NotBeNull();
            movieCheckinFromJson.Movie.Ids.Trakt.Should().Be(movieTraktId);
            movieCheckinFromJson.Movie.Ids.Slug.Should().Be(movieSlug);
            movieCheckinFromJson.Movie.Ids.Imdb.Should().Be(movieImdb);
            movieCheckinFromJson.Movie.Ids.Tmdb.Should().Be(movieTmdb);
        }
Example #26
0
 /// <summary>Check into an episode. This should be tied to a user action to manually indicate they are watching something.
 /// The item will display as watching on the site, then automatically switch to watched status once the duration has elapsed.</summary>
 /// <param name="showTitle">The show title</param>
 /// <param name="showYear">The show release year (first season)</param>
 /// <param name="seasonNumber">The season number</param>
 /// <param name="episodeNumber">The episode number within the specified season</param>
 /// <param name="sharing">Control sharing to any connected social networks</param>
 /// <param name="message">Message used for sharing. If not sent, it will use the watching string in the user settings.</param>
 /// <param name="venueId">Foursquare venue ID</param>
 /// <param name="venueName">Foursquare venue name</param>
 /// <param name="appVersion">Version number of the app</param>
 /// <param name="appDate">Build date of the app</param>
 /// <param name="extended">Changes which properties are populated for standard media objects. By default, minimal data is returned. Change this if additional fields are required in the returned data.</param>
 /// <returns>See summary</returns>
 public async Task <TraktCheckinEpisodeResponse> CheckinEpisodeAsync(string showTitle, int?showYear, int seasonNumber, int episodeNumber, TraktSharing sharing = null, string message = "", string venueId = "", string venueName = "", string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await CheckinEpisodeAsync(TraktEpisodeFactory.FromSeasonAndEpisodeNumber(seasonNumber, episodeNumber), TraktShowFactory.FromTitleAndYear(showTitle, showYear), sharing, message, venueId, venueName, appVersion, appDate, extended));
 }
Example #27
0
 /// <summary>Check into a movie. This should be tied to a user action to manually indicate they are watching something.
 /// The item will display as watching on the site, then automatically switch to watched status once the duration has elapsed.</summary>
 /// <param name="movieTitle">The movie title</param>
 /// <param name="movieYear">The movie release year</param>
 /// <param name="sharing">Control sharing to any connected social networks</param>
 /// <param name="message">Message used for sharing. If not sent, it will use the watching string in the user settings.</param>
 /// <param name="venueId">Foursquare venue ID</param>
 /// <param name="venueName">Foursquare venue name</param>
 /// <param name="appVersion">Version number of the app</param>
 /// <param name="appDate">Build date of the app</param>
 /// <param name="extended">Changes which properties are populated for standard media objects. By default, minimal data is returned. Change this if additional fields are required in the returned data.</param>
 /// <returns>See summary</returns>
 /// <remarks>This should be tied to a user action to manually indicate they are watching something.
 /// The item will display as watching on the site, then automatically switch to watched status once the duration has elapsed.</remarks>
 public async Task <TraktCheckinMovieResponse> CheckinMovieAsync(string movieTitle, int?movieYear, TraktSharing sharing = null, string message = "", string venueId = "", string venueName = "", string appVersion = "", DateTime?appDate = null, TraktExtendedOption extended = TraktExtendedOption.Unspecified)
 {
     return(await CheckinMovieAsync(TraktMovieFactory.FromTitleAndYear(movieTitle, movieYear), sharing, message, venueId, venueName, appVersion, appDate, extended));
 }