yangweichen / inspection_app

0 stars 0 forks source link

Submit Report Route #17

Open jakepeyser opened 7 years ago

jakepeyser commented 7 years ago

POST api/company/:companyId/trucks/:vin/reports with:

  1. Make sure logged in user has access to truck
  2. Verify all data matches up
  3. Persist responses
{
  vin: "12345678",
  responses: [
    {
      questionId: 123,
      response: false,
      comments: "this is an explanation of my response"
    }, {...}
  ]
}

Expected responses: 201: success - report persisted successfully 400: failure - request (question, user, truck, etc) invalid 401: unauthorized - user is not allowed to submit report for this truck

Response payload on successful submission:

{
  success: true,
  reportId: 123 // ID of newly created report
}
jakepeyser commented 7 years ago

@yangweichen updated API input data and expected successful response