public static VerificationCode validate(string token, long code, ref bool disposed)
        {
            disposed = false;

            VerificationCode t = get_object(token);

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

            if (!t.update_ttl(token))
            {
                disposed = true;
                return(null);
            }

            if (t._Code == code && t._ExpirationDate.HasValue && t._ExpirationDate.Value > DateTime.Now)
            {
                return(t);
            }
            else
            {
                return(null);
            }
        }
        public static bool process_request(Guid?applicationId, string emailAddress, string phoneNumber,
                                           string token, long?code, ref string responseText, string customData = "")
        {
            bool disposed = false;

            if (string.IsNullOrEmpty(token) || !code.HasValue)
            {
                VerificationCode vc = new VerificationCode(applicationId, emailAddress, phoneNumber, customData: customData);

                if (vc.send_code())
                {
                    responseText = "{\"VerificationCode\":" + vc.toJson() + "}";
                }
                else
                {
                    responseText = "{\"ErrorText\":\"" + Messages.SendingVerificationCodeFailed.ToString() + "\"}";
                }

                return(false);
            }
            else
            {
                VerificationCode vc = VerificationCode.validate(token, code.Value, ref disposed);

                if (vc != null)
                {
                    responseText = vc.CustomData;
                }
                else if (vc == null)
                {
                    responseText = "{\"ErrorText\":\"" + Messages.VerificationCodeDidNotMatch.ToString() + "\"" +
                                   ",\"CodeDisposed\":" + disposed.ToString().ToLower() + "}";
                    return(false);
                }
            }

            return(true);
        }
        public static bool resend_code(string token)
        {
            VerificationCode vc = get_object(token);

            return(vc != null && vc.resend());
        }