/// <summary>
        /// Retrieve a list of all Challenges for a Factor.
        /// </summary>
        /// <param name="options"> Read Challenge parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Challenge </returns>
        public static ResourceSet <ChallengeResource> Read(ReadChallengeOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = client.Request(BuildReadRequest(options, client));

            var page = Page <ChallengeResource> .FromJson("challenges", response.Content);

            return(new ResourceSet <ChallengeResource>(page, options, client));
        }
 private static Request BuildReadRequest(ReadChallengeOptions options, ITwilioRestClient client)
 {
     return(new Request(
                HttpMethod.Get,
                Rest.Domain.Verify,
                "/v2/Services/" + options.PathServiceSid + "/Entities/" + options.PathIdentity + "/Challenges",
                queryParams: options.GetParams()
                ));
 }
        /// <summary>
        /// Retrieve a list of all Challenges for a 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="status"> The Status of theChallenges to fetch </param>
        /// <param name="pageSize"> Page size </param>
        /// <param name="limit"> Record limit </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 <ResourceSet <ChallengeResource> > ReadAsync(string pathServiceSid,
                                                                                                     string pathIdentity,
                                                                                                     string factorSid = null,
                                                                                                     ChallengeResource.ChallengeStatusesEnum status = null,
                                                                                                     int?pageSize             = null,
                                                                                                     long?limit               = null,
                                                                                                     ITwilioRestClient client = null)
        {
            var options = new ReadChallengeOptions(pathServiceSid, pathIdentity)
            {
                FactorSid = factorSid, Status = status, PageSize = pageSize, Limit = limit
            };

            return(await ReadAsync(options, client));
        }
        /// <summary>
        /// Retrieve a list of all Challenges for a 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="status"> The Status of theChallenges to fetch </param>
        /// <param name="pageSize"> Page size </param>
        /// <param name="limit"> Record limit </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Challenge </returns>
        public static ResourceSet <ChallengeResource> Read(string pathServiceSid,
                                                           string pathIdentity,
                                                           string factorSid = null,
                                                           ChallengeResource.ChallengeStatusesEnum status = null,
                                                           int?pageSize             = null,
                                                           long?limit               = null,
                                                           ITwilioRestClient client = null)
        {
            var options = new ReadChallengeOptions(pathServiceSid, pathIdentity)
            {
                FactorSid = factorSid, Status = status, PageSize = pageSize, Limit = limit
            };

            return(Read(options, client));
        }
        /// <summary>
        /// Retrieve a list of all Challenges for a Factor.
        /// </summary>
        /// <param name="options"> Read 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 <ResourceSet <ChallengeResource> > ReadAsync(ReadChallengeOptions options,
                                                                                                     ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildReadRequest(options, client));

            var page = Page <ChallengeResource> .FromJson("challenges", response.Content);

            return(new ResourceSet <ChallengeResource>(page, options, client));
        }