public async Task <DC_ListTaskResponse> ListAllTask(DC_ListTaskRequest listTaskRequest = null)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            var queryParams = ((listTaskRequest != null) && (listTaskRequest.BuildQueryParams().Length > 0)) ? listTaskRequest.BuildQueryParams() : string.Empty;

            uriBuilder.Path = $"/v3/tasks";
            if (!string.IsNullOrWhiteSpace(queryParams))
            {
                uriBuilder.Query = queryParams;
            }

            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Get;
            var authHeader = await BuildAuthenticationHeader();

            if (!string.IsNullOrWhiteSpace(authHeader.Key))
            {
                if (client.Headers.ContainsKey(authHeader.Key))
                {
                    client.Headers[authHeader.Key] = authHeader.Value;
                }
                else
                {
                    client.Headers.Add(authHeader);
                }
            }
            var expectedReturnStatus = 200;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <DC_ListTaskResponse>(await response.ReadContentAsStringAsync()));
        }
Ejemplo n.º 2
0
        public async Task <DC_ListTaskResponse> ListAllTask(DC_ListTaskRequest listTaskRequest = null)
        {
            UriBuilder uriBuilder = new UriBuilder(this.Client.CloudTarget);

            var queryParams = ((listTaskRequest != null) && (listTaskRequest.BuildQueryParams().Length > 0)) ? "?" + listTaskRequest.BuildQueryParams() : string.Empty;

            uriBuilder.Path = $"/v3/tasks{queryParams}";

            var client = this.GetHttpClient();

            client.Uri    = uriBuilder.Uri;
            client.Method = HttpMethod.Get;

            var expectedReturnStatus = 200;
            var response             = await this.SendAsync(client, expectedReturnStatus);

            return(Utilities.DeserializeJson <DC_ListTaskResponse>(await response.Content.ReadAsStringAsync()));
        }