/// <summary> /// Accesses the /tasks/{id}/removeFollowers endpoint. /// </summary> /// <returns></returns> public async Task RemoveFollower(AsanaUser[] followers) { var request = new RestRequest("/tasks/{id}/removeFollowers", Method.POST); request.AddUrlSegment("id", Id.ToString()); request.AddParameter("followers", followers.ToString()); // execute the request var response = await AsanaHost.RestClient.ExecuteTaskAsync(request); using (var stringReader = new StringReader(response.Content)) // raw content as string using (var reader = new JsonTextReader(stringReader)) { var jsonData = AsanaHost.JsonDeserializer.Deserialize<AsanaResponse>(reader); if (!ReferenceEquals(jsonData.Errors, null)) // || !string.IsNullOrEmpty(jsonData.Errors.Message) throw new Exception("A remote error has occured: " + jsonData.Errors.First().Message); } }
/// <summary> /// Accesses the /workspaces/{id}/tasks endpoint. /// </summary> /// <returns></returns> public async Task<AsanaCollection<AsanaTask>> GetTasks(AsanaUser assignee = null, System.Nullable<System.DateTime> completedSince = null, System.Nullable<System.DateTime> modifiedSince = null, string optFields = null, bool assigneeIsMe = false, bool completedSinceIsNow = false) { var request = new RestRequest("/workspaces/{id}/tasks", Method.GET); request.AddUrlSegment("id", Id.ToString()); if (assigneeIsMe) request.AddParameter("assignee", "me"); else if (!ReferenceEquals(assignee, null)) request.AddParameter("assignee", assignee.ToString()); if (completedSinceIsNow) request.AddParameter("completed_since", "now"); else if (!ReferenceEquals(completedSince, null)) request.AddParameter("completed_since", completedSince.ToString()); if (!ReferenceEquals(modifiedSince, null)) request.AddParameter("modified_since", modifiedSince.ToString()); if (!ReferenceEquals(optFields, null)) request.AddParameter("opt_fields", optFields.ToString()); // execute the request var response = await AsanaHost.RestClient.ExecuteTaskAsync(request); using (var stringReader = new StringReader(response.Content)) // raw content as string using (var reader = new JsonTextReader(stringReader)) { var jsonData = AsanaHost.JsonDeserializer.Deserialize<AsanaArrayResponse>(reader); if (!ReferenceEquals(jsonData.Errors, null)) // || !string.IsNullOrEmpty(jsonData.Errors.Message) throw new Exception("A remote error has occured: " + jsonData.Errors.First().Message); var resultsCollection = jsonData.Data.ToObject<List<AsanaTask>>(AsanaHost.JsonDeserializer); if (ReferenceEquals(Tasks, null)) { Tasks = new AsanaCollection<AsanaTask>(resultsCollection); } else { Tasks.Import(resultsCollection); } AsanaHost.Cache.AsanaTaskCollection.Import(resultsCollection, true); return Tasks; } }