/// <summary>
        /// List workers statictics on current workspace with filters
        /// </summary>
        /// <param name="workspaceSid">The Sid of the workspace the task queues belong to</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public virtual void ListWorkersStatistics(string workspaceSid, WorkersStatisticsRequest options, Action<WorkersStatistics> callback)
        {
            Require.Argument("WorkspaceSid", workspaceSid);

            var request = new RestRequest();
            request.Resource = "Workspaces/{WorkspaceSid}/Workers/Statistics";

            request.AddUrlSegment("WorkspaceSid", workspaceSid);

            AddWorkersStatisticsOptions(options, request);

            ExecuteAsync<WorkersStatistics>(request, callback);
        }
Exemplo n.º 2
0
 private void AddWorkersStatisticsOptions(WorkersStatisticsRequest options, RestRequest request)
 {
     AddStatisticsDateOptions(options, request);
     if (options.FriendlyName.HasValue()) {
         request.AddParameter("FriendlyName", options.FriendlyName);
     }
     if (options.TaskQueueSid.HasValue()) {
         request.AddParameter("TaskQueueSid", options.TaskQueueSid);
     }
     if (options.TaskQueueName.HasValue()) {
         request.AddParameter("TaskQueueName", options.TaskQueueName);
     }
 }
Exemplo n.º 3
0
        /// <summary>
        /// List workers statistics on current workspace with filters
        /// </summary>
        /// <param name="workspaceSid">The Sid of the workspace the task queues belong to</param>
        /// <param name="options">Filtering options for the statistics request</param>>
        public virtual WorkersStatistics ListWorkersStatistics(string workspaceSid, WorkersStatisticsRequest options)
        {
            Require.Argument("WorkspaceSid", workspaceSid);

            var request = new RestRequest();
            request.Resource = "Workspaces/{WorkspaceSid}/Workers/Statistics";

            request.AddUrlSegment("WorkspaceSid", workspaceSid);

            AddWorkersStatisticsOptions(options, request);

            return Execute<WorkersStatistics>(request);
        }
Exemplo n.º 4
0
        /// <summary>
        /// List workers statictics on current workspace with filters
        /// </summary>
        /// <param name="workspaceSid">The Sid of the workspace the task queues belong to</param>
        /// <param name="callback">Method to call upon successful completion</param>
        public virtual void ListWorkersStatistics(string workspaceSid, WorkersStatisticsRequest options, Action <WorkersStatistics> callback)
        {
            Require.Argument("WorkspaceSid", workspaceSid);

            var request = new RestRequest();

            request.Resource = "Workspaces/{WorkspaceSid}/Workers/Statistics";

            request.AddUrlSegment("WorkspaceSid", workspaceSid);

            AddWorkersStatisticsOptions(options, request);

            ExecuteAsync <WorkersStatistics>(request, callback);
        }
