@@ -220,92 +220,5 @@ public async Task<GeneralAccount> GetGenerallyAccountInformationAsync(Cancellati
220220 string responseString = await MakeAPIGetRequestAsync ( "/WebUntis/api/profile/general" , ct ) ;
221221 return GeneralAccount . ReadFromJson ( JObject . Parse ( responseString ) [ "data" ] . CreateReader ( ) ) ;
222222 }
223-
224- /// <summary>
225- /// Update the general account information
226- /// </summary>
227- /// <remarks>
228- /// When a value shouldn't change then must you set the current value
229- /// </remarks>
230- /// <param name="email"><see cref="GeneralAccount.Email"/></param>
231- /// <param name="forwardMessageToEmail"><see cref="GeneralAccount.ForwardMessageToMail"/></param>
232- /// <param name="itemsOnStartPage"><see cref="GeneralAccount.ItemsOnStartPage"/></param>
233- /// <param name="languageCode"><see cref="GeneralAccount.LanguageCode"/></param>
234- /// <param name="showLessonOfDay"><see cref="GeneralAccount.ShowLessonsOfDay"/></param>
235- /// <param name="showNextDayPeriods"><see cref="GeneralAccount.ShowNextDayPeriods"/></param>
236- /// <param name="userTaskNotifications"><see cref="GeneralAccount.UserTaskNotifications"/></param>
237- /// <param name="ct">Cancellation token</param>
238- /// <returns>Was the update successful</returns>
239- public async Task < bool > UpdateGenerallyAccountInformationAsync ( string email , bool forwardMessageToEmail , int itemsOnStartPage , string languageCode , bool showLessonOfDay , bool showNextDayPeriods , bool userTaskNotifications , CancellationToken ct = default )
240- {
241- // Check for disposing
242- if ( _disposedValue )
243- throw new ObjectDisposedException ( GetType ( ) . FullName ) ;
244-
245- // Check if you logged in
246- if ( ! LoggedIn )
247- throw new UnauthorizedAccessException ( "You're not logged in" ) ;
248-
249- // Write request
250- StringWriter sw = new StringWriter ( ) ;
251- using ( JsonWriter writer = new JsonTextWriter ( sw ) )
252- {
253- writer . WriteStartObject ( ) ;
254-
255- writer . WritePropertyName ( "email" ) ;
256- writer . WriteValue ( email ) ;
257-
258- writer . WritePropertyName ( "forwardMessageToEmail" ) ;
259- writer . WriteValue ( forwardMessageToEmail ) ;
260-
261- writer . WritePropertyName ( "itemOnStartPage" ) ;
262- writer . WriteValue ( itemsOnStartPage ) ;
263-
264- writer . WritePropertyName ( "languageCode" ) ;
265- writer . WriteValue ( languageCode ) ;
266-
267- writer . WritePropertyName ( "showLessonsOfDay" ) ;
268- writer . WriteValue ( showLessonOfDay ) ;
269-
270- writer . WritePropertyName ( "showNextDayPeriods" ) ;
271- writer . WriteValue ( showNextDayPeriods ) ;
272-
273- writer . WritePropertyName ( "userTaskNotifications" ) ;
274- writer . WriteValue ( userTaskNotifications ) ;
275-
276- writer . WriteEndObject ( ) ;
277- }
278-
279- HttpRequestMessage request = new HttpRequestMessage ( )
280- {
281- Method = HttpMethod . Post ,
282- RequestUri = new Uri ( ServerUrl + "/WebUntis/api/profile/general" ) ,
283- Content = new StringContent ( sw . ToString ( ) )
284- } ;
285-
286- request . Headers . Add ( "JSESSIONID" , _sessionId ) ;
287- request . Headers . Add ( "schoolname" , _schoolName ) ;
288- request . Headers . Authorization = new AuthenticationHeaderValue ( "Bearer" , _bearerToken ) ;
289-
290- HttpResponseMessage response = await _client . SendAsync ( request , ct ) ;
291-
292- // Check cancellation token
293- if ( ct . IsCancellationRequested )
294- return false ;
295-
296- // Verify response
297- if ( response . StatusCode == HttpStatusCode . Unauthorized || response . StatusCode == HttpStatusCode . Forbidden )
298- {
299- _ = LogoutAsync ( ) ;
300- throw new UnauthorizedAccessException ( "You're not logged in" ) ;
301- }
302-
303- if ( response . StatusCode != HttpStatusCode . OK )
304- throw new HttpRequestException ( $ "There was an error while the http request (Code: { response . StatusCode } ).") ;
305-
306- string responseString = await response . Content . ReadAsStringAsync ( ) ;
307- JObject responseObject = JObject . Parse ( responseString ) ;
308- return responseObject [ "data" ] [ "success" ] . Value < bool > ( ) ;
309- }
310223 }
311224}
0 commit comments