-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#3981 - Model SDPR API #4018
Merged
Merged
#3981 - Model SDPR API #4018
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7a2cf8b
initial commit
andrepestana-aot 850a628
fixed import
andrepestana-aot 26c3525
Changed exception
andrepestana-aot 767e433
Added default http code
andrepestana-aot d62247a
review issues
andrepestana-aot 4988f70
added external swagger route
andrepestana-aot 79ae32a
added external swagger route
andrepestana-aot cb5c776
review issues
andrepestana-aot 550db69
changed auth to check an additional audience (sims-api-external) inst…
andrepestana-aot b1c5abf
added condition to authorize client
andrepestana-aot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
sources/packages/backend/apps/api/src/app.external.module.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { Module } from "@nestjs/common"; | ||
import { StudentExternalController } from "./route-controllers"; | ||
import { AuthModule } from "./auth/auth.module"; | ||
import { StudentService } from "@sims/integrations/services"; | ||
|
||
@Module({ | ||
imports: [AuthModule], | ||
controllers: [StudentExternalController], | ||
providers: [StudentService], | ||
}) | ||
export class AppExternalModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...es/packages/backend/apps/api/src/route-controllers/student/student.external.controller.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { | ||
Body, | ||
Controller, | ||
HttpCode, | ||
HttpStatus, | ||
NotFoundException, | ||
Post, | ||
} from "@nestjs/common"; | ||
import { ApiNotFoundResponse, ApiTags } from "@nestjs/swagger"; | ||
import { ClientTypeBaseRoute } from "../../types"; | ||
import { AuthorizedParties } from "../../auth/authorized-parties.enum"; | ||
import { | ||
AllowAuthorizedParty, | ||
RequiresUserAccount, | ||
} from "../../auth/decorators"; | ||
import BaseController from "../BaseController"; | ||
import { StudentService } from "@sims/integrations/services"; | ||
import { | ||
ExternalSearchStudentAPIInDTO, | ||
StudentDetailsAPIOutDTO, | ||
} from "./models/student.dto"; | ||
|
||
/** | ||
* Student controller for external client. | ||
*/ | ||
@RequiresUserAccount(false) | ||
@AllowAuthorizedParty(AuthorizedParties.external) | ||
andrewsignori-aot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@Controller("student") | ||
@ApiTags(`${ClientTypeBaseRoute.External}-student`) | ||
export class StudentExternalController extends BaseController { | ||
constructor(private readonly studentService: StudentService) { | ||
super(); | ||
} | ||
|
||
/** | ||
* Searches for student details. | ||
* This request method is POST to avoid passing sensitive data in the URL. | ||
* @param payload payload with SIN to retrieve the student details. | ||
* @returns student details. | ||
*/ | ||
@Post() | ||
@ApiNotFoundResponse({ description: "Student not found." }) | ||
andrewsignori-aot marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@HttpCode(HttpStatus.OK) | ||
async searchStudentDetails( | ||
@Body() payload: ExternalSearchStudentAPIInDTO, | ||
): Promise<StudentDetailsAPIOutDTO> { | ||
const student = await this.studentService.getStudentBySIN(payload.sin); | ||
if (!student) { | ||
throw new NotFoundException("Student not found."); | ||
} | ||
return { | ||
firstName: student.user.firstName, | ||
lastName: student.user.lastName, | ||
sin: student.sinValidation.sin, | ||
dateOfBirth: student.birthDate, | ||
address: { | ||
addressLine1: student.contactInfo.address.addressLine1, | ||
addressLine2: student.contactInfo.address.addressLine2, | ||
city: student.contactInfo.address.city, | ||
provinceState: student.contactInfo.address.provinceState, | ||
country: student.contactInfo.address.country, | ||
postalCode: student.contactInfo.address.postalCode, | ||
}, | ||
applicationNumbers: student.applications.map((a) => a.applicationNumber), | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Open for discussion but we can keep those services at the API scope at first.
We can create some specific services for the external module, but I am not sure if we should start creating them in the integrations lib directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@dheepak-aot can you please collaborate on this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with @andrewsignori-aot, current scope of the services that serve the external APIs can be in
API
scope.