Skip to content
/ PickPerfect Public template
forked from H8-FSJS-P2S5/IP-BSD008

An app that provides personalized fruit recommendations based on users' nutritional needs and allows consultation through PickPerfect Chat for precise fruit selection.

Notifications You must be signed in to change notification settings

adaoho/PickPerfect

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 

Repository files navigation

Pick Perfect API Documentation

This document provides an overview of the API endpoints and their usage for our service,
that can be access on http://server.adaoho-project.my.id

1. Available endpoints for Public Site

2. Global Error

 

1. POST /user/register

Endpoint to create account user with default role "staff"

Request - Body

{
  "fullname": "string",
  "email": "string",
  "password": "string",
  "imageUrl": "string",
  "age": "integer",
  "address": "string",
  "phoneNumber": "string"
}
Click here for Response

Response (201 - Created)

{
  "newUser": {
    "id": 3,
    "fullname": "Adnan Nugroho",
    "email": "adnan@mail.com",
    "imageUrl": "https://source.unsplash.com/random/500x500/?person",
    "age": 25,
    "address": "South Tangerang"
  }
}

Response (400 - Bad Request)

{
  "message": "Email is required"
}
OR
{
  "message": "Invalid email format"
}
OR
{
  "message": "Email must be unique"
}
OR
{
  "message": "Full Name is required"
}
OR
{
  "message": "Password is required"
}

 

2. POST /user/login

Request - Body

{
  "email": "string",
  "password": "string"
}
Click here for Response

Response (200 - OK)

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiZW1haWwiOiJhZG5hbkBtYWlsLmNvbSIsImZ1bGxOYW1lIjoiQWRuYW4gTnVncm9obyIsInBob3RvIjoiaHR0cHM6Ly9zb3VyY2UudW5zcGxhc2guY29tL3JhbmRvbS81MDB4NTAwLz9wZXJzb24iLCJpYXQiOjE3MDAxNTg2NTl9.1T4jd_rWB5yK-QaQAMz65QZhE8V7Htbbv8yYOkWgyyc",
  "email": "adnan@mail.com",
  "fullname": "Adnan Nugroho",
  "photo": "https://source.unsplash.com/random/500x500/?person"
}

Response (400 - Bad Request)

{
  "message": "Email Can't be Empty"
}
OR
{
  "message": "Password Can't be Empty"
}

Response (401 - Unauthorized)

{
  "message": "Invalid email/password"
}

 

3. POST /user/google-login

Request - Body

{
  "token": "string"
}
Click here for Response

Response (200 - OK)

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiZW1haWwiOiJhZG5hbkBtYWlsLmNvbSIsImZ1bGxOYW1lIjoiQWRuYW4gTnVncm9obyIsInBob3RvIjoiaHR0cHM6Ly9zb3VyY2UudW5zcGxhc2guY29tL3JhbmRvbS81MDB4NTAwLz9wZXJzb24iLCJpYXQiOjE3MDAxNTg2NTl9.1T4jd_rWB5yK-QaQAMz65QZhE8V7Htbbv8yYOkWgyyc",
  "fullname": "Adnan Nugroho",
  "email": "adnan@mail.com",
  "photo": "https://source.unsplash.com/random/500x500/?person"
}

Response (401 - Unauthorized)

{
  "message": "Invalid email/password"
}

 

4. POST /user/github-login

Request - Body

{
  "fullname": "string",
  "email": "string",
  "password": "string",
  "imageUrl": "string"
}
Click here for Response

Response (200 - OK)

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiZW1haWwiOiJhZG5hbkBtYWlsLmNvbSIsImZ1bGxOYW1lIjoiQWRuYW4gTnVncm9obyIsInBob3RvIjoiaHR0cHM6Ly9zb3VyY2UudW5zcGxhc2guY29tL3JhbmRvbS81MDB4NTAwLz9wZXJzb24iLCJpYXQiOjE3MDAxNTg2NTl9.1T4jd_rWB5yK-QaQAMz65QZhE8V7Htbbv8yYOkWgyyc",
  "fullname": "Adnan Nugroho",
  "email": "adnan@mail.com",
  "photo": "https://source.unsplash.com/random/500x500/?person"
}

 

5. POST /user/facebook-login

Request - Body

{
  "fullname": "string",
  "email": "string",
  "password": "string",
  "imageUrl": "string"
}
Click here for Response

Response (200 - OK)

{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6MywiZW1haWwiOiJhZG5hbkBtYWlsLmNvbSIsImZ1bGxOYW1lIjoiQWRuYW4gTnVncm9obyIsInBob3RvIjoiaHR0cHM6Ly9zb3VyY2UudW5zcGxhc2guY29tL3JhbmRvbS81MDB4NTAwLz9wZXJzb24iLCJpYXQiOjE3MDAxNTg2NTl9.1T4jd_rWB5yK-QaQAMz65QZhE8V7Htbbv8yYOkWgyyc",
  "fullname": "Adnan Nugroho",
  "email": "adnan@mail.com",
  "photo": "https://source.unsplash.com/random/500x500/?person"
}

 

