public RingCentralClientWrapper(IOptionsMonitor <RingCentralOptions> options, IHandoffRequestRecognizer handoffRequestRecognizer, ILogger logger = null)
        {
            _options = options ?? throw new ArgumentNullException(nameof(options));
            _handoffRequestRecognizer = handoffRequestRecognizer ?? throw new ArgumentNullException(nameof(handoffRequestRecognizer));
            _logger = logger ?? NullLogger.Instance;

            if (string.IsNullOrWhiteSpace(_options.CurrentValue.RingCentralEngageApiAccessToken))
            {
                throw new ArgumentException(nameof(options.CurrentValue.RingCentralEngageApiAccessToken));
            }

            if (_options.CurrentValue.RingCentralEngageApiUrl == null)
            {
                throw new ArgumentException(nameof(options.CurrentValue.RingCentralEngageApiUrl));
            }

            // DimeloClient is used to send messages out to RingCentral platform in order to log messages
            // only do this if this feature has been enabled.
            if (_options.CurrentValue.LogMessagesToRingCentral)
            {
                if (string.IsNullOrWhiteSpace(_options.CurrentValue.RingCentralEngageCustomSourceRealtimeEndpointUrl))
                {
                    throw new ArgumentException(nameof(_options.CurrentValue.RingCentralEngageCustomSourceRealtimeEndpointUrl));
                }

                if (_options.CurrentValue.RingCentralEngageCustomSourceApiAccessToken == null)
                {
                    throw new ArgumentException(nameof(_options.CurrentValue.RingCentralEngageCustomSourceApiAccessToken));
                }
                _ringCentralClient = new DimeloClient(_options.CurrentValue.RingCentralEngageCustomSourceRealtimeEndpointUrl, _options.CurrentValue.RingCentralEngageCustomSourceApiAccessToken);
            }
        }
コード例 #2
0
        public async Task <bool> SendDeleteThread(Thread thread)
        {
            bool result = false;

            try
            {
                MainPage.Log($"===== DELETE 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 = Sdk.Models.CreateAction.Thread;

                //Sdk.Models.Thread sdkThread = new Sdk.Models.Thread();
                //sdkThread.Id = thread.Id;
                //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);
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        public async Task <bool> SendUpdateUser(User user)
        {
            bool result = false;

            try
            {
                MainPage.Log($"===== UPDATE 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 = Sdk.Models.CreateAction.UserUpdate;

                //Sdk.Models.User sdkUser = new 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);
        }
 public RingCentralClientWrapper(DimeloClient ringCentralClient, ILogger logger = null)
 {
     _ringCentralClient = ringCentralClient ?? throw new ArgumentNullException(nameof(ringCentralClient));
     _logger            = logger ?? NullLogger.Instance;
 }