Ejemplo n.º 1
0
        /// <summary>
        /// Gets the current user info.
        /// </summary>
        /// <param name="notificationType">Type of the notification.</param>
        /// <param name="service">The service.</param>
        /// <param name="notify">The notify.</param>
        /// <returns>The current user info.</returns>
        /// <exception cref="HttpRequestException">API exception.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="notificationType" /> or <paramref name="service" /> is <see langword="null" /></exception>
        public async Task <NotificationSettings> UpdateNotificationSettingsAsync(
            NotificationType notificationType,
            NotificationService service,
            bool notify)
        {
            if (notificationType == null)
            {
                throw new ArgumentNullException(nameof(notificationType));
            }

            if (service == null)
            {
                throw new ArgumentNullException(nameof(service));
            }

            var parameters = new LinkedList <KeyValuePair <string, string> >();

            parameters.AddLast(new KeyValuePair <string, string>("notification_type", notificationType.Value));
            parameters.AddLast(new KeyValuePair <string, string>("service", service.Value));
            parameters.AddLast(new KeyValuePair <string, string>("dont_notify", notify ? "1" : "0"));

            return
                (await
                 TodoistClient.PostAsync <NotificationSettings>("notification_settings/update", parameters)
                 .ConfigureAwait(false));
        }
Ejemplo n.º 2
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.º 3
0
 /// <summary>
 /// Gets archived projects.
 /// </summary>
 /// <returns>
 /// The archived projects.
 /// </returns>
 /// <exception cref="HttpRequestException">API exception.</exception>
 public async Task <IEnumerable <Project> > GetArchivedAsync()
 {
     return
         (await
          TodoistClient.PostAsync <IEnumerable <Project> >(
              "projects/get_archived",
              new List <KeyValuePair <string, string> >()).ConfigureAwait(false));
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Gets all the user’s completed items (tasks).
        /// </summary>
        /// <param name="filter">The filter.</param>
        /// <returns>The completed items.</returns>
        /// <exception cref="HttpRequestException">API exception.</exception>
        /// <remarks>Only available for Todoist Premium users.</remarks>
        public async Task <CompletedItemsInfo> GetCompletedAsync(ItemFilter filter = null)
        {
            var parameters = filter == null ? new List <KeyValuePair <string, string> >() : filter.ToParameters();

            return
                (await
                 TodoistClient.PostAsync <CompletedItemsInfo>("completed/get_all", 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>
        /// Add a task. Implementation of the Quick Add Task available in the official clients.
        /// </summary>
        /// <param name="quickAddItem">The quick add item.</param>
        /// <returns>The created task.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="quickAddItem"/> is <see langword="null"/></exception>
        /// <exception cref="HttpRequestException">API exception.</exception>
        public Task <Item> QuickAddAsync(QuickAddItem quickAddItem)
        {
            if (quickAddItem == null)
            {
                throw new ArgumentNullException(nameof(quickAddItem));
            }

            return(TodoistClient.PostAsync <Item>("quick/add", quickAddItem.ToParameters()));
        }
Ejemplo n.º 7
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.º 8
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.º 9
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.º 10
0
 /// <summary>
 /// Gets archived projects.
 /// </summary>
 /// <returns>
 /// The archived projects.
 /// </returns>
 /// <exception cref="HttpRequestException">API exception.</exception>
 public Task <IEnumerable <Project> > GetArchivedAsync()
 {
     return(TodoistClient.PostAsync <IEnumerable <Project> >(
                "projects/get_archived",
                new List <KeyValuePair <string, string> >()));
 }