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)); }
async Task IWrikeGroupsClient.DeleteAsync(WrikeClientIdParameter id, bool isTest) { var uriBuilder = new WrikeUriBuilder($"groups/{id}") .AddParameter("test", isTest); await SendRequest <WrikeGroup>(uriBuilder.GetUri(), HttpMethods.Delete).ConfigureAwait(false); }
async Task <List <WrikeComment> > IWrikeCommentsClient.GetAsync(WrikeClientIdListParameter commentIds, bool?plainText) { var requestUri = $"comments/{commentIds}"; var uriBuilder = new WrikeUriBuilder(requestUri).AddParameter("plainText", plainText); var response = await SendRequest <WrikeComment>(uriBuilder.GetUri(), HttpMethods.Get, jsonConverter : new WrikeCommentConverter()).ConfigureAwait(false); return(GetReponseDataList(response)); }
async Task <WrikeTimelog> IWrikeTimelogsClient.GetAsync(WrikeClientIdParameter id, bool?plainText) { var uriBuilder = new WrikeUriBuilder($"timelogs/{id}") .AddParameter("plainText", plainText); var response = await SendRequest <WrikeTimelog>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(GetReponseDataFirstItem(response)); }
async Task <List <WrikeAttachment> > IWrikeAttachmentsClient.GetAsync(WrikeClientIdListParameter ids, bool?versions) { var uriBuilder = new WrikeUriBuilder($"attachments/{ids}") .AddParameter("versions", versions); var response = await SendRequest <WrikeAttachment>(uriBuilder.GetUri(), HttpMethods.Get, jsonConverter : new WrikeAttachmentConverter()).ConfigureAwait(false); return(GetReponseDataList(response)); }
async Task <Stream> IWrikeAttachmentsClient.DownloadPreviewAsync(WrikeClientIdParameter id, WrikePreviewDimension?size) { var uriBuilder = new WrikeUriBuilder($"attachments/{id}/preview") .AddParameter("size", size); var response = await SendRequestAndGetStream <Stream>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(response); }
async Task <List <WrikeTaskAttachment> > IWrikeAttachmentsClient.GetInTaskAsync(WrikeClientIdParameter taskId, bool?versions, WrikeDateFilterRange createdDate, bool?withUrls) { var uriBuilder = new WrikeUriBuilder($"tasks/{taskId}/attachments") .AddParameter("versions", versions) .AddParameter("createdDate", createdDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss'Z'")) .AddParameter("withUrls", withUrls); var response = await SendRequest <WrikeTaskAttachment>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(GetReponseDataList(response)); }
async Task <List <WrikeTaskComment> > IWrikeCommentsClient.GetInTaskAsync(WrikeClientIdParameter taskId, bool?plainText) { var requestUri = $"tasks/{taskId}/comments"; var uriBuilder = new WrikeUriBuilder(requestUri) .AddParameter("plainText", plainText); var response = await SendRequest <WrikeTaskComment>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(GetReponseDataList(response)); }
async Task <List <WrikeComment> > IWrikeCommentsClient.GetAsync(bool?plainText, int?limit, WrikeDateFilterRange updatedDate) { var requestUri = "comments"; var uriBuilder = new WrikeUriBuilder(requestUri) .AddParameter("plainText", plainText) .AddParameter("limit", limit) .AddParameter("updatedDate", updatedDate); var response = await SendRequest <WrikeComment>(uriBuilder.GetUri(), HttpMethods.Get, jsonConverter : new WrikeCommentConverter()).ConfigureAwait(false); return(GetReponseDataList(response)); }
async Task <List <WrikeFolder> > IWrikeFoldersAndProjectsClient.GetFoldersAsync(WrikeClientIdListParameter folderIds, List <string> optionalFields) { if (optionalFields != null && optionalFields.Count > 0 && optionalFields.Except(WrikeFolder.OptionalFields.List).Any()) { throw new ArgumentOutOfRangeException(nameof(optionalFields), "Use only values in WrikeFolder.OptionalFields"); } var uriBuilder = new WrikeUriBuilder($"folders/{folderIds}") .AddParameter("fields", optionalFields); var response = await SendRequest <WrikeFolder>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(GetReponseDataList(response)); }
async Task <WrikeGroup> IWrikeGroupsClient.GetAsync(WrikeClientIdParameter id, List <string> optionalFields) { if (optionalFields != null && optionalFields.Count > 0 && optionalFields.Except(WrikeGroup.OptionalFields.List).Any()) { throw new ArgumentOutOfRangeException(nameof(optionalFields), "Use only values in WrikeGroup.OptionalFields"); } var uriBuilder = new WrikeUriBuilder($"groups/{id}") .AddParameter("fields", optionalFields); var response = await SendRequest <WrikeGroup>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(GetReponseDataFirstItem(response)); }
async Task <List <WrikeTimelog> > IWrikeTimelogsClient.GetAsync(string contactId, string folderId, string taskId, string categoryId, WrikeDateFilterRange createdDate, WrikeDateFilterRange updatedDate, IWrikeDateFilter trackedDate, bool?me, bool?descendants, bool?subTasks, bool?plainText, List <string> categoryIds) { int notNullCount = 0; string requestUri = "timelogs"; if (!string.IsNullOrWhiteSpace(contactId)) { requestUri = $"contacts/{contactId}/timelogs"; notNullCount++; } else if (!string.IsNullOrWhiteSpace(folderId)) { requestUri = $"folders/{folderId}/timelogs"; notNullCount++; } else if (!string.IsNullOrWhiteSpace(taskId)) { requestUri = $"tasks/{taskId}/timelogs"; notNullCount++; } else if (!string.IsNullOrWhiteSpace(categoryId)) { requestUri = $"timelog_categories/{categoryId}/timelogs"; notNullCount++; } if (notNullCount > 1) { throw new ArgumentException("only one of contactId, folderId, taskId or categoryId can be used"); } var uriBuilder = new WrikeUriBuilder(requestUri) .AddParameter("createdDate", createdDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss'Z'")) .AddParameter("updatedDate", updatedDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss'Z'")) .AddParameter("trackedDate", trackedDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss")) .AddParameter("me", me) .AddParameter("descendants", descendants) .AddParameter("subTasks", subTasks) .AddParameter("plainText", plainText) .AddParameter("timelogCategories", categoryIds); var response = await SendRequest <WrikeTimelog>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(GetReponseDataList(response)); }
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)); }
async Task <List <WrikeTask> > IWrikeTasksClient.GetAsync(string folderId, bool?addDescendants, string title, WrikeTaskStatus?status, WrikeTaskImportance?importance, IWrikeDateFilter startDate, IWrikeDateFilter dueDate, IWrikeDateFilter scheduledDate, WrikeDateFilterRange createdDate, WrikeDateFilterRange updatedDate, WrikeDateFilterRange completedDate, List <string> authors, List <string> responsibles, List <string> shareds, string permalink, WrikeTaskDateType?type, int?limit, WrikeTaskSortField?sortField, WrikeSortOrder?sortOrder, bool?addSubTasks, int?pageSize, string nextPageToken, WrikeMetadata metadata, WrikeCustomFieldData customField, List <string> customStatuses, List <string> fields) { var requestUri = "tasks"; if (!string.IsNullOrWhiteSpace(folderId)) { requestUri = $"folders/{folderId}/tasks"; } var uriBuilder = new WrikeUriBuilder(requestUri) .AddParameter("descendants", addDescendants) .AddParameter("title", title) .AddParameter("status", status) .AddParameter("importance", importance) .AddParameter("startDate", startDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss")) .AddParameter("dueDate", dueDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss")) .AddParameter("scheduledDate", scheduledDate, new CustomDateTimeConverter("yyyy-MM-dd")) .AddParameter("createdDate", createdDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss'Z'")) .AddParameter("updatedDate", updatedDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss'Z'")) .AddParameter("completedDate", completedDate, new CustomDateTimeConverter("yyyy-MM-dd'T'HH:mm:ss'Z'")) .AddParameter("authors", authors) .AddParameter("responsibles", responsibles) .AddParameter("shareds", shareds) .AddParameter("permalink", permalink) .AddParameter("type", type) .AddParameter("limit", limit) .AddParameter("sortField", sortField) .AddParameter("sortOrder", sortOrder) .AddParameter("subTasks", addSubTasks) .AddParameter("pageSize", pageSize) .AddParameter("nextPageToken", nextPageToken) .AddParameter("metadata", metadata) .AddParameter("customField", customField) .AddParameter("customStatuses", customStatuses) .AddParameter("fields", fields); var response = await SendRequest <WrikeTask>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); _lastResponseSize = response.ResponseSize; _lastNextPageToken = response.NextPageToken; return(GetReponseDataList(response)); }
async Task <List <WrikeApiV2Id> > IWrikeIdsClient.GetAsync(WrikeEntityType entityType, List <int> ids) { if (ids == null) { throw new ArgumentNullException(nameof(ids)); } if (ids.Count == 0) { throw new ArgumentException("value can not be empty", nameof(ids)); } var uriBuilder = new WrikeUriBuilder("ids") .AddParameter("type", entityType) .AddParameter("ids", ids); var response = await SendRequest <WrikeApiV2Id>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(GetReponseDataList(response)); }
async Task <List <WrikeTask> > IWrikeTasksClient.GetAsync(WrikeClientIdListParameter taskIds, List <string> optionalFields) { var supportedOptionalFields = new List <string> { WrikeTask.OptionalFields.Recurrent, WrikeTask.OptionalFields.AttachmentCount }; if (optionalFields != null && (optionalFields.Count > 2 || optionalFields.Any(o => !supportedOptionalFields.Contains(o)))) { throw new ArgumentOutOfRangeException(nameof(optionalFields), "Only Recurrent and AttachmentCount is supported."); } var uriBuilder = new WrikeUriBuilder($"tasks/{taskIds}") .AddParameter("fields", optionalFields); var response = await SendRequest <WrikeTask>(uriBuilder.GetUri(), HttpMethods.Get).ConfigureAwait(false); return(GetReponseDataList(response)); }
/// <summary> /// The URL that user will click to start the authorization process /// </summary> /// <param name="clientId"></param> /// <param name="redirectUri"></param> /// <param name="state"></param> /// <param name="scope"></param> /// See <see href="https://developers.wrike.com/documentation/oauth2"/> public static string GetAuthorizationUrl(string clientId, string redirectUri = null, string state = null, List <string> scope = null) { if (clientId == null) { throw new ArgumentNullException(nameof(clientId)); } if (clientId.Trim() == string.Empty) { throw new ArgumentException("value can not be empty", nameof(clientId)); } var uriBuilder = new WrikeUriBuilder("https://www.wrike.com/oauth2/authorize/v4") .AddParameter("client_id", clientId) .AddParameter("response_type", "code") .AddParameter("redirect_uri", redirectUri) .AddParameter("state", state) .AddParameter("scope", string.Join(",", scope)); return(uriBuilder.GetUri()); }