@@ -35,8 +35,8 @@ public MessageClient(WebUntisClient client)
3535 /// </summary>
3636 /// <param name="ct">Cancellation token</param>
3737 /// <returns>The count of unread messages</returns>
38- /// <exception cref="ObjectDisposedException">Thrown when the instance was disposed</exception>
39- /// <exception cref="UnauthorizedAccessException">Thrown when you're logged in</exception>
38+ /// <exception cref="ObjectDisposedException">Thrown when the client instance was disposed</exception>
39+ /// <exception cref="UnauthorizedAccessException">Thrown when the client aren't logged in</exception>
4040 /// <exception cref="HttpRequestException">Thrown when an error happened while the http request</exception>
4141 public async Task < int > GetUnreadMessagesCountAsync ( CancellationToken ct = default )
4242 {
@@ -49,8 +49,8 @@ public async Task<int> GetUnreadMessagesCountAsync(CancellationToken ct = defaul
4949 /// </summary>
5050 /// <param name="ct">Cancllation token</param>
5151 /// <returns></returns>
52- /// <exception cref="ObjectDisposedException">Thrown when the instance was disposed</exception>
53- /// <exception cref="UnauthorizedAccessException">Thrown when you're logged in</exception>
52+ /// <exception cref="ObjectDisposedException">Thrown when the client instance was disposed</exception>
53+ /// <exception cref="UnauthorizedAccessException">Thrown when the client aren't logged in</exception>
5454 /// <exception cref="HttpRequestException">Thrown when an error happened while the http request</exception>
5555 public async Task < MessagePermissions > GetMessagePermissionsAsync ( CancellationToken ct = default )
5656 {
@@ -63,8 +63,8 @@ public async Task<MessagePermissions> GetMessagePermissionsAsync(CancellationTok
6363 /// </summary>
6464 /// <param name="ct">Cancellation token</param>
6565 /// <returns>The message previews</returns>
66- /// <exception cref="ObjectDisposedException">Thrown when the instance was disposed</exception>
67- /// <exception cref="UnauthorizedAccessException">Thrown when you're logged in</exception>
66+ /// <exception cref="ObjectDisposedException">Thrown when the client instance was disposed</exception>
67+ /// <exception cref="UnauthorizedAccessException">Thrown when the client aren't logged in</exception>
6868 /// <exception cref="HttpRequestException">Thrown when an error happened while the http request</exception>
6969 public async Task < MessagePreview [ ] > GetMessageInboxAsync ( CancellationToken ct = default )
7070 {
@@ -73,5 +73,25 @@ public async Task<MessagePreview[]> GetMessageInboxAsync(CancellationToken ct =
7373 JArray jsonMsg = JObject . Parse ( responseString ) . Value < JArray > ( "incomingMessages" ) ;
7474 return new JsonSerializer ( ) . Deserialize < List < MessagePreview > > ( jsonMsg . CreateReader ( ) ) . ToArray ( ) ;
7575 }
76+
77+ /// <summary>
78+ /// Get all available reception people
79+ /// </summary>
80+ /// <param name="ct">Cancellation token</param>
81+ /// <returns>The people (<see cref="KeyValuePair{TKey, TValue}.Key"/> is the type of people that are contained in <see cref="KeyValuePair{TKey, TValue}.Value"/>)</returns>
82+ /// <exception cref="ObjectDisposedException">Thrown when the client instance was disposed</exception>
83+ /// <exception cref="UnauthorizedAccessException">Thrown when the client aren't logged in</exception>
84+ /// <exception cref="HttpRequestException">Thrown when an error happened while the http request</exception>
85+ public async Task < KeyValuePair < string , MessagePerson [ ] > [ ] > GetMessagePeopleAsync ( CancellationToken ct = default )
86+ {
87+ string responseString = await _client . MakeAPIGetRequestAsync ( "/WebUntis/api/rest/view/v1/messages/recipients/static/persons" , ct ) ;
88+
89+ List < KeyValuePair < string , MessagePerson [ ] > > personTypes = new List < KeyValuePair < string , MessagePerson [ ] > > ( ) ;
90+ JArray types = JArray . Parse ( responseString ) ;
91+ foreach ( JObject personType in types . Cast < JObject > ( ) )
92+ personTypes . Add ( new KeyValuePair < string , MessagePerson [ ] > ( personType . Value < string > ( "type" ) ,
93+ new JsonSerializer ( ) . Deserialize < List < MessagePerson > > ( personType . Value < JArray > ( "persons" ) . CreateReader ( ) ) . ToArray ( ) ) ) ;
94+ return personTypes . ToArray ( ) ;
95+ }
7696 }
7797}
0 commit comments