public void PerformProjectOperation(Project project, ProjectOperation operation) { CheckDisposed(); if (project == null) { throw new ArgumentNullException(nameof(project)); } CheckConnected(); string tag = "project_" + operation.ToString().ToLower(); XElement request = new XElement(tag, new XElement("project_url", project.MasterUrl)); CheckResponse(PerformRpc(request)); }
/// <summary> /// Project operations: /// - Reset a project. /// - Detach from a project. /// - Update a project. /// - Suspend a project. /// - Resume a project. /// - Stop getting new tasks for a project. /// - Receive new tasks for a project. /// - Detach from a project after all it's tasks are finished. /// - Don't detach from a project after all it's tasks are finished. /// This request requires authentication. /// </summary> /// <param name="project"></param> /// <param name="operation">Reset/Detach/Update/Suspend/Resume/NoMoreWork/AllowMoreWork/DetachWhenDone/DontDetachWhenDone</param> /// <returns></returns> public async Task PerformProjectOperationAsync(Project project, ProjectOperation operation) { CheckDisposed(); if (project == null) { throw new ArgumentNullException(nameof(project)); } CheckConnected(); string tag; switch (operation) { case ProjectOperation.Reset: case ProjectOperation.Detach: case ProjectOperation.Update: case ProjectOperation.Suspend: case ProjectOperation.Resume: case ProjectOperation.AllowMoreWork: case ProjectOperation.NoMoreWork: tag = "project_" + operation.ToString().ToLower(); break; case ProjectOperation.DetachWhenDone: tag = "project_detach_when_done"; break; case ProjectOperation.DontDetachWhenDone: tag = "project_dont_detach_when_done"; break; default: throw new ArgumentException("Invalid project operation.", nameof(operation)); } XElement request = new XElement(tag, new XElement("project_url", project.MasterUrl)); CheckResponse(await PerformRpcAsync(request)); }