File tree Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Expand file tree Collapse file tree 3 files changed +38
-1
lines changed Original file line number Diff line number Diff line change @@ -336,3 +336,11 @@ Selects a pupil to make subsequent requests for.
336
336
``` typescript
337
337
await client .selectPupil (123 );
338
338
```
339
+
340
+ ## ` .changePassword `
341
+
342
+ Changes the parent's password.
343
+
344
+ ``` typescript
345
+ await client .changePassword (" oldPassword" , " newPassword" );
346
+ ```
Original file line number Diff line number Diff line change 1
- import type { GetPupilsResponse } from "../types.ts" ;
1
+ import type { ChangePasswordResponse , GetPupilsResponse } from "../types.ts" ;
2
2
3
3
import { BaseClient } from "../core/baseClient.ts" ;
4
4
import { API_BASE_PARENT , BASE_URL } from "../utils/consts.ts" ;
@@ -88,4 +88,31 @@ export class ParentClient extends BaseClient {
88
88
}
89
89
throw new Error ( "No pupil with specified ID returned" ) ;
90
90
}
91
+ /**
92
+ * Changes the login password for the current parent account
93
+ * @param currentPassword Current password
94
+ * @param newPassword New password
95
+ * @returns Whether the request was successful
96
+ */
97
+ async changePassword (
98
+ currentPassword : string ,
99
+ newPassword : string ,
100
+ ) : Promise < ChangePasswordResponse > {
101
+ const formData = new URLSearchParams ( ) ;
102
+ formData . append ( "current" , currentPassword ) ;
103
+ formData . append ( "new" , newPassword ) ;
104
+ formData . append ( "repeat" , newPassword ) ;
105
+ return (
106
+ await this . makeAuthedRequest (
107
+ this . API_BASE + "/password" ,
108
+ {
109
+ method : "POST" ,
110
+ body : formData ,
111
+ headers : {
112
+ "Content-Type" : "application/x-www-form-urlencoded" ,
113
+ } ,
114
+ } ,
115
+ )
116
+ ) ;
117
+ }
91
118
}
Original file line number Diff line number Diff line change @@ -490,6 +490,8 @@ export interface PupilFieldsData {
490
490
491
491
export type PupilFieldsResponse = ClassChartsResponse < PupilFieldsData , [ ] > ;
492
492
493
+ export type ChangePasswordResponse = ClassChartsResponse < [ ] , [ ] > ;
494
+
493
495
export interface GetStudentCodeOptions {
494
496
/**
495
497
* Date of birth, in format YYYY-MM-DD
You can’t perform that action at this time.
0 commit comments