// TaskList Methods public async Task <ListResult <GTaskList> > GetTaskListsAsync(string pageToken = null, ulong maxResults = 20) { ListResult <GTaskList> result = null; StringBuilder requestBuilder = new StringBuilder(); requestBuilder.Append("https://www.googleapis.com/tasks/v1/users/@me/lists"); Dictionary <string, object> queries = new Dictionary <string, object>(); if (pageToken != null) { queries.Add("pageToken", pageToken); } queries.Add("maxResults", maxResults); RequestHelper.AddQueriesToRequest(requestBuilder, queries); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestBuilder.ToString()); RequestHelper.AddAuthorizationHeader(request, ClientToken); var responseMessage = await _client.SendAsync(request); if (responseMessage.IsSuccessStatusCode) { string jsonReturned = await responseMessage.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject <ListResult <GTaskList> >(jsonReturned); } return(result); }
public async Task <ListResult <GTask> > GetTasksAsync(string taskListID, TasksQuery query) { ListResult <GTask> result = null; StringBuilder requestBuilder = new StringBuilder(); requestBuilder.Append($"https://www.googleapis.com/tasks/v1/lists/{taskListID}/tasks"); Dictionary <string, object> queries = new Dictionary <string, object>(); queries.Add("maxResults", query.MaxResults); queries.Add("showCompleted", query.ShowCompleted); queries.Add("showDeleted", query.ShowDeleted); queries.Add("showHidden", query.ShowHidden); QueryHelper.TryAddToQueries(query, queries); RequestHelper.AddQueriesToRequest(requestBuilder, queries); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestBuilder.ToString()); RequestHelper.AddAuthorizationHeader(request, ClientToken); var responseMessage = await _client.SendAsync(request); if (responseMessage.IsSuccessStatusCode) { string jsonReturned = await responseMessage.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject <ListResult <GTask> >(jsonReturned); } return(result); }
public async Task <bool> ClearTaskListAsync(string taskListID) { bool wasTaskCleared = false; string requestUrl = $"https://www.googleapis.com/tasks/v1/lists/{taskListID}/clear"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl); RequestHelper.AddAuthorizationHeader(request, ClientToken); var responseMessage = await _client.SendAsync(request); if (responseMessage.IsSuccessStatusCode) { wasTaskCleared = true; } return(wasTaskCleared); }
public async Task <GTaskList> GetTaskListAsync(string taskListID) { GTaskList result = null; string requestUrl = $"https://www.googleapis.com/tasks/v1/users/@me/lists/{taskListID}"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, requestUrl); RequestHelper.AddAuthorizationHeader(request, ClientToken); var responseMessage = await _client.SendAsync(request); if (responseMessage.IsSuccessStatusCode) { string jsonReturned = await responseMessage.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject <GTaskList>(jsonReturned); } return(result); }
public async Task <GTask> MoveTaskAsync(string taskID, string taskListID, string parentID = null, string previousSiblingID = null) { GTask result = null; StringBuilder requestBuilder = new StringBuilder(); requestBuilder.Append($"https://www.googleapis.com/tasks/v1/lists/{taskListID}/tasks/{taskID}/move"); Dictionary <string, object> queries = new Dictionary <string, object>(); if (parentID != null) { queries.Add("parent", parentID); } if (previousSiblingID != null) { queries.Add("previous", previousSiblingID); } RequestHelper.AddQueriesToRequest(requestBuilder, queries); HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestBuilder.ToString()); RequestHelper.AddAuthorizationHeader(request, ClientToken); var responseMessage = await _client.SendAsync(request); if (responseMessage.IsSuccessStatusCode) { string jsonReturned = await responseMessage.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject <GTask>(jsonReturned); } return(result); }
public async Task <GTaskList> AddTaskListAsync(GTaskList listToAdd) { GTaskList result = null; string requestUrl = "https://www.googleapis.com/tasks/v1/users/@me/lists"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, requestUrl); RequestHelper.AddAuthorizationHeader(request, ClientToken); var listJson = new StringContent(JsonConvert.SerializeObject(listToAdd), Encoding.UTF8, JsonMediaType); request.Content = listJson; var responseMessage = await _client.SendAsync(request); if (responseMessage.IsSuccessStatusCode) { string jsonReturned = await responseMessage.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject <GTaskList>(jsonReturned); } return(result); }
public async Task <GTask> UpdateTaskAsync(string taskListID, GTask updatedTask) { GTask result = null; string requestUrl = $"https://www.googleapis.com/tasks/v1/lists/{taskListID}/tasks/{updatedTask.ID}"; HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, requestUrl); RequestHelper.AddAuthorizationHeader(request, ClientToken); var listJson = new StringContent(JsonConvert.SerializeObject(updatedTask), Encoding.UTF8, JsonMediaType); request.Content = listJson; var responseMessage = await _client.SendAsync(request); if (responseMessage.IsSuccessStatusCode) { string jsonReturned = await responseMessage.Content.ReadAsStringAsync(); result = JsonConvert.DeserializeObject <GTask>(jsonReturned); } return(result); }