async Task <List <WrikeFolderTree> > IWrikeFoldersAndProjectsClient.GetFolderTreeAsync(string folderId, string permalink, bool?addDescendants, WrikeMetadata metadata, WrikeCustomFieldData customField, WrikeDateFilterRange updatedDate, bool?isProject, bool?isDeleted, List <string> optionalFields)
        {
            if (optionalFields != null && optionalFields.Count > 0 && optionalFields.Except(WrikeFolderTree.OptionalFields.List).Any())
            {
                throw new ArgumentOutOfRangeException(nameof(optionalFields), "Use only values in WrikeFolderTree.OptionalFields");
            }

            var requestUri = "folders";

            bool useFolderId = !string.IsNullOrWhiteSpace(folderId);

            if (useFolderId)
            {
                requestUri = $"folders/{folderId}/folders";
            }

            var uriBuilder = new WrikeUriBuilder(requestUri)
                             .AddParameter("permalink", permalink)
                             .AddParameter("descendants", addDescendants)
                             .AddParameter("metadata", metadata)
                             .AddParameter("customField", customField)
                             .AddParameter("updatedDate", updatedDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss'Z'"))
                             .AddParameter("project", isProject)
                             .AddParameter("deleted", isDeleted)
                             .AddParameter("fields", optionalFields);

            if (!useFolderId)
            {
                uriBuilder.AddParameter("deleted", isDeleted);
            }

            var response = await SendRequest <WrikeFolderTree>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false);

            return(GetReponseDataList(response));
        }
Exemplo n.º 2
0
        async Task <List <WrikeUser> > IWrikeContactsClient.GetAsync(WrikeClientIdListParameter contactIds, WrikeMetadata metadata, bool?retrieveMetadata)
        {
            var requestUri = $"contacts/{contactIds}";
            var uriBuilder = new WrikeUriBuilder(requestUri)
                             .AddParameter("metadata", metadata);

            if (retrieveMetadata.HasValue && retrieveMetadata == true)
            {
                var fields = new List <string> {
                    "metadata"
                };
                uriBuilder.AddParameter("fields", fields);
            }

            var response = await SendRequest <WrikeUser>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false);

            return(GetReponseDataList(response));
        }