Exemplo n.º 5
0
        /// <summary>
        /// List workers statistics on current workspace with filters
        /// </summary>
        /// <param name="workspaceSid">The Sid of the workspace the task queues belong to</param>
        /// <param name="options">Filtering options for the statistics request</param>>
        public virtual WorkersStatistics ListWorkersStatistics(string workspaceSid, WorkersStatisticsRequest options)
        {
            Require.Argument("WorkspaceSid", workspaceSid);

            var request = new RestRequest();

            request.Resource = "Workspaces/{WorkspaceSid}/Workers/Statistics";

            request.AddUrlSegment("WorkspaceSid", workspaceSid);

            AddWorkersStatisticsOptions(options, request);

            return(Execute <WorkersStatistics>(request));
        }
 private void AddWorkersStatisticsOptions(WorkersStatisticsRequest options, RestRequest request)
 {
     AddStatisticsDateOptions(options, request);
     if (options.FriendlyName.HasValue())
     {
         request.AddParameter("FriendlyName", options.FriendlyName);
     }
     if (options.TaskQueueSid.HasValue())
     {
         request.AddParameter("TaskQueueSid", options.TaskQueueSid);
     }
     if (options.TaskQueueName.HasValue())
     {
         request.AddParameter("TaskQueueName", options.TaskQueueName);
     }
 }
        public async System.Threading.Tasks.Task ShouldListWorkersStatisticsUsingFilters()
        {
            RestRequest savedRequest = null;

            var tcs = new TaskCompletionSource<WorkersStatistics>();
            tcs.SetResult(new WorkersStatistics());

            mockClient.Setup(trc => trc.Execute<WorkersStatistics>(It.IsAny<RestRequest>()))
                .Callback<RestRequest>((request) => savedRequest = request)
                .Returns(tcs.Task);
            var client = mockClient.Object;
            var friendlyName = Twilio.Api.Tests.Utilities.MakeRandomFriendlyName();
            var minutes = 10;
            var taskQueueSid = "WQ123";
            var taskQueueName = Twilio.Api.Tests.Utilities.MakeRandomFriendlyName ();
            var options = new WorkersStatisticsRequest();
            options.Minutes = minutes;
            options.FriendlyName = friendlyName;
            options.TaskQueueSid = taskQueueSid;
            options.TaskQueueName = taskQueueName;

            await client.ListWorkersStatisticsAsync(WORKSPACE_SID, options);

            mockClient.Verify(trc => trc.Execute<WorkersStatistics>(It.IsAny<RestRequest>()), Times.Once);
            Assert.IsNotNull(savedRequest);
            Assert.AreEqual("Workspaces/{WorkspaceSid}/Workers/Statistics", savedRequest.Resource);
            Assert.AreEqual("GET", savedRequest.Method);
            Assert.AreEqual(5, savedRequest.Parameters.Count);
            var workspaceSidParam = savedRequest.Parameters.Find(x => x.Name == "WorkspaceSid");
            Assert.IsNotNull (workspaceSidParam);
            Assert.AreEqual (WORKSPACE_SID, workspaceSidParam.Value);
            var friendlyNameParam = savedRequest.Parameters.Find(x => x.Name == "FriendlyName");
            Assert.IsNotNull (friendlyNameParam);
            Assert.AreEqual (friendlyName, friendlyNameParam.Value);
            var taskQueueSidParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueSid");
            Assert.IsNotNull (taskQueueSidParam);
            Assert.AreEqual (taskQueueSid, taskQueueSidParam.Value);
            var taskQueueNameParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueName");
            Assert.IsNotNull (taskQueueNameParam);
            Assert.AreEqual (taskQueueName, taskQueueNameParam.Value);
            var minutesParam = savedRequest.Parameters.Find(x => x.Name == "Minutes");
            Assert.IsNotNull(minutesParam);
            Assert.AreEqual(minutes, minutesParam.Value);
        }
        public void ShouldListWorkersStatisticsUsingFiltersAsynchronously()
        {
            RestRequest savedRequest = null;
            mockClient.Setup(trc => trc.ExecuteAsync<WorkersStatistics>(It.IsAny<RestRequest>(), It.IsAny<Action<WorkersStatistics>>()))
                .Callback<RestRequest, Action<WorkersStatistics>>((request, action) => savedRequest = request);
            var client = mockClient.Object;
            manualResetEvent = new ManualResetEvent(false);
            var options = new WorkersStatisticsRequest();
            options.FriendlyName = Twilio.Api.Tests.Utilities.MakeRandomFriendlyName();
            options.Minutes = 10;
            options.TaskQueueSid = "WQ123";
            options.TaskQueueName = Twilio.Api.Tests.Utilities.MakeRandomFriendlyName();;

            client.ListWorkersStatistics(WORKSPACE_SID, options, stats => {
                manualResetEvent.Set();
            });

            mockClient.Verify(trc => trc.ExecuteAsync<WorkersStatistics>(It.IsAny<RestRequest>(), It.IsAny<Action<WorkersStatistics>>()), Times.Once);
            Assert.IsNotNull(savedRequest);
            Assert.AreEqual("Workspaces/{WorkspaceSid}/Workers/Statistics", savedRequest.Resource);
            Assert.AreEqual("GET", savedRequest.Method);
            Assert.AreEqual(5, savedRequest.Parameters.Count);
            var workspaceSidParam = savedRequest.Parameters.Find(x => x.Name == "WorkspaceSid");
            Assert.IsNotNull (workspaceSidParam);
            Assert.AreEqual (WORKSPACE_SID, workspaceSidParam.Value);
            var friendlyNameParam = savedRequest.Parameters.Find(x => x.Name == "FriendlyName");
            Assert.IsNotNull (friendlyNameParam);
            Assert.AreEqual (options.FriendlyName, friendlyNameParam.Value);
            var taskQueueSidParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueSid");
            Assert.IsNotNull (taskQueueSidParam);
            Assert.AreEqual (options.TaskQueueSid, taskQueueSidParam.Value);
            var taskQueueNameParam = savedRequest.Parameters.Find(x => x.Name == "TaskQueueName");
            Assert.IsNotNull (taskQueueNameParam);
            Assert.AreEqual (options.TaskQueueName, taskQueueNameParam.Value);
            var minutesParam = savedRequest.Parameters.Find(x => x.Name == "Minutes");
            Assert.IsNotNull(minutesParam);
            Assert.AreEqual(options.Minutes, minutesParam.Value);
        }