@@ -20,6 +20,7 @@ import {
20
20
StudentProfileAPIOutDTO ,
21
21
StudentFileDetailsAPIOutDTO ,
22
22
StudentUploadFileAPIOutDTO ,
23
+ InstitutionStudentProfileAPIOutDTO ,
23
24
} from "./models/student.dto" ;
24
25
import { transformAddressDetailsForAddressBlockForm } from "../utils/address-utils" ;
25
26
@@ -113,14 +114,36 @@ export class StudentControllerService {
113
114
* @param studentId student id to retrieve the data.
114
115
* @returns student profile details.
115
116
*/
116
- async getStudentProfile ( studentId : number ) : Promise < StudentProfileAPIOutDTO > {
117
+ async getStudentProfile ( studentId : number ) : Promise < StudentProfileAPIOutDTO > ;
118
+ /**
119
+ * Get the student information that represents the profile.
120
+ * @param studentId student id to retrieve the data.
121
+ * @param options options:
122
+ * - `withSensitiveData` boolean option to return sensitive data such as SIN.
123
+ * @returns student profile details.
124
+ */
125
+ async getStudentProfile (
126
+ studentId : number ,
127
+ options : { withSensitiveData : true } ,
128
+ ) : Promise < InstitutionStudentProfileAPIOutDTO > ;
129
+ /**
130
+ * Get the student information that represents the profile.
131
+ * @param studentId student id to retrieve the data.
132
+ * @param options options:
133
+ * - `withSensitiveData` boolean option to return sensitive data such as SIN.
134
+ * @returns student profile details.
135
+ */
136
+ async getStudentProfile (
137
+ studentId : number ,
138
+ options ?: { withSensitiveData : true } ,
139
+ ) : Promise < StudentProfileAPIOutDTO | InstitutionStudentProfileAPIOutDTO > {
117
140
const student = await this . studentService . getStudentById ( studentId ) ;
118
141
if ( ! student ) {
119
142
throw new NotFoundException ( "Student not found." ) ;
120
143
}
121
144
122
145
const address = student . contactInfo . address ?? ( { } as AddressInfo ) ;
123
- return {
146
+ const studentProfile = {
124
147
firstName : student . user . firstName ,
125
148
lastName : student . user . lastName ,
126
149
fullName : getUserFullName ( student . user ) ,
@@ -133,8 +156,12 @@ export class StudentControllerService {
133
156
} ,
134
157
disabilityStatus : student . disabilityStatus ,
135
158
validSin : student . sinValidation . isValidSIN ,
136
- sin : student . sinValidation . sin ,
137
159
} ;
160
+
161
+ if ( options ?. withSensitiveData ) {
162
+ return { ...studentProfile , sin : student . sinValidation . sin } ;
163
+ }
164
+ return studentProfile ;
138
165
}
139
166
140
167
/**
0 commit comments