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.
336336``` typescript
337337await client .selectPupil (123 );
338338```
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" ;
22
33import { BaseClient } from "../core/baseClient.ts" ;
44import { API_BASE_PARENT , BASE_URL } from "../utils/consts.ts" ;
@@ -88,4 +88,31 @@ export class ParentClient extends BaseClient {
8888 }
8989 throw new Error ( "No pupil with specified ID returned" ) ;
9090 }
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+ }
91118}
Original file line number Diff line number Diff line change @@ -490,6 +490,8 @@ export interface PupilFieldsData {
490490
491491export type PupilFieldsResponse = ClassChartsResponse < PupilFieldsData , [ ] > ;
492492
493+ export type ChangePasswordResponse = ClassChartsResponse < [ ] , [ ] > ;
494+
493495export interface GetStudentCodeOptions {
494496 /**
495497 * Date of birth, in format YYYY-MM-DD
You can’t perform that action at this time.
0 commit comments