/// <summary> /// Add a new message to the conversation in a specific service /// </summary> /// <param name="options"> Create Message parameters </param> /// <param name="client"> Client to make requests to Twilio </param> /// <returns> A single instance of Message </returns> public static MessageResource Create(CreateMessageOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = client.Request(BuildCreateRequest(options, client)); return(FromJson(response.Content)); }
private static Request BuildCreateRequest(CreateMessageOptions options, ITwilioRestClient client) { return(new Request( HttpMethod.Post, Rest.Domain.Conversations, "/v1/Services/" + options.PathChatServiceSid + "/Conversations/" + options.PathConversationSid + "/Messages", postParams: options.GetParams(), headerParams: options.GetHeaderParams() )); }
/// <summary> /// Add a new message to the conversation in a specific service /// </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 this message. </param> /// <param name="author"> The channel specific identifier of the message's author. </param> /// <param name="body"> The content of the message. </param> /// <param name="dateCreated"> The date that this resource was created. </param> /// <param name="dateUpdated"> The date that this resource was last updated. </param> /// <param name="attributes"> A string metadata field you can use to store any data you wish. </param> /// <param name="mediaSid"> The Media SID to be attached to the new Message. </param> /// <param name="xTwilioWebhookEnabled"> The X-Twilio-Webhook-Enabled HTTP request header </param> /// <param name="client"> Client to make requests to Twilio </param> /// <returns> A single instance of Message </returns> public static MessageResource Create(string pathChatServiceSid, string pathConversationSid, string author = null, string body = null, DateTime?dateCreated = null, DateTime?dateUpdated = null, string attributes = null, string mediaSid = null, MessageResource.WebhookEnabledTypeEnum xTwilioWebhookEnabled = null, ITwilioRestClient client = null) { var options = new CreateMessageOptions(pathChatServiceSid, pathConversationSid) { Author = author, Body = body, DateCreated = dateCreated, DateUpdated = dateUpdated, Attributes = attributes, MediaSid = mediaSid, XTwilioWebhookEnabled = xTwilioWebhookEnabled }; return(Create(options, client)); }
/// <summary> /// Add a new message to the conversation in a specific service /// </summary> /// <param name="options"> Create 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 <MessageResource> CreateAsync(CreateMessageOptions options, ITwilioRestClient client = null) { client = client ?? TwilioClient.GetRestClient(); var response = await client.RequestAsync(BuildCreateRequest(options, client)); return(FromJson(response.Content)); }