/// <summary>
        /// Create a new Challenge for the Factor
        /// </summary>
        /// <param name="options"> Create Challenge parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Challenge </returns>
        public static ChallengeResource Create(CreateChallengeOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = client.Request(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }
 private static Request BuildCreateRequest(CreateChallengeOptions options, ITwilioRestClient client)
 {
     return(new Request(
                HttpMethod.Post,
                Rest.Domain.Authy,
                "/v1/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Factors/" + options.PathFactorSid + "/Challenges",
                postParams: options.GetParams()
                ));
 }
        /// <summary>
        /// Create a new Challenge for the Factor
        /// </summary>
        /// <param name="pathServiceSid"> Service Sid. </param>
        /// <param name="pathIdentity"> Unique identity of the Entity </param>
        /// <param name="pathFactorSid"> Factor Sid. </param>
        /// <param name="expirationDate"> The future date in which this Challenge will expire </param>
        /// <param name="details"> Public details provided to contextualize the Challenge </param>
        /// <param name="hiddenDetails"> Hidden details provided to contextualize the Challenge </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Challenge </returns>
        public static async System.Threading.Tasks.Task <ChallengeResource> CreateAsync(string pathServiceSid,
                                                                                        string pathIdentity,
                                                                                        string pathFactorSid,
                                                                                        DateTime?expirationDate  = null,
                                                                                        string details           = null,
                                                                                        string hiddenDetails     = null,
                                                                                        ITwilioRestClient client = null)
        {
            var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, pathFactorSid)
            {
                ExpirationDate = expirationDate, Details = details, HiddenDetails = hiddenDetails
            };

            return(await CreateAsync(options, client));
        }
        /// <summary>
        /// Create a new Challenge for the Factor
        /// </summary>
        /// <param name="pathServiceSid"> Service Sid. </param>
        /// <param name="pathIdentity"> Unique identity of the Entity </param>
        /// <param name="pathFactorSid"> Factor Sid. </param>
        /// <param name="expirationDate"> The future date in which this Challenge will expire </param>
        /// <param name="details"> Public details provided to contextualize the Challenge </param>
        /// <param name="hiddenDetails"> Hidden details provided to contextualize the Challenge </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Challenge </returns>
        public static ChallengeResource Create(string pathServiceSid,
                                               string pathIdentity,
                                               string pathFactorSid,
                                               DateTime?expirationDate  = null,
                                               string details           = null,
                                               string hiddenDetails     = null,
                                               ITwilioRestClient client = null)
        {
            var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, pathFactorSid)
            {
                ExpirationDate = expirationDate, Details = details, HiddenDetails = hiddenDetails
            };

            return(Create(options, client));
        }
        /// <summary>
        /// Create a new Challenge for the Factor
        /// </summary>
        /// <param name="options"> Create Challenge parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Challenge </returns>
        public static async System.Threading.Tasks.Task <ChallengeResource> CreateAsync(CreateChallengeOptions options,
                                                                                        ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildCreateRequest(options, client));

            return(FromJson(response.Content));
        }