Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

URL for test server: https://mobile-test.diaper-project.

cf

com:5001

URL for prod server: https://mobile-prod.diaper-project.

cf

com:5001Note:

Notes:

The API key is jus the API key.

...

URL/api/users
DescriptionCreate a new user
MethodPUT
Content-typeapplication/json
Url Param---
Request Body Data
{
email: xxx,
firstName: xxx,
lastName: xxx,
surveyData: xxx
}
Response


Response BodyCode

{

message: "Password set email has been sent."

}

200

{

message: "Malformatted JSON"

}

400

{

message: "There was a problem sending the password set email. Please try again later."

}

500

{

message: "User already exists!"

}

500


Cookie---


User Authentication APIs

...

URL/api/auth
DescriptionUser login
MethodPOST
Content-typeapplication/json
Url Param--
Request Body Data
{
email: xxx,
password: xxx,
firstName: xxx,
lastName: xxx
}
Response


Response BodyCode

{

loginResponseType: “loginResponseTypeSuccess”,

message: "User successfully authenticated.",

accessToken: xxx,

email: xxx,

firstName: xxx,

lastName: xxx

}

201

{

loginResponseType: "loginResponseTypeInvalidPassword",

message: "Failed login",

displayMessage: "Incorrect email or password."

}

401

{

message: "There was a problem sending the password set email. Please try again later"

}

500

{

loginResponseType: "loginResponseTypePasswordNotSet",

message: "User password has not been set.",

displayMessage: "Please check your email for a link to set your account password."

}



Cookie

---



URL/api/users/<email>/resetpassword
DescriptionReset password with given new password
MethodPOST
Url Paramemail: email for the user to reset password
Request Body Data
{
password: xxx
}

Note: password field takes the new password to be reset, not the old password.
Response


Response BodyCode

{

message: "Successfully updated password"

}

200

{

message: "Invalid email address provided"

}

400

{

message: "Unauthorized: you do not have access to reset this user's password"

}

401


Cookie---



URL/api/users/<email>/requestpasswordreset
DescriptionSend password reset email
MethodPOST
Url Paramemail: email for the user to reset password
Request Body Data---
Response


Response BodyCode

{

message: "Password reset email has been sent."

}

200

{

message: "Invalid email address provided"

}

400

{

message: "There was a problem sending the password reset email. Please try again later"

}

500


Cookie---



URL/api/logout
DescriptionLog out user by deleting the user's access token
MethodDELETE
Url Param---
Request Body Data---
Response


Response BodyCode

{

message: "Successfully logged out"

}

200


Cookie---


Sample APIs

URL /api/samples/
Description

GET: Fetching all samples created from a user

PUT: Inserting a new sample [Poop Sample Response]

HeaderAPI_KEY, Authorization
Content-typemultipart/form-data
MethodPUT | GET
Url Param

--

Request Body Data

GET

---

PUT
{

sampleData: {

sampleBarcodeID: xxx,

milkBarcodeID:xxx,

surveyData: {...} 

},

image: xxx

}

Note: SampleData should send as form-data text, and the image should be form-data file.

Response

PUT

  • { message: “Sample data recorded!” } - 200: Success
  • { message: "Bad request: no image or sample data" } - 400
  • { message: "Bad request: no sample data"} - 401
  • { message: "Bad request: no barcode ID"} - 402
  • { message: "Bad request: no survey data"} - 403


GET
{ sampleList:
[

{

id: barcode id,

milk_id: milk id,

dateTime: timestamp,

surveyData: {},

readableSurveyData: {}, 

image_url: url of sample image,

email: xxx@gmail.com

},

{

...

},]

}
200: Success

...