Esempio n. 1
0
 public int MakeComment(int movieID, string commentText)
 {
     this.CheckAppKey();
     this.CheckLoggedIn();
     if (movieID < 0)
     {
         throw new ArgumentException("Movie id should be greater than 0.");
     }
     else if (string.IsNullOrWhiteSpace(commentText))
     {
         throw new ArgumentException("Comment text cannot be null or empty.");
     }
     else
     {
         var req    = YifyAPI.GetMakeCommentReqeust(this.appKey, this.userKey, movieID, commentText);
         var res    = YifyAPI.SendPostRequest(req);
         int parsed = _parser.ParseMakeCommentResponse(res);
         try
         {
             var xDoc = _parser.ToResponse(res);
             return(-1);
         }
         catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); }
     }
 }
Esempio n. 2
0
        public bool MakeRequest(string movieTitle, string requestMessage)
        {
            this.CheckAppKey();
            this.CheckLoggedIn();

            if (string.IsNullOrWhiteSpace(movieTitle))
            {
                throw new ArgumentException("Movie title cannot be null or empty.");
            }
            else if (string.IsNullOrWhiteSpace(requestMessage))
            {
                throw new ArgumentException("Request message cannot be null or empty.");
            }
            else
            {
                try
                {
                    var req  = YifyAPI.GetMakeRequestReqeust(this.appKey, this.userKey, movieTitle, requestMessage);
                    var res  = YifyAPI.SendPostRequest(req);
                    var xDoc = _parser.ToResponse(res);
                    return(true);
                }
                catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); }
            }
        }
Esempio n. 3
0
 public string Login(string username, string password)
 {
     this.CheckAppKey();
     try
     {
         var    req  = YifyAPI.GetUserKeyRequest(username, password, appKey, false);
         var    res  = YifyAPI.SendPostRequest(req);
         string ukey = _parser.ParseGetUserKeyResponse(res);
         this.userKey = ukey;
         return(ukey);
     }
     catch (Exception ex)
     {
         throw new YifyException("An error occurred. See inner exception for more details", ex);
     }
 }
Esempio n. 4
0
 public bool ResetUserPassword(string resetCode, string newPassword)
 {
     this.CheckAppKey();
     if (!resetCode.HasValue() || !newPassword.HasValue())
     {
         throw new ArgumentException("Reset Code or New Password cannot be empty.");
     }
     else
     {
         try
         {
             var req  = YifyAPI.GetResetUserPasswordRequest(this.appKey, resetCode, newPassword);
             var res  = YifyAPI.SendPostRequest(req);
             var xDoc = _parser.ToResponse(res);
             return(true);
         }
         catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); }
     }
 }
Esempio n. 5
0
        /// <summary>
        /// Send a password recovery request to Yify torrent. If the email is valid Yify torrent will email a
        /// password rest code which can be used on <code>ResetUserPassword</code> function.
        /// </summary>
        /// <param name="email">Email of a registered account</param>
        /// <returns>True if the request is successful</returns>
        /// <exception cref="YifyLib.YifyMissingAppKeyException">If application key is missing</exception>
        /// <exception cref="ArgumentException">If Email is empty or null</exception>
        /// <exception cref="YifyLib.YifyException">If any errors occurred YTS process</exception>
        public bool ForgotUserPassword(string email)
        {
            this.CheckAppKey();
            if (!email.HasValue())
            {
                throw new ArgumentException("Email cannot be empty.");
            }
            else
            {
                try
                {
                    var req = YifyAPI.GetForgotUserPasswordRequest(this.appKey, email);
                    var res = YifyAPI.SendPostRequest(req);

                    var xDoc = _parser.ToResponse(res);
                    return(true);
                }
                catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); }
            }
        }
Esempio n. 6
0
 public RegisterUser RegisterUser(string userName, string password, string email)
 {
     this.CheckAppKey();
     if (!userName.HasValue() || !password.HasValue() || !email.HasValue())
     {
         throw new ArgumentException("Username, Password or Email cannot be empty.");
     }
     else
     {
         try
         {
             var req = YifyAPI.GetRegisterUserRequest(this.appKey, userName, password, email);
             var res = YifyAPI.SendPostRequest(req);
             var rgu = _parser.ParseRegisterUserResponse(res);
             this.userKey = rgu.UserKey;
             return(rgu);
         }
         catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); }
     }
 }
Esempio n. 7
0
        public bool DeleteComment(int commentID)
        {
            this.CheckAppKey();
            this.CheckLoggedIn();

            if (commentID < 0)
            {
                throw new ArgumentException("Comment id should be greater than 0.");
            }
            else
            {
                try
                {
                    var req  = YifyAPI.GetDeleteCommentReqeust(this.appKey, this.userKey, commentID);
                    var res  = YifyAPI.SendPostRequest(req);
                    var xDoc = _parser.ToResponse(res);
                    return(true);
                }
                catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); }
            }
        }