6. GET /fruit/

Request - Body

{
  "name": "string",
  "description": "string",
  "price": "integer",
  "imgUrl": "string",
  "categoryId": "integer"
}

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (201 - Created)

{
  "getFruit": [
    {
      "id": 1,
      "name": "Persimmon",
      "family": "Ebenaceae",
      "calories": "81",
      "fat": "0",
      "sugar": "18",
      "carbohydrates": "18",
      "protein": "0",
      "imageUrl": "https://source.unsplash.com/random/900x700/?Persimmon",
      "MovementId": 1
    },
    ...
  ]
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

 

7. GET /fruit/fetchfruit

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (200 - OK)

{
  "message": "Fetching data from FruityViceAPI Success"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

 

8. GET /fruitmov/

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (200 - OK)

{
  "findCuisine": {
    "id": 1,
    "name": "Sloppy Joes",
    "description": "This beats canned or ...",
    "price": 12000,
    "imgUrl": "https://img.sndimg.com/...",
    "categoryId": 1,
    "authorId": 1,
    "createdAt": "2023-10-30T20:25:08.875Z",
    "updatedAt": "2023-10-30T20:25:08.875Z"
  }
}

Response (400 - Bad Request)

{
  "message": "User didn't have any Data"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

 

9. POST /fruitmov/:MovementId

Request - Params

{
  "MovementId": "<integer>"
}

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (200 - OK)

{
  "message": "Add Movement <movement name> to User Success"
}

Response (400 - Bad Request)

{
  "message": "Data Movement Already Being Input"
}
OR
{
  "message": "Data Movement Already Being Deleted"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

Response (404 - Not Found)

{
  "message": "Error Data Not Found"
}

 

10. PATCH /user/:id

Request - File

{
  "imageUrl": "<file>"
}

Request - Params

{
  "id": "integer (required)"
}

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (200 - OK)

{
  "message": "Image <entitiy_name> success to update"
}

Response (400 - Bad Request)

{
  "message": "ImageURL can't be Empty"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

Response (403 - Forbidden)

{
  "message": "You're Not Authorized"
}

Response (404 - Not Found)

{
  "message": "Error Data Not Found"
}

 

11. GET /purchase/

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (200 - OK)

{
  "message": "Sloppy White success to delete"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

Response (403 - Forbidden)

{
  "message": "You're Not Authorized"
}

Response (404 - Not Found)

{
  "message": "Error Data Not Found"
}

 

12. POST /purchase/:id

Request - Body

{
  "name": "string",
  "quantity": "integer",
  "price": "integer",
  "total": "integer"
}

Request - Params

{
  "id": "<integer>"
}

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (201 - OK)

{
  "addPurchase": {
    "id": 6,
    "name": "Indonesian",
    "updatedAt": "2023-10-31T03:41:06.960Z",
    "createdAt": "2023-10-31T03:41:06.960Z"
  }
}

Response (400 - Bad Request)

{
  "message": "Name can't be Empty"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

 

13. DELETE /purchase/:id

Request - Params

{
  "id": "<integer>"
}

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (200 - OK)

{
  "updatedCategory": {
    "id": 1,
    "name": "Waffle Cone",
    "createdAt": "2023-10-30T20:24:52.246Z",
    "updatedAt": "2023-10-31T03:59:02.802Z"
  }
}

Response (400 - Bad Request)

{
  "message": "Name can't be Empty"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

Response (403 - Forbidden)

{
  "message": "You're Not Authorized"
}

Response (404 - Not Found)

{
  "message": "Error Data Not Found"
}

 

14. PATCH /purchase/:id

Request - Params

{
  "id": "<integer>"
}

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (200 - OK)

{
  "message": "Italian success to delete"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

Response (403 - Forbidden)

{
  "message": "You're Not Authorized"
}

Response (404 - Not Found)

{
  "message": "Error Data Not Found"
}

 

15. GET /movement/

Request - Params

{
  "id": "<integer>"
}

Request - Headers - Authorization (Bearer Scheme)

Authorization: Bearer <access_token>
Click here for Response

Response (200 - OK)

{
  "message": "Italian success to delete"
}

Response (401 - Unauthorized)

{
  "message": "You're Not Authenticated"
}

Response (403 - Forbidden)

{
  "message": "You're Not Authorized"
}

Response (404 - Not Found)

{
  "message": "Error Data Not Found"
}

 

Global Error

Response (401 - Unauthorized)

{
  "message": "Invalid Token"
}

Response (500 - Internal Server Error)

{
  "message": "Internal server error"
}

About

An app that provides personalized fruit recommendations based on users' nutritional needs and allows consultation through PickPerfect Chat for precise fruit selection.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 99.3%
  • Other 0.7%