lucidiot/HabitSharp
lucidiot
/
HabitSharp
Archived
1
0
Fork 0
This repository has been archived on 2022-08-04. You can view files and clone it, but cannot push or open issues or pull requests.
HabitSharp/Managers/NotificationManager.cs

44 lines
2.1 KiB
C#

using System;
using System.Linq;
using System.Collections.Generic;
using RestSharp;
using HabitSharp.Notifications;
namespace HabitSharp.Managers {
public class NotificationManager : Manager {
public NotificationManager(HabiticaApi client) : base(client) { }
public List<Notification> MarkAsRead(IEnumerable<Notification> notes) => this.MarkAsRead(notes.Select(note => note.Id));
public List<Notification> MarkAsRead(IEnumerable<Guid> ids) => this.MarkAsRead(ids.Select(id => id.ToString()));
public List<Notification> MarkAsRead(IEnumerable<string> ids) {
var req = new RestRequest("notifications/read", Method.POST);
req.AddParameter("notificationIds", ids);
return this.Client.Execute<List<Notification>>(req);
}
public List<Notification> MarkAsRead(Notification note) => this.MarkAsRead(note.Id);
public List<Notification> MarkAsRead(Guid id) => this.MarkAsRead(id.ToString());
public List<Notification> MarkAsRead(string id) {
var req = new RestRequest("notifications/{noteId}/read", Method.POST);
req.AddUrlSegment("noteId", id);
return this.Client.Execute<List<Notification>>(req);
}
public List<Notification> MarkAsSeen(IEnumerable<Notification> notes) => this.MarkAsSeen(notes.Select(note => note.Id));
public List<Notification> MarkAsSeen(IEnumerable<Guid> ids) => this.MarkAsSeen(ids.Select(id => id.ToString()));
public List<Notification> MarkAsSeen(IEnumerable<string> ids) {
var req = new RestRequest("notifications/see", Method.POST);
req.AddParameter("notificationIds", ids);
return this.Client.Execute<List<Notification>>(req);
}
public Notification MarkAsSeen(Notification note) => this.MarkAsSeen(note.Id);
public Notification MarkAsSeen(Guid id) => this.MarkAsSeen(id.ToString());
public Notification MarkAsSeen(String id) {
var req = new RestRequest("notifications/{noteId}/seen", Method.POST);
req.AddUrlSegment("noteId", id);
return this.Client.Execute<Notification>(req);
}
}
}