Exemple #1
0
 public void TestNotNullOrEmptyStillWorksWhenNameIsNull()
 {
     Assert.Throws <ArgumentException>(delegate
     {
         CheckArgument.NotNullOrEmpty(string.Empty, null);
     });
 }
        /// <summary>
        /// Checks the status of a Verify transaction. When the code is
        /// supplied it verifies this code. The response also contains
        /// status information about the progress of the call or sms.
        /// </summary>
        /// <param name="referenceId">
        /// The reference id return in the VerifyResponse from
        /// a call to Sms or Call.
        /// </param>
        /// <param name="verifyCode">The code the user provided you to be verified.</param>
        /// <returns>
        /// A VerifyResponse object containing information about the status
        /// of the transactation and validity of the code.
        /// </returns>
        public string StatusRaw(
            string referenceId,
            string verifyCode = null)
        {
            CheckArgument.NotNullOrEmpty(referenceId, "referenceId");

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("referenceId", referenceId);

            if (!string.IsNullOrEmpty(verifyCode))
            {
                args.Add("verify_code", verifyCode.ToString());
            }

            string resourceName = string.Format(
                RawVerifyService.VerifyResourceFormatString,
                referenceId);

            WebRequest request = this.ConstructWebRequest(
                resourceName,
                "GET",
                args);

            return(this.WebRequester.ReadResponseAsString(request));
        }
Exemple #3
0
 public void TestNotNullOrEmptyThrowsWhenPassedEmptyString()
 {
     Assert.Throws <ArgumentException>(delegate
     {
         CheckArgument.NotNullOrEmpty(string.Empty, "value");
     });
 }
Exemple #4
0
 public void TestNotNullOrEmptyThrowsWhenPassedNull()
 {
     Assert.Throws <ArgumentNullException>(delegate
     {
         CheckArgument.NotNullOrEmpty(null, "value");
     });
 }
Exemple #5
0
        /////// <summary>
        /////// The TeleSign Verify Soft Token web service is a server-side component of the TeleSign AuthID application, and it allows you to authenticate your end users when they use the TeleSign AuthID application on their mobile device to generate a Time-based One-time Password (TOTP) verification code
        /////// </summary>
        /////// <param name="phoneNumber">The phone number for the Verify Soft Token request, including country code</param>
        /////// <param name="softTokenId">
        /////// The alphanumeric string that uniquely identifies your TeleSign soft token subscription
        /////// </param>
        /////// <param name="verifyCode">
        /////// The verification code received from the end user
        /////// </param>
        /////// <returns>The raw JSON response from the REST API.</returns>
        ////public string SoftTokenRaw(
        ////            string phoneNumber,
        ////            string softTokenId = null,
        ////            string verifyCode = null)
        ////{
        ////    phoneNumber = this.CleanupPhoneNumber(phoneNumber);

        ////    if (softTokenId == null)
        ////    {
        ////        softTokenId = string.Empty;
        ////    }

        ////    if (verifyCode == null)
        ////    {
        ////        verifyCode = string.Empty;
        ////    }

        ////    Dictionary<string, string> args = ConstructVerifyArgs(
        ////                VerificationMethod.SoftToken,
        ////                phoneNumber,
        ////                softTokenId,
        ////                verifyCode);

        ////    string resourceName = string.Format(
        ////                RawVerifyService.VerifyResourceFormatString,
        ////                VerificationMethod.SoftToken.ToString().ToLowerInvariant());

        ////    WebRequest request = this.ConstructWebMobileRequest(
        ////                resourceName,
        ////                "POST",
        ////                args);

        ////    return this.WebRequester.ReadResponseAsString(request);
        ////}

        /// <summary>
        /// The TeleSign Verify 2-Way SMS web service allows you to authenticate your users and verify user transactions via two-way Short Message Service (SMS) wireless communication. Verification requests are sent to user’s in a text message, and users return their verification responses by replying to the text message.
        /// </summary>
        /// <param name="phoneNumber">The phone number for the Verify Soft Token request, including country code</param>
        /// <param name="message">
        /// The text to display in the body of the text message. You must include the $$CODE$$ placeholder for the verification code somewhere in your message text. TeleSign automatically replaces it with a randomly-generated verification code
        /// </param>
        /// <param name="validityPeriod">
        /// This parameter allows you to place a time-limit on the verification. This provides an extra level of security by restricting the amount of time your end user has to respond (after which, TeleSign automatically rejects their response). Values are expressed as a natural number followed by a lower-case letter that represents the unit of measure. You can use 's' for seconds, 'm' for minutes, 'h' for hours, and 'd' for days
        /// </param>
        /// <param name="useCaseId"></param>
        /// <returns>The raw JSON response from the REST API.</returns>
        public string TwoWaySmsRaw(
            string phoneNumber,
            string message,
            string validityPeriod = "5m",
            string useCaseId      = RawVerifyService.DefaultUseCaseId)
        {
            CheckArgument.NotEmpty(message, "message");
            CheckArgument.NotNullOrEmpty(validityPeriod, "validityPeriod");

            phoneNumber = this.CleanupPhoneNumber(phoneNumber);

            Dictionary <string, string> args = ConstructVerifyArgs(
                VerificationMethod.TwoWaySms,
                phoneNumber,
                null,
                message,
                null,
                validityPeriod,
                useCaseId);

            string resourceName = string.Format(
                RawVerifyService.VerifyResourceFormatString,
                "two_way_sms");

            WebRequest request = this.ConstructWebRequest(
                resourceName,
                "POST",
                args);

            return(this.WebRequester.ReadResponseAsString(request));
        }
Exemple #6
0
        /// <summary>
        /// Checks the status of TeleSign Verify transaction. At the underlying REST
        /// API layer this is the same call as ValidateCode (to the Status resource)
        /// but without supplying the code. This is useful to check the progress
        /// of the SMS or call prior to the user responding with the code.
        /// </summary>
        /// <param name="referenceId">
        /// The reference id return in the VerifyResponse from
        /// a call to Sms or Call.
        /// </param>
        /// <returns>
        /// A VerifyResponse object containing information about the status
        /// of the transactation
        /// </returns>
        public VerifyResponse CheckStatus(string referenceId)
        {
            CheckArgument.NotNullOrEmpty(referenceId, "referenceId");

            string rawResponse = this.StatusRaw(referenceId);

            try
            {
                return(this.parser.ParseVerifyResponse(rawResponse));
            }
            catch (Exception x)
            {
                throw new ResponseParseException(
                          "Error parsing Verify code check status response",
                          rawResponse,
                          x);
            }
        }
Exemple #7
0
        /// <summary>
        /// Performs a PhoneID Contact lookup on a phone number.
        /// </summary>
        /// <param name="phoneNumber">The phone number to lookup.</param>
        /// <returns>
        /// A ContactPhoneIdResponse object containing both status of the transaction
        /// and the resulting data (if successful).
        /// </returns>
        public PhoneIdContactResponse ContactLookup(string phoneNumber)
        {
            CheckArgument.NotNullOrEmpty(phoneNumber, "phoneNumber");

            string rawResponse = this.ContactLookupRaw(phoneNumber);

            try
            {
                return(this.responseParser.ParsePhoneIdContactResponse(rawResponse));
            }
            catch (Exception x)
            {
                throw new ResponseParseException(
                          "Error parsing PhoneID Contact response",
                          rawResponse,
                          x);
            }
        }
Exemple #8
0
 public void TestNotNullOrEmptyDoesntThrowWhenPassedNonNullNonEmptyString()
 {
     CheckArgument.NotNullOrEmpty("foo", "value");
 }