Esempio n. 1
0
        /// <summary>
        /// Removes movies from users collection
        /// </summary>
        /// <param name="syncData">list of shows</param>
        public static TraktSyncResponse RemoveMoviesFromCollection(TraktMovieSync syncData)
        {
            if (syncData == null)
            {
                return(null);
            }

            var response = TraktWeb.PostToTrakt(TraktURIs.SyncCollectionRemove, syncData.ToJSON());

            return(response.FromJSON <TraktSyncResponse>());
        }
Esempio n. 2
0
        // <summary>
        /// Removes all season ratings from trakt
        /// </summary>
        /// <param name="syncData">list of shows with seasons</param>
        public static TraktSyncResponse RemoveSeasonsFromRatings(TraktSeasonSync syncData)
        {
            if (syncData == null)
            {
                return(null);
            }

            var response = TraktWeb.PostToTrakt(TraktURIs.SyncRatingsRemove, syncData.ToJSON());

            return(response.FromJSON <TraktSyncResponse>());
        }
Esempio n. 3
0
        /// <summary>
        /// Removes movies from users watched history
        /// </summary>
        /// <param name="syncData">list of shows</param>
        public static TraktSyncResponse RemoveMoviesFromWatchedHistory(TraktMovieSync syncData)
        {
            if (syncData == null)
            {
                return(null);
            }

            var response = TraktWeb.PostToTrakt(TraktURIs.SyncWatchedRemove, syncData.ToJSON());

            return(response.FromJSON <TraktSyncResponse>());
        }
Esempio n. 4
0
        /// <summary>
        /// Removes all shows from watchlist from trakt
        /// </summary>
        /// <param name="syncData">list of shows</param>
        public static TraktSyncResponse RemoveShowsFromWatchlist(TraktShowSync syncData)
        {
            if (syncData == null)
            {
                return(null);
            }

            var response = TraktWeb.PostToTrakt(TraktURIs.SyncWatchlistRemove, syncData.ToJSON());

            return(response.FromJSON <TraktSyncResponse>());
        }
Esempio n. 5
0
        /// <summary>
        /// Sends show sync data to Trakt Watchlist
        /// </summary>
        /// <param name="syncData">The sync data to send</param>
        /// <returns>The response from trakt</returns>
        public static TraktSyncResponse AddShowsToWatchlist(TraktShowSync syncData)
        {
            // check that we have everything we need
            if (syncData == null || syncData.Shows == null || syncData.Shows.Count == 0)
            {
                return(null);
            }

            // serialize data to JSON and send to server
            string response = TraktWeb.PostToTrakt(TraktURIs.SyncWatchlist, syncData.ToJSON());

            // return success or failure
            return(response.FromJSON <TraktSyncResponse>());
        }
Esempio n. 6
0
        /// <summary>
        /// Sends movie sync data to Trakt Collection
        /// </summary>
        /// <param name="syncData">The sync data to send</param>
        /// <returns>The response from trakt</returns>
        public static TraktSyncResponse AddMoviesToCollection(TraktMovieSync syncData)
        {
            // check that we have everything we need
            if (syncData == null || syncData.Movies == null || syncData.Movies.Count == 0)
            {
                return(null);
            }

            // serialize data to JSON and send to server
            string response = TraktWeb.PostToTrakt(TraktURIs.SyncCollection, syncData.ToJSON());

            // return success or failure
            return(response.FromJSON <TraktSyncResponse>());
        }
Esempio n. 7
0
        /// <summary>
        /// Rates a list of episodes on trakt
        /// </summary>
        /// <param name="data">The object containing the list of episodes to be rated</param>
        /// <returns>The response from trakt</returns>
        public static TraktSyncResponse AddsEpisodesToRatings(TraktEpisodeRatingSync data)
        {
            // check that we have everything we need
            if (data == null || data.Episodes == null || data.Episodes.Count == 0)
            {
                return(null);
            }

            // serialize data to JSON and send to server
            string response = TraktWeb.PostToTrakt(TraktURIs.SyncRatings, data.ToJSON());

            // return success or failure
            return(response.FromJSON <TraktSyncResponse>());
        }
Esempio n. 8
0
        /// <summary>
        /// Login to trakt to request a user access token for all subsequent requests
        /// </summary>
        /// <param name="key">Set this to a PinCode for first time oAuth otherwise your previous Access Token</param>
        /// <returns>If successfully an access token will be returned</returns>
        public static TraktOAuthToken GetOAuthToken(string key)
        {
            // set our required headers now
            TraktWeb.CustomRequestHeaders.Clear();

            TraktWeb.CustomRequestHeaders.Add("trakt-api-key", ApplicationId);
            TraktWeb.CustomRequestHeaders.Add("trakt-api-version", "2");

            string response      = TraktWeb.PostToTrakt(TraktURIs.LoginOAuth, GetOAuthLogin(key), true);
            var    loginResponse = response.FromJSON <TraktOAuthToken>();

            if (loginResponse == null || loginResponse.AccessToken == null)
            {
                return(loginResponse);
            }

            // add the token for authenticated methods
            TraktWeb.CustomRequestHeaders.Add("Authorization", string.Format("Bearer {0}", loginResponse.AccessToken));

            return(loginResponse);
        }
Esempio n. 9
0
        /// <summary>
        /// Login to trakt to request a user token for all subsequent requests
        /// </summary>
        public static TraktUserToken GetUserToken()
        {
            // set our required headers now
            TraktWeb.CustomRequestHeaders.Clear();

            TraktWeb.CustomRequestHeaders.Add("trakt-api-key", ApplicationId);
            TraktWeb.CustomRequestHeaders.Add("trakt-api-version", "2");
            TraktWeb.CustomRequestHeaders.Add("trakt-user-login", Username);

            string response      = TraktWeb.PostToTrakt(TraktURIs.Login, GetUserLogin(), false);
            var    loginResponse = response.FromJSON <TraktUserToken>();

            if (loginResponse == null)
            {
                return(loginResponse);
            }

            // add the token for authenticated methods
            TraktWeb.CustomRequestHeaders.Add("trakt-user-token", loginResponse.Token);

            return(loginResponse);
        }
Esempio n. 10
0
        public static TraktSyncResponse AddItemsToList(string id, TraktSyncAll items, string username = "******")
        {
            var response = TraktWeb.PostToTrakt(string.Format(TraktURIs.UserListItemsAdd, username, id), items.ToJSON());

            return(response.FromJSON <TraktSyncResponse>());
        }
Esempio n. 11
0
        public static TraktListDetail CreateCustomList(TraktList list, string username = "******")
        {
            var response = TraktWeb.PostToTrakt(string.Format(TraktURIs.UserListAdd, username), list.ToJSON());

            return(response.FromJSON <TraktListDetail>());
        }