/// <summary> /// Gets a label info by ID. /// </summary> /// <param name="id">The ID of the label.</param> /// <returns> /// The label info. /// </returns> /// <exception cref="HttpRequestException">API exception.</exception> public Task <LabelInfo> GetAsync(ComplexId id) { return(TodoistClient.PostAsync <LabelInfo>( "labels/get", new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("label_id", id.ToString()) })); }
/// <summary> /// Gets a section by ID. /// </summary> /// <param name="id">The ID of the section.</param> /// <returns> /// The section. /// </returns> /// <exception cref="HttpRequestException">API exception.</exception> public Task <Section> GetAsync(ComplexId id) { return(TodoistClient.PostAsync <Section>( "sections/get", new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("section_id", id.ToString()) })); }
/// <summary> /// Gets a template for the project as a file asynchronous. /// </summary> /// <param name="projectId">The project identifier.</param> /// <returns>The CSV template is returned.</returns> /// <exception cref="HttpRequestException">API exception.</exception> public async Task <string> ExportAsFileAsync(ComplexId projectId) { var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("project_id", projectId.ToString()) }; return(await _todoistClient.PostRawAsync("templates/export_as_file", parameters).ConfigureAwait(false)); }
/// <summary> /// Gets a template for the project as a shareable URL asynchronous. /// </summary> /// <param name="projectId">The project identifier.</param> /// <returns>The file object of the template.</returns> /// <exception cref="HttpRequestException">API exception.</exception> public async Task <FileBase> ExportAsShareableUrlAsync(ComplexId projectId) { var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("project_id", projectId.ToString()) }; return(await _todoistClient.PostAsync <FileBase>("templates/export_as_url", parameters).ConfigureAwait(false)); }
/// <summary> /// Gets a project by ID. /// </summary> /// <param name="id">The ID of the project.</param> /// <returns> /// The project. /// </returns> /// <exception cref="HttpRequestException">API exception.</exception> public Task <ProjectInfo> GetAsync(ComplexId id) { return(TodoistClient.PostAsync <ProjectInfo>( "projects/get", new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("project_id", id.ToString()) })); }
/// <summary> /// Imports a template into a project asynchronous. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="fileContent">Content of the template.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="HttpRequestException">API exception.</exception> public Task ImportIntoProjectAsync(ComplexId projectId, byte[] fileContent) { var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("project_id", projectId.ToString()) }; var files = new[] { new ByteArrayContent(fileContent) }; return(_todoistClient.PostFormAsync <dynamic>("templates/import_into_project", parameters, files)); }
/// <summary> /// Moves the tasks to the project asynchronous. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="items">The items.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="ArgumentNullException"><paramref name="items" /> is <see langword="null" /></exception> /// <exception cref="ArgumentException">Unable to move an item with an empty source project ID.</exception> /// <exception cref="HttpRequestException">API exception.</exception> /// <exception cref="AggregateException">Command execution exception.</exception> public async Task MoveToProjectAsync(ComplexId projectId, params Item[] items) { if (items == null) { throw new ArgumentNullException(nameof(items)); } var command = new Command(CommandType.MoveItem, new MoveItemArgument(items, projectId)); await ExecuteCommandAsync(command).ConfigureAwait(false); }
/// <summary> /// Shares a project. /// </summary> /// <param name="id">The project ID to be shared.</param> /// <param name="email">The user email with whom to share the project.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> /// <exception cref="ArgumentException">Value cannot be null or empty.</exception> public async Task ShareProjectAsync(ComplexId id, string email) { if (string.IsNullOrEmpty(email)) { throw new ArgumentException("Value cannot be null or empty.", nameof(email)); } var command = new Command(CommandType.ShareProject, new ShareProjectArgument(id, email)); await ExecuteCommandAsync(command).ConfigureAwait(false); }
/// <summary> /// Deletes a person from a shared project. /// </summary> /// <param name="id">The project ID to be affected.</param> /// <param name="email">The user email with whom to share the project.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> /// <exception cref="ArgumentException">Value cannot be null or empty.</exception> public Task DeleteCollaboratorAsync(ComplexId id, string email) { if (string.IsNullOrEmpty(email)) { throw new ArgumentException("Value cannot be null or empty.", nameof(email)); } var command = new Command(CommandType.DeleteCollaborator, new ShareProjectArgument(id, email)); return(ExecuteCommandAsync(command)); }
/// <summary> /// Gets a reminder info by ID. /// </summary> /// <param name="id">The ID of the reminder.</param> /// <returns> /// The reminder info. /// </returns> /// <exception cref="HttpRequestException">API exception.</exception> public Task <ReminderInfo> GetAsync(ComplexId id) { return(TodoistClient.PostAsync <ReminderInfo>( "reminders/get", new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>( "reminder_id", id.ToString()) })); }
/// <summary> /// Moves the tasks to the project asynchronous. /// </summary> /// <param name="projectId">The project identifier.</param> /// <param name="items">The items.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="ArgumentNullException"><paramref name="items" /> is <see langword="null" /></exception> /// <exception cref="ArgumentException">Unable to move an item with an empty source project ID.</exception> /// <exception cref="HttpRequestException">API exception.</exception> /// <exception cref="AggregateException">Command execution exception.</exception> public Task MoveToProjectAsync(ComplexId projectId, params Item[] items) { if (items == null) { throw new ArgumentNullException(nameof(items)); } var command = new Command(CommandType.MoveItem, new MoveItemArgument(items, projectId)); return(ExecuteCommandAsync(command)); }
/// <summary> /// Gets a filter info by ID. /// </summary> /// <param name="id">The ID of the filter.</param> /// <returns> /// The filter info. /// </returns> /// <exception cref="HttpRequestException">API exception.</exception> public async Task <FilterInfo> GetAsync(ComplexId id) { return (await TodoistClient.PostAsync <FilterInfo>( "filters/get", new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>("filter_id", id.ToString()) }).ConfigureAwait(false)); }
/// <summary> /// Adds the note asynchronous. /// </summary> /// <param name="note">The note.</param> /// <param name="projectId">The project ID.</param> /// <returns> /// The note ID. /// </returns> /// <exception cref="ArgumentNullException"><paramref name="note" /> is <see langword="null" /></exception> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> public async Task <ComplexId> AddToProjectAsync(Note note, ComplexId projectId) { if (note == null) { throw new ArgumentNullException(nameof(note)); } note.ProjectId = projectId; var command = CreateAddCommand(CommandType.AddNote, note); await ExecuteCommandAsync(command).ConfigureAwait(false); return(note.Id); }
private static List <KeyValuePair <string, string> > CreateParameters(ObjectType objectType, ComplexId objectId) { if (objectType == null) { throw new ArgumentNullException(nameof(objectType)); } var parameters = new List <KeyValuePair <string, string> > { new KeyValuePair <string, string>( "obj_type", objectType.ToString()), new KeyValuePair <string, string>( "obj_id", objectId.ToString()) }; return(parameters); }
/// <summary> /// Completes a recurring task. See also <see cref="CloseAsync" /> for a simplified version of the command. /// </summary> /// <param name="id">The recurring task ID.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="HttpRequestException">API exception.</exception> /// <exception cref="AggregateException">Command execution exception.</exception> public async Task CompleteRecurringAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.CompleteRecurringItem, id); await ExecuteCommandAsync(command).ConfigureAwait(false); }
/// <summary> /// Marks the last read live notification. /// </summary> /// <param name="id">The ID of the last read notification.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> public Task MarkLastReadAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.SetLastReadNotification, id); return(ExecuteCommandAsync(command)); }
/// <summary> /// Marks the last read live notification. /// </summary> /// <param name="id">The ID of the last read notification.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> public async Task MarkLastReadAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.SetLastReadNotification, id); await ExecuteCommandAsync(command).ConfigureAwait(false); }
/// <summary> /// Initializes a new instance of the <see cref="ItemState" /> class. /// </summary> /// <param name="itemId">The item identifier.</param> /// <param name="isChecked">The is checked.</param> /// <param name="indent">The indent.</param> /// <param name="inHistory">The in history.</param> /// <param name="order">The order.</param> public ItemState(ComplexId itemId, bool isChecked, int indent, bool inHistory, int order) : base(itemId, order, indent) { IsChecked = isChecked; InHistory = inHistory; }
/// <summary> /// Initializes a new instance of the <see cref="OrderEntry"/> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="order">The order.</param> public OrderEntry(ComplexId id, int order) { Id = id; Order = order; }
/// <summary> /// Unarchive a project. /// No ancestors will be unarchived along with the unarchived project. /// Instead, the project is unarchived alone, loses any parent relationship (becomes a root project), and is placed at the end of the list of other root projects. /// </summary> /// <param name="id">The project ID.</param> /// <returns> Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation. </returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> /// <remarks>Only available for Todoist Premium users.</remarks> public Task UnarchiveAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.UnarchiveProject, id); return(ExecuteCommandAsync(command)); }
/// <summary> /// Archive a section and all its descendants tasks. /// </summary> /// <param name="id">The section ID.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> public Task ArchiveAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.ArchiveSection, id); return(ExecuteCommandAsync(command)); }
/// <summary> /// Closes a task asynchronous. /// </summary> /// <param name="id">The item ID.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> /// <remarks> /// A simplified version of item_complete / item_update_date_complete. /// The command does exactly what official clients do when you close a task: regular task is completed and moved to history, /// subtask is checked (marked as done, but not moved to history), recurring task is moved forward (due date is updated). /// </remarks> public Task CloseAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.CloseItem, id); return(ExecuteCommandAsync(command)); }
/// <summary> /// Deletes an existing label asynchronous. /// </summary> /// <param name="id">The ID of the label.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> public Task DeleteAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.DeleteLabel, id); return(ExecuteCommandAsync(command)); }
public TestDomainEventWithComplexProperty(ComplexId id) { Id = id; }
/// <summary> /// Initializes a new instance of the <see cref="OrderIndentEntry"/> class. /// </summary> /// <param name="id">The identifier.</param> /// <param name="order">The order.</param> /// <param name="indent">The indent.</param> public OrderIndentEntry(ComplexId id, int order, int indent) : base(id, order) { Indent = indent; }
/// <summary> /// Creates a new email address for an object, or gets an existing email. /// </summary> /// <param name="objectType">Type of the object.</param> /// <param name="objectId">The object identifier.</param> /// <returns> /// The email information. /// </returns> /// <exception cref="HttpRequestException">API exception.</exception> public Task <EmailInfo> GetOrCreateAsync(ObjectType objectType, ComplexId objectId) { var parameters = CreateParameters(objectType, objectId); return(_todoistClient.PostAsync <EmailInfo>("emails/get_or_create", parameters)); }
/// <summary> /// Deletes an existing filter asynchronous. /// </summary> /// <param name="id">The ID of the filter.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="AggregateException">Command execution exception.</exception> /// <exception cref="HttpRequestException">API exception.</exception> public async Task DeleteAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.DeleteFilter, id); await ExecuteCommandAsync(command).ConfigureAwait(false); }
/// <summary> /// Completes a recurring task. See also <see cref="CloseAsync" /> for a simplified version of the command. /// </summary> /// <param name="id">The recurring task ID.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="HttpRequestException">API exception.</exception> /// <exception cref="AggregateException">Command execution exception.</exception> public Task CompleteRecurringAsync(ComplexId id) { var command = CreateEntityCommand(CommandType.CompleteRecurringItem, id); return(ExecuteCommandAsync(command)); }
internal Command CreateEntityCommand(CommandType commandType, ComplexId id) { return(new Command(commandType, new BaseEntity(id))); }
/// <summary> /// Disables an email address for an object. /// </summary> /// <param name="objectType">Type of the object.</param> /// <param name="objectId">The object identifier.</param> /// <returns>Returns <see cref="T:System.Threading.Tasks.Task" />.The task object representing the asynchronous operation.</returns> /// <exception cref="HttpRequestException">API exception.</exception> public Task DisableAsync(ObjectType objectType, ComplexId objectId) { var parameters = CreateParameters(objectType, objectId); return(_todoistClient.PostRawAsync("emails/disable", parameters)); }