Ejemplo n.º 1
0
 /// <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())
     }));
 }
Ejemplo n.º 2
0
 /// <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())
     }));
 }
Ejemplo n.º 3
0
        /// <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));
        }
Ejemplo n.º 4
0
        /// <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));
        }
Ejemplo n.º 5
0
 /// <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())
     }));
 }
Ejemplo n.º 6
0
        /// <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));
        }
Ejemplo n.º 7
0
        /// <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);
        }
Ejemplo n.º 8
0
        /// <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);
        }
Ejemplo n.º 9
0
        /// <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));
        }
Ejemplo n.º 10
0
 /// <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())
     }));
 }
Ejemplo n.º 11
0
        /// <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));
        }
Ejemplo n.º 12
0
 /// <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));
 }
Ejemplo n.º 13
0
        /// <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);
        }
Ejemplo n.º 14
0
        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);
        }
Ejemplo n.º 15
0
        /// <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);
        }
Ejemplo n.º 18
0
 /// <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;
 }
Ejemplo n.º 19
0
 /// <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;
 }
Ejemplo n.º 20
0
        /// <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));
        }
Ejemplo n.º 21
0
        /// <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));
        }
Ejemplo n.º 22
0
        /// <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));
        }
Ejemplo n.º 23
0
        /// <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;
 }
Ejemplo n.º 25
0
 /// <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;
 }
Ejemplo n.º 26
0
        /// <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));
        }
Ejemplo n.º 27
0
        /// <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);
        }
Ejemplo n.º 28
0
        /// <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));
        }
Ejemplo n.º 29
0
 internal Command CreateEntityCommand(CommandType commandType, ComplexId id)
 {
     return(new Command(commandType, new BaseEntity(id)));
 }
Ejemplo n.º 30
0
        /// <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));
        }