/// <summary> /// Returns the news story with its content. /// </summary> /// <param name="newsId">The unique id of the news.</param> public async Task <News> GetStoryContentAsync(int newsId) { var news = await WAPI.GetAsync <IEnumerable <News> >(_session, _role.Slug + "/news/index_json/" + newsId).ConfigureAwait(false); return(news.First()); }
/// <summary> /// Reply to a message which has the collated replies allowed. /// </summary> /// <param name="messageId">The identifier of the message which the reply is meant for.</param> /// <param name="bodyText">The reply message body.</param> public Task <HttpResponseMessage> ReplyAsync(int messageId, string bodyText) { return(WAPI.PostAsync(_session, _role.Slug + "/messages/collatedreply/" + messageId, parameters: new Dictionary <string, string> { { "BodyText", bodyText } })); }
/// <summary> /// Retrieves the message contents by the unique message identifier. /// </summary> /// <param name="messageId">The message identifier.</param> /// <returns>The message contents.</returns> public async Task <Message> GetMessageContentAsync(int messageId) { var messages = await WAPI.GetAsync <IEnumerable <Message> >(_session, _role.Slug + "/messages/" + messageId).ConfigureAwait(false); return(messages.First()); }
public async Task <WilmaSession?> LoginAsync(string username, string password) { string sessionId = await GetSessionIdAsync().ConfigureAwait(false); string apiKey = "sha1:" + Utils.DeriveSHA1Digest($"{username}|{sessionId}|{_context.Key}"); var parameters = new Dictionary <string, string> { { "Login", username }, { "Password", password }, { "SESSIONID", sessionId }, { "ApiKey", apiKey }, { "CompleteJson", string.Empty }, { "format", "json" } }; var response = await WAPI.PostAsync <IndexResponse>(_context, "/login", parameters).ConfigureAwait(false); if (response.LoginResult == LoginResult.Ok) { return(new WilmaSession(_context, response)); } return(null); }
/// <summary> /// Retrieves all the messages from the specified folder. /// </summary> /// <param name="folder">The folder to retrieve messages from, by default <see cref="MessageFolder.Inbox"/>.</param> /// <returns>The message records.</returns> public Task <IEnumerable <MessageRecord> > GetMessagesAsync(MessageFolder folder = MessageFolder.Inbox) { string path = "/messages/index_json"; if (folder != MessageFolder.Inbox) { path += $"/{folder}"; } return(WAPI.GetAsync <IEnumerable <MessageRecord> >(_session, _role.Slug + path)); }
public Task <IEnumerable <Observation> > GetLessonNotesAsync(DateTime?date = default) { string path = "/attendance/index_json"; if (date is not null) { path += "?date={date:d.M.yyyy}"; } return(WAPI.GetAsync <IEnumerable <Observation> >(_session, _role.Slug + path)); }
public async Task <bool> ForgotPasswordAsync(string email, string username = "") { var parameters = new Dictionary <string, string> { { "username", username }, { "email", email } }; using var response = await WAPI.PostAsync(_context, "/forgotpasswd", parameters).ConfigureAwait(false); return(response.IsSuccessStatusCode); }
public Task <RecipientResponse> GetAllRecipientsAsync() { return(WAPI.GetAsync <RecipientResponse>(_session, _role.Slug + "/messages/recipients")); }
/// <summary> /// Lists all the news stories available. /// </summary> public Task <IEnumerable <NewsRecord> > GetStoriesAsync() { return(WAPI.GetAsync <IEnumerable <NewsRecord> >(_session, _role.Slug + "/news/index_json")); }
private async Task <string> GetSessionIdAsync() { var response = await WAPI.GetAsync <IndexResponse>(_context, "/index_json").ConfigureAwait(false); return(response.SessionID); }
public async Task <bool> LogoutAsync(WilmaSession session) { using var response = await WAPI.PostAsync(session, "/logout").ConfigureAwait(false); return(response.IsSuccessStatusCode); }
public Task <IEnumerable <Group> > GetFutureGroupsAsync() => WAPI.GetAsync <IEnumerable <Group> >(_session, _role.Slug + "/groups/index_json/future");
public Task <IEnumerable <Group> > GetPastGroupsAsync() => WAPI.GetAsync <IEnumerable <Group> >(_session, _role.Slug + "/groups/index_json/past");
public Task MarkAsSeenAsync() => WAPI.PostAsync(_session, _role.Slug + "/exams/seen");
public Task <IEnumerable <Exam> > GetExamsAsync() => WAPI.GetAsync <IEnumerable <Exam> >(_session, _role.Slug + "/exams/index_json");