-
Notifications
You must be signed in to change notification settings - Fork 8
Create travel api #639
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
Create travel api #639
Conversation
| } | ||
| }); | ||
| } | ||
| req.body.travelDetails.request = hacker.application.accommodation.travel; |
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.
return next()?
middlewares/travel.middleware.js
Outdated
| * @param {JSON} res | ||
| * @param {(err?)=>void} next | ||
| * @return {void} | ||
| * @description Load travel request from hacker application and add it to |
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.
Nit: add it to req.body.travelDetails
| const travelDetails = req.body.travelDetails; | ||
|
|
||
| const exists = await Services.Hacker.findByAccountId( | ||
| travelDetails.accountId |
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.
Need to change this to instead look for a travel record by accountID instead to ensure we don't make duplicate travel docs for same linked accs. The way it is now, it is just looking for a hacker associated to an accountID which is not what we want I think.
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.
True true
loreina
left a comment
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.
LGTM! functionality seems great
@MrHarshPatel if it's good on the technical side, ready to merge
| post: { | ||
| requestType: Constants.REQUEST_TYPES.POST, | ||
| uri: "/api/travel/" | ||
| }, |
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.
what is this post? Did you mean create travel?
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.
Yeah, it's for create - thought I was following the naming convention from account and hacker, would it be better to rename this from post to createTravel?
| function updatedTravel(req, res) { | ||
| return res.status(200).json({ | ||
| message: Constants.Success.TRAVEL_UPDATE, | ||
| data: req.body |
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.
Should this be json like the other portions or no?
| Error: require("../constants/error.constant") | ||
| }; | ||
|
|
||
| function okay(req, res) { |
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.
nit: okay sounds a bit odd as a function name
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.
Whoops, this function was just for debugging - I'll remove it
| function addDefaultStatusAndOffer(req, res, next) { | ||
| req.body.travelDetails.status = "None"; | ||
| req.body.travelDetails.offer = 0; | ||
| return next(); |
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.
Can this be added in parseTravel? or is this used for a specific purpose?
Tickets:
List of changes:
Create a travel model and api. Model is of form
Following api end points were also created:
/travel/:idgets a travel with a certain id/travel/selfgets travel associated with the logged in user/travel/email/:emailgets the travel associated with the user of a given email/travelcreates a new travel/travel/status/:idupdates the status field of a given traveler/travel/offer/:idupdates the amount of money we are offering a given travelerType of change
Please delete options that are not relevant.
How has this been tested?
Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration
Test Configuration:
Firmware version:
Hardware:
Toolchain:
SDK:
Questions for code reviewers?
Checklist: