Eric Ma - CZ2006 SkyForce
I will do the Introduction in the form of Q and A
FE and BE
-
Q: How the frontend connect to the backend?
-
A: Through RESTful API
RESTful API
-
Q: What is RESTful API?
-
A: (short answer) a form of API featuring V1.1 HTTP request including GET POST PUT DELETE
FE call BE
- Q: How the frontend call the backend?
- A: Through HTTP Request
HTTP Request
- Q: What is a HTTP Request?
- A: Include:
- Request Method
- Request URL
- Request Header
- Request Parameter
- Path Variable
- Request Body
About this doc
- Q: What this document will provide?
- A: HTTP Request for every function provided here.
Method: POST
URL: "http://localhost:9090/api/customer"
Request Header: None
Request Param: None
Path Variable: None
Request Body:
{
"firstName" : "<firstName>",
"lastName" : "<lastName>",
"gender" : "<MALE/FEMALE>",
"email": "<email>",
"password": "<password>",
"avatar": "<url>",
"dob" : "<date>",
"halaPreference": <true/false>,
"vegPreference": <true/false>,
"regionalPreference": "None"
}
Request Body Example:
{
"firstName" : "abcdefg",
"lastName" : "ABCDEFG",
"gender" : "FEMALE",
"email": "[email protected]",
"password": "Ma12345!",
"avatar": "https://www.greencointoken.com/assets/images/avatar.png",
"dob" : "2000-09-09",
"halaPreference": false,
"vegPreference": true,
"regionalPreference": "None"
}
Method: GET
URL: "http://localhost:9090/api/customer/signin"
Request Header: None
Request Param:
{
"email": "<customer's email>",
"password": "<customer's password>"
}
Path Variable: None
Request Body: None
Method: PUT
URL: "http://localhost:9090/api/customer"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"customerId": "<customerId>"
}
Path Variable: None
Request Body: { "firstName" : "", "lastName" : "", "gender" : "<MALE/FEMALE>", "email": "", "password": "", "avatar": "", "dob" : "", "halaPreference": <true/false>, "vegPreference": <true/false>, "regionalPreference": "None" }
Request Body Example: { "firstName" : "abcdefg", "lastName" : "ABCDEFG", "gender" : "FEMALE", "email": "[email protected]", "password": "Ma12345!", "avatar": "https://www.greencointoken.com/assets/images/avatar.png", "dob" : "2000-09-09", "halaPreference": false, "vegPreference": true, "regionalPreference": "None" }
Method: DELETE
URL: "http://localhost:9090/api/customer"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"customerId": "<customerId>"
}
Path Variable: None
Request Body: None
Method: POST
URL: "http://localhost:9090/api/vendor"
Request Header: None
Request Param: None
Path Variable: None
Request Body:
{
"firstName" : "<firstName>",
"lastName" : "<lastName>",
"gender" : "<MALE/FEMALE>",
"email": "<email>",
"password": "<password>",
"shops": []
}
Request Body Example:
{
"firstName" : "dcba",
"lastName" : "DCBA",
"gender" : "MALE",
"email": "[email protected]",
"password": "12qweASD!@#",
"shops": []
}
Method: GET
URL: "http://localhost:9090/api/vendor/signin"
Request Header: None
Request Param:
{
"email": "<customer's email>",
"password": "<customer's password>"
}
Path Variable: None
Request Body: None
Method: PUT
URL: "http://localhost:9090/api/vendor"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"vendorId": "<vendorId>"
}
Path Variable: None
Request Body:
{
"firstName" : "<firstName>",
"lastName" : "<lastName>",
"gender" : "<MALE/FEMALE>",
"email": "<email>",
"password": "<password>",
"shops": []
}
Request Body Example:
{
"firstName" : "dcba",
"lastName" : "DCBA",
"gender" : "MALE",
"email": "[email protected]",
"password": "12qweASD!@#",
"shops": []
}
Method: DELETE
URL: "http://localhost:9090/api/vendor"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"vendorId": "<vendorId>"
}
Path Variable: None
Request Body: None
Method: POSt
URL: "http://localhost:9090/api/vendor/shop"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"vendorId": "<vendorId>"
}
Path Variable: None
Request Body:
{
"name": "<shopName>",
"contactNumber": "<contactNumber>",
"contactEmail": "<contactEmail>",
"verified": <true/false>,
"category": "<category>",
"products": []
}
Request Body Example:
{
"name": "<KFC>",
"contactNumber": "12345678",
"contactEmail": "[email protected]",
"verified": true,
"category": "RESTAURANT",
"products": []
}
Method: DELETE
URL: "http://localhost:9090/api/vendor/shop"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"vendorId": "<vendorId>",
"shopId": "<shopId>"
}
Path Variable: None
Request Body: None
Method: GET
URL: "http://localhost:9090/api/shops"
Request Header: None
Request Param: None
Path Variable: None
Request Body: None
Method: GET
URL: "http://localhost:9090/api/shop"
Request Header: None
Request Param:
{
"shopId": "<shopId>"
}
Path Variable: None
Request Body: None
Method: PUT
URL: "http://localhost:9090/api/shop"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"shopId": "<shopId>"
}
Path Variable: None
Request Body:
{
"name": "<shopName>",
"contactNumber": "<contactNumber>",
"contactEmail": "<contactEmail>",
"verified": <true/false>,
"category": "<category>",
"products": []
}
Request Body Example:
{
"name": "<KFC>",
"contactNumber": "12345678",
"contactEmail": "[email protected]",
"verified": true,
"category": "RESTAURANT",
"products": []
}
Method: POST
URL: "http://localhost:9090/api/shop/product"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"shopId": "<shopId>"
}
Path Variable: None
Request Body:
{
"name": "<productName>",
"description": "<productDescription>",
"productImg": ["<imgUrl>", "<imgUrl>"]
}
Request Body Example:
{
"name": "Happy Meal",
"description": "Enjoy ur happy meal",
"productImg": ["https://www.eatthis.com/wp-content/uploads/2016/12/mcdonalds-fast-food-500x366.jpg", "https://www.eatthis.com/wp-content/uploads/2016/12/mcdonalds-fast-food-500x366.jpg"]
}
Method: DELETE
URL: "http://localhost:9090/api/shop/product"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"shopId": "<shopId>",
"productId": "<productId>"
}
Path Variable: None
Request Body: None
Method: POST
URL: "http://localhost:9090/api/customer/plan"
Request Header:
{
"Authorization" : "<user access token>"
}
Request Param:
{
"customerId": "<customerId>"
}
Path Variable: None
Request Body:
{
"name": "<planname>",
"date": "<date>",
"planItems": []
}
Request Body Example:
{
"name": "Today Plan",
"date": "2019-03-12",
"planItems": []
}
To be continued ...