Пример #1
0
        /// <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());
        }
Пример #2
0
 /// <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 }
     }));
 }
Пример #3
0
        /// <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());
        }
Пример #4
0
        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);
        }
Пример #5
0
        /// <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));
        }
Пример #6
0
        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));
        }
Пример #7
0
        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);
        }
Пример #8
0
 public Task <RecipientResponse> GetAllRecipientsAsync()
 {
     return(WAPI.GetAsync <RecipientResponse>(_session, _role.Slug + "/messages/recipients"));
 }
Пример #9
0
 /// <summary>
 /// Lists all the news stories available.
 /// </summary>
 public Task <IEnumerable <NewsRecord> > GetStoriesAsync()
 {
     return(WAPI.GetAsync <IEnumerable <NewsRecord> >(_session, _role.Slug + "/news/index_json"));
 }
Пример #10
0
        private async Task <string> GetSessionIdAsync()
        {
            var response = await WAPI.GetAsync <IndexResponse>(_context, "/index_json").ConfigureAwait(false);

            return(response.SessionID);
        }
Пример #11
0
        public async Task <bool> LogoutAsync(WilmaSession session)
        {
            using var response = await WAPI.PostAsync(session, "/logout").ConfigureAwait(false);

            return(response.IsSuccessStatusCode);
        }
Пример #12
0
 public Task <IEnumerable <Group> > GetFutureGroupsAsync()
 => WAPI.GetAsync <IEnumerable <Group> >(_session, _role.Slug + "/groups/index_json/future");
Пример #13
0
 public Task <IEnumerable <Group> > GetPastGroupsAsync()
 => WAPI.GetAsync <IEnumerable <Group> >(_session, _role.Slug + "/groups/index_json/past");
Пример #14
0
 public Task MarkAsSeenAsync()
 => WAPI.PostAsync(_session, _role.Slug + "/exams/seen");
Пример #15
0
 public Task <IEnumerable <Exam> > GetExamsAsync()
 => WAPI.GetAsync <IEnumerable <Exam> >(_session, _role.Slug + "/exams/index_json");