Ejemplo n.º 1
0
        /// <summary>
        /// Check to see if the given phone digits are
        /// indeed a cell phone.
        /// </summary>
        /// <param name="user">The user identity (api key) to authenticate with the provider.</param>
        /// <param name="password">The user password (secondary key) to authenticate with the provider.</param>
        /// <param name="digits">The phone number digits to check for a cell.</param>
        /// <returns>Indicates whether or not the digits are a cell.</returns>
        public bool IsACell(string user, string password, string digits)
        {
            if (String.IsNullOrEmpty(user))
            {
                this.ApplyResponse(HttpStatusCode.InternalServerError, "Api user name is missing or empty.");
                return(false);
            }

            if (String.IsNullOrEmpty(password))
            {
                this.ApplyResponse(HttpStatusCode.InternalServerError, "Api user passsword is missing or empty.");
                return(false);
            }

            this.auth      = Convert.ToBase64String(Encoding.UTF8.GetBytes(String.Format("{0}:{1}", user, password)));
            this.confirmed = false;

            HttpTransceiver adapter = new HttpTransceiver();

            adapter.OnRequestInitialized += this.RequestInitialized;
            adapter.OnRequestComplete    += this.PreviewRequestComplete;
            adapter.OnRequestError       += this.PreviewRequestError;

            string url = String.Format("{0}{1}{2}", om.Default.api_base_url, om.Default.confirm_method_name, digits);

            adapter.Get(url, typeof(PreviewResponse));

            return(this.confirmed);
        }