/// <summary>
        /// Retrieve a list of all messages in the conversation
        /// </summary>
        /// <param name="options"> Read Message parameters </param>
        /// <param name="client"> Client to make requests to Twilio </param>
        /// <returns> A single instance of Message </returns>
        public static ResourceSet <MessageResource> Read(ReadMessageOptions options, ITwilioRestClient client = null)
        {
            client = client ?? TwilioClient.GetRestClient();
            var response = client.Request(BuildReadRequest(options, client));

            var page = Page <MessageResource> .FromJson("messages", response.Content);

            return(new ResourceSet <MessageResource>(page, options, client));
        }
 private static Request BuildReadRequest(ReadMessageOptions options, ITwilioRestClient client)
 {
     return(new Request(
                HttpMethod.Get,
                Rest.Domain.Conversations,
                "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages",
                queryParams: options.GetParams(),
                headerParams: null
                ));
 }
        /// <summary>
        /// Retrieve a list of all messages in the conversation
        /// </summary>
        /// <param name="pathChatServiceSid"> The SID of the Conversation Service that the resource is associated with. </param>
        /// <param name="pathConversationSid"> The unique ID of the Conversation for messages. </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 Message </returns>
        public static async System.Threading.Tasks.Task <ResourceSet <MessageResource> > ReadAsync(string pathChatServiceSid,
                                                                                                   string pathConversationSid,
                                                                                                   int?pageSize             = null,
                                                                                                   long?limit               = null,
                                                                                                   ITwilioRestClient client = null)
        {
            var options = new ReadMessageOptions(pathChatServiceSid, pathConversationSid)
            {
                PageSize = pageSize, Limit = limit
            };

            return(await ReadAsync(options, client));
        }
        /// <summary>
        /// Retrieve a list of all messages in the conversation
        /// </summary>
        /// <param name="pathChatServiceSid"> The SID of the Conversation Service that the resource is associated with. </param>
        /// <param name="pathConversationSid"> The unique ID of the Conversation for messages. </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 Message </returns>
        public static ResourceSet <MessageResource> Read(string pathChatServiceSid,
                                                         string pathConversationSid,
                                                         int?pageSize             = null,
                                                         long?limit               = null,
                                                         ITwilioRestClient client = null)
        {
            var options = new ReadMessageOptions(pathChatServiceSid, pathConversationSid)
            {
                PageSize = pageSize, Limit = limit
            };

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

            var page = Page <MessageResource> .FromJson("messages", response.Content);

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