/// <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.Verify,
                "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges",
                postParams: options.GetParams()
                ));
 }
        /// <summary>
        /// Create a new Challenge for the Factor
        /// </summary>
        /// <param name="pathServiceSid"> Service Sid. </param>
        /// <param name="pathIdentity"> Unique external identifier of the Entity </param>
        /// <param name="factorSid"> 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 factorSid,
                                                                                        DateTime?expirationDate  = null,
                                                                                        string details           = null,
                                                                                        string hiddenDetails     = null,
                                                                                        ITwilioRestClient client = null)
        {
            var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, factorSid)
            {
                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 external identifier of the Entity </param>
        /// <param name="factorSid"> 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 factorSid,
                                               DateTime?expirationDate  = null,
                                               string details           = null,
                                               string hiddenDetails     = null,
                                               ITwilioRestClient client = null)
        {
            var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, factorSid)
            {
                ExpirationDate = expirationDate, Details = details, HiddenDetails = hiddenDetails
            };

            return(Create(options, client));
        }
        /// <summary>
        /// Create a new Challenge for the Factor
        /// </summary>
        /// <param name="pathServiceSid"> Service Sid. </param>
        /// <param name="pathIdentity"> Unique external identifier of the Entity </param>
        /// <param name="factorSid"> Factor Sid. </param>
        /// <param name="expirationDate"> The future date in which this Challenge will expire </param>
        /// <param name="detailsMessage"> Shown to the user when the push notification arrives </param>
        /// <param name="detailsFields"> A list of objects that describe the Fields included in the Challenge </param>
        /// <param name="hiddenDetails"> Hidden details provided to contextualize the Challenge </param>
        /// <param name="twilioSandboxMode"> The Twilio-Sandbox-Mode HTTP request header </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 factorSid,
                                                                                        DateTime?expirationDate     = null,
                                                                                        string detailsMessage       = null,
                                                                                        List <object> detailsFields = null,
                                                                                        object hiddenDetails        = null,
                                                                                        string twilioSandboxMode    = null,
                                                                                        ITwilioRestClient client    = null)
        {
            var options = new CreateChallengeOptions(pathServiceSid, pathIdentity, factorSid)
            {
                ExpirationDate = expirationDate, DetailsMessage = detailsMessage, DetailsFields = detailsFields, HiddenDetails = hiddenDetails, TwilioSandboxMode = twilioSandboxMode
            };

            return(await CreateAsync(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));
        }