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

            var page = Page <EngagementResource> .FromJson("engagements", response.Content);

            return(new ResourceSet <EngagementResource>(page, options, client));
        }
 private static Request BuildReadRequest(ReadEngagementOptions options, ITwilioRestClient client)
 {
     return(new Request(
                HttpMethod.Get,
                Rest.Domain.Preview,
                "/Studio/Flows/" + options.PathFlowSid + "/Engagements",
                client.Region,
                queryParams: options.GetParams()
                ));
 }
        /// <summary>
        /// Retrieve a list of all Engagements for the Flow.
        /// </summary>
        /// <param name="pathFlowSid"> Flow Sid. </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 Engagement </returns>
        public static ResourceSet <EngagementResource> Read(string pathFlowSid,
                                                            int?pageSize             = null,
                                                            long?limit               = null,
                                                            ITwilioRestClient client = null)
        {
            var options = new ReadEngagementOptions(pathFlowSid)
            {
                PageSize = pageSize, Limit = limit
            };

            return(Read(options, client));
        }
        /// <summary>
        /// Retrieve a list of all Engagements for the Flow.
        /// </summary>
        /// <param name="pathFlowSid"> Flow Sid. </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 Engagement </returns>
        public static async System.Threading.Tasks.Task <ResourceSet <EngagementResource> > ReadAsync(string pathFlowSid,
                                                                                                      int?pageSize             = null,
                                                                                                      long?limit               = null,
                                                                                                      ITwilioRestClient client = null)
        {
            var options = new ReadEngagementOptions(pathFlowSid)
            {
                PageSize = pageSize, Limit = limit
            };

            return(await ReadAsync(options, client));
        }
        /// <summary>
        /// Retrieve a list of all Engagements for the Flow.
        /// </summary>
        /// <param name="options"> Read Engagement parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> Task that resolves to A single instance of Engagement </returns>
        public static async System.Threading.Tasks.Task <ResourceSet <EngagementResource> > ReadAsync(ReadEngagementOptions options,
                                                                                                      ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = await client.RequestAsync(BuildReadRequest(options, client));

            var page = Page <EngagementResource> .FromJson("engagements", response.Content);

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