Proyek Akhir: OpenShop RESTful API
Setiap kriteria dapat bernilai 0 sampai 4 points (pts). Untuk lulus dari submission ini setidaknya Anda harus mendapatkan 2 points dari setiap kriteria. Submission akan ditolak jika masih terdapat kriteria dengan nilai 0 points.
RESTful API yang dibuat harus mampu menyimpan data dengan ketentuan sebagai berikut.
Method: POST
URL: /products
Body request:
{
"name": "string",
"sku": "string",
"description": "string",
"shop": "string",
"location": "string",
"price": "integer",
"discount": "integer",
"category": "string",
"stock": "integer",
"is_available": "boolean",
"picture": "string"
}
Body response:
{
"id": "590f5c38-e7cf-45c9-8b0a-0937f7de6fa4",
"name": "Kelas Belajar Python",
"shop": "Dicoding",
"price": 1500000,
"sku": "DCD01",
"description": "This is a sample description of the product.",
"location": "Bandung",
"discount": 0,
"category": "Course",
"stock": 1000,
"is_available": true,
"picture": "<https://www.shutterstock.com/image-vector/sample-red-square-grunge-stamp-260nw-338250266.jpg>",
"_links": [
{
"rel": "self",
"href": "/products",
"action": "POST",
"types": [
"application/json"
]
},
{
"rel": "self",
"href": "/products/590f5c38-e7cf-45c9-8b0a-0937f7de6fa4/",
"action": "GET",
"types": [
"application/json"
]
},
{
"rel": "self",
"href": "/products/590f5c38-e7cf-45c9-8b0a-0937f7de6fa4/",
"action": "PUT",
"types": [
"application/json"
]
},
{
"rel": "self",
"href": "/products/590f5c38-e7cf-45c9-8b0a-0937f7de6fa4/",
"action": "DELETE",
"types": [
"application/json"
]
}
]
}
Berikut adalah ketentuan kriteria 1.
RESTful API yang dibuat harus mampu menampilkan data dengan ketentuan sebagai berikut.
{
"products": [
{
"id": "590f5c38-e7cf-45c9-8b0a-0937f7de6fa4",
"name": "Kelas Belajar Python",
"shop": "Dicoding",
"price": 1500000,
"sku": "DCD01",
"description": "This is a sample description of the product.",
"location": "Bandung",
"discount": 0,
"category": "Course",
"stock": 1000,
"is_available": true,
"picture": "<https://www.shutterstock.com/image-vector/sample-red-square-grunge-stamp-260nw-338250266.jpg>",
"_links": [
{
"rel": "self",
"href": "<http://localhost:8000/products>",
"action": "POST",
"types": [
"application/json"
]
},
{
"rel": "self",
"href": "<http://localhost:8000/products/75ea4e94-65a1-4c84-b5ab-b15b3af9ffac/>",
"action": "GET",
"types": [
"application/json"
]
},
{
"rel": "self",
"href": "<http://localhost:8000/products/75ea4e94-65a1-4c84-b5ab-b15b3af9ffac/>",
"action": "PUT",
"types": [
"application/json"
]
},
{
"rel": "self",
"href": "<http://localhost:8000/products/75ea4e94-65a1-4c84-b5ab-b15b3af9ffac/>",
"action": "DELETE",
"types": [
"application/json"
]
}
]
}
]
}