public async Task <bool> SendNewMessage(Message message) { bool result = false; UpdateMessageWithMessageCategories(message); try { MainPage.Log($"===== SEND MESSAGE {message.Id} =====", true); MainPage.Log($"Create DimeloClient"); DimeloClient client = new DimeloClient(Settings.EndpointUrl, Settings.AccountToken); MainPage.Log($"Create MessageRequest"); DimeloRequest request = new DimeloRequest(); request.Action = RingCentral.Sdk.Models.CreateAction.Message; RingCentral.Sdk.Models.Message sdkMessage = new RingCentral.Sdk.Models.Message(); sdkMessage.Id = message.Id; if (!string.IsNullOrWhiteSpace(message.ThreadId)) { sdkMessage.ThreadId = message.ThreadId; } if (!string.IsNullOrWhiteSpace(message.ReplyToId)) { sdkMessage.InReplyToId = message.ReplyToId; } sdkMessage.Categories = message.Categories.ToArray(); if (message.Author != null) { sdkMessage.Author = new RingCentral.Sdk.Models.User(); sdkMessage.Author.Id = message.Author.Id; sdkMessage.Author.Firstname = message.Author.FirstName; sdkMessage.Author.Lastname = message.Author.LastName; sdkMessage.Author.Screenname = message.Author.ScreenName; sdkMessage.Author.Email = message.Author.Email; sdkMessage.Author.CreatedAt = message.Author.Created; sdkMessage.Author.UpdatedAt = message.Author.Updated; } sdkMessage.Body = message.Body; sdkMessage.CreatedAt = message.Created; sdkMessage.UpdatedAt = message.Updated; request.Params = sdkMessage; MainPage.Log("\n" + request.GetJson() + "\n"); MainPage.Log($"Send request"); string response = await client.SendAsync(request); MainPage.Log($"Response: {response}"); result = true; } catch (Exception ex) { MainPage.Log($"\nERROR: {ex.Message}"); MainPage.Log(ex.ToString()); } return(result); }
public async Task <bool> SendNewThread(Thread thread) { bool result = false; try { MainPage.Log($"===== CREATE THREAD {thread.DisplayName} =====", true); MainPage.Log($"Create DimeloClient"); DimeloClient client = new DimeloClient(Settings.EndpointUrl, Settings.AccountToken); MainPage.Log($"Create ThreadRequest"); DimeloRequest request = new DimeloRequest(); request.Action = RingCentral.Sdk.Models.CreateAction.Thread; RingCentral.Sdk.Models.Thread sdkThread = new RingCentral.Sdk.Models.Thread(); sdkThread.Id = thread.Id; sdkThread.Title = thread.Title; sdkThread.Body = thread.Body; sdkThread.Categories = thread.Categories.ToArray(); if (thread.Author != null) { sdkThread.Author = new RingCentral.Sdk.Models.User(); sdkThread.Author.Id = thread.Author.Id; sdkThread.Author.Firstname = thread.Author.FirstName; sdkThread.Author.Lastname = thread.Author.LastName; sdkThread.Author.Screenname = thread.Author.ScreenName; sdkThread.Author.Email = thread.Author.Email; sdkThread.Author.CreatedAt = thread.Author.Created; sdkThread.Author.UpdatedAt = thread.Author.Updated; } sdkThread.Format = RingCentral.Sdk.Models.Formatting.Text; sdkThread.CreatedAt = thread.Created; sdkThread.UpdatedAt = thread.Updated; request.Params = sdkThread; MainPage.Log("\n" + request.GetJson() + "\n"); MainPage.Log($"Send request"); string response = await client.SendAsync(request); MainPage.Log($"Response: {response}"); result = true; } catch (Exception ex) { MainPage.Log($"\nERROR: {ex.Message}"); MainPage.Log(ex.ToString()); } return(result); }
public async Task <bool> SendNewUser(User user) { bool result = false; try { MainPage.Log($"===== CREATE USER {user.DisplayName} =====", true); MainPage.Log($"Create DimeloClient"); DimeloClient client = new DimeloClient(Settings.EndpointUrl, Settings.AccountToken); MainPage.Log($"Create UserRequest"); DimeloRequest request = new DimeloRequest(); request.Action = RingCentral.Sdk.Models.CreateAction.User; RingCentral.Sdk.Models.User sdkUser = new RingCentral.Sdk.Models.User(); sdkUser.Id = user.Id; sdkUser.Firstname = user.FirstName; sdkUser.Lastname = user.LastName; sdkUser.Screenname = user.ScreenName; sdkUser.Email = user.Email; sdkUser.CreatedAt = user.Created; sdkUser.UpdatedAt = user.Updated; request.Params = sdkUser; MainPage.Log("\n" + request.GetJson() + "\n"); MainPage.Log($"Send request"); string response = await client.SendAsync(request); MainPage.Log($"Response: {response}"); result = true; } catch (Exception ex) { MainPage.Log($"\nERROR: {ex.Message}"); MainPage.Log(ex.ToString()); } return(result); }