-
Notifications
You must be signed in to change notification settings - Fork 9
#4076: created getGuestDefinition endpoint #4148
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
Changes from 1 commit
b022dee
c50f372
c353145
c2d1e74
9eb5c02
b5c7cfd
e4f9fcd
9ef1c1c
b97ce6e
adced8a
1abf4d4
147e524
1cc1ed2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import { Organization } from '@prisma/client'; | ||
| import { Guest_Definition, Organization } from '@prisma/client'; | ||
| import { isAdmin, User } from 'shared'; | ||
| import prisma from '../prisma/prisma.js'; | ||
| import { AccessDeniedAdminOnlyException, DeletedException, NotFoundException } from '../utils/errors.utils.js'; | ||
|
|
@@ -253,4 +253,28 @@ export default class RecruitmentServices { | |
|
|
||
| return definition; | ||
| } | ||
|
|
||
| /** | ||
| * Gets a single guest defenition with the given user, organization, and definition ids | ||
| * @param userCreatedId the id of guest to retrieve | ||
| * @param organizationId the organization the user is currently in | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. update doc string |
||
| * @param definitionId the id of the specific defenition being found | ||
| * @returns a definition | ||
| * @throws if the defenition is not found in the db | ||
| */ | ||
| static async getGuestDefinition( | ||
| userCreatedId: string, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You will not need to take in the user created id, that does not matter when requesting a guest definition, so you can delete that parameter |
||
| organizationId: string, | ||
| definitionId: string | ||
| ): Promise<Guest_Definition> { | ||
| const guest = await prisma.guest_Definition.findFirst({ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can instead be findUnique, since there will only be one definition with the given definitionId |
||
| where: { userCreatedId, organizationId, definitionId } | ||
| }); | ||
|
|
||
| if (!guest) { | ||
| throw new NotFoundException('User', userCreatedId); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should instead be NotFoundException('Guest Definition', definitionId) |
||
| } | ||
|
|
||
| return guest; | ||
| } | ||
| } | ||
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.
We will only be extracting the definitionId from the parameters. You can get the organizationId directly from the request with req.organization.organizationId