Chuyển tới nội dung chính

San pham

Quan ly danh muc san pham voi thong tin gia ban va gia mua.

Tham chieu nhanh

EndpointMethodMo ta
/api/v1/productsPOSTTao san pham moi
/api/v1/productsGETLay danh sach tat ca san pham
/api/v1/products/:idGETLay thong tin san pham cu the
/api/v1/products/:idPUTCap nhat san pham
/api/v1/products/:idDELETEXoa san pham

Cac endpoint API

Tao san pham

Tao san pham moi voi thong tin gia ban va gia mua.

POST /api/v1/products
curl -X POST 'https://api.finan.one/open/api/v1/products' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999' \
-d '{
"general_info": {
"item_name": "Example Product",
"sku_code": "SKU12345",
"unit": "pcs",
"description": "This is a sample product."
},
"sale_info": {
"sale_price": 100000,
"sale_category_code": "C1001",
"sale_tax_code": "TAX_CODE_10"
},
"purchase_info": {
"purchase_price": 80000,
"purchase_category_code": "D1001",
"purchase_tax_code": "TAX_CODE_8"
}
}'

Noi dung request

general_info (bat buoc)

TruongKieuBat buocMo ta
item_namestringTen san pham
sku_codestringMa SKU duy nhat
unitstringDon vi tinh (vi du: pcs, kg)
descriptionstringMo ta san pham

sale_info (bat buoc)

TruongKieuBat buocMo ta
sale_priceintegerGia ban truoc thue (don vi tien te nho nhat)
sale_category_codestringMa danh muc thu nhap. Xem Tai lieu tham chieu ma
sale_tax_codestringMa thue (vi du: TAX_CODE_10). Xem Tai lieu tham chieu ma

purchase_info (bat buoc)

TruongKieuBat buocMo ta
purchase_priceintegerGia mua truoc thue
purchase_category_codestringMa danh muc chi phi. Xem Tai lieu tham chieu ma
purchase_tax_codestringMa thue. Xem Tai lieu tham chieu ma

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102001,
"request_id": "abc123...",
"data": {
"product_id": "PROD-550e8400-e29b-41d4-a716-446655440000",
"general_info": {
"item_name": "Example Product",
"sku_code": "SKU12345",
"unit": "pcs",
"description": "This is a sample product."
},
"sale_info": {
"sale_price": 100000,
"sale_category_code": "C1001",
"sale_tax_code": "TAX_CODE_10"
},
"purchase_info": {
"purchase_price": 80000,
"purchase_category_code": "D1001",
"purchase_tax_code": "TAX_CODE_8"
},
"created_at": "2024-01-20T14:00:00Z"
}
}

Lay danh sach san pham

Truy xuat tat ca san pham.

GET /api/v1/products
curl -X GET 'https://api.finan.one/open/api/v1/products' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999'

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102000,
"request_id": "abc123...",
"data": [
{
"product_id": "PROD-550e8400-e29b-41d4-a716-446655440000",
"general_info": {
"item_name": "Example Product",
"sku_code": "SKU12345",
"unit": "pcs"
},
"sale_info": {
"sale_price": 100000
},
"purchase_info": {
"purchase_price": 80000
},
"created_at": "2024-01-20T14:00:00Z"
}
]
}
Lay mot san pham
GET /api/v1/products/:product_id

Cap nhat san pham

Thay the du lieu cua san pham hien tai. Day la thao tac thay the toan bo -- tat ca cac phan (general_info, sale_info, purchase_info) va cac truong bat buoc cua chung phai duoc bao gom.

PUT /api/v1/products/:product_id
Thay the toan bo

Tat ca cac truong bao gom sale_tax_code va purchase_tax_code deu bat buoc khi cap nhat. Cac truong bi bo qua se bi xoa.

curl -X PUT 'https://api.finan.one/open/api/v1/products/PRODUCT_ID' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999' \
-d '{
"general_info": {
"item_name": "Updated Product Name",
"sku_code": "SKU67890",
"unit": "kg",
"description": "Updated description for the product."
},
"sale_info": {
"sale_price": 120000,
"sale_category_code": "C1001",
"sale_tax_code": "TAX_CODE_10"
},
"purchase_info": {
"purchase_price": 100000,
"purchase_category_code": "D1001",
"purchase_tax_code": "TAX_CODE_10"
}
}'

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102001,
"request_id": "abc123...",
"data": {
"product_id": "e5f85e53-d5db-4e4a-8383-61b4cc67398a",
"general_info": {
"item_name": "Updated Product Name",
"sku_code": "SKU67890",
"unit": "kg",
"description": "Updated description for the product."
},
"sale_info": {
"sale_price": 120000,
"sale_category_code": "C1001",
"sale_tax_code": "TAX_CODE_10"
},
"purchase_info": {
"purchase_price": 100000,
"purchase_category_code": "D1001",
"purchase_tax_code": "TAX_CODE_10"
}
}
}

Xoa san pham

Xoa san pham khoi danh muc.

DELETE /api/v1/products/:product_id
curl -X DELETE 'https://api.finan.one/open/api/v1/products/PROD-550e8400-e29b-41d4-a716-446655440000' \
-H 'Content-Type: application/json' \
-H 'x-client-id: YOUR_CLIENT_ID' \
-H 'x-signature: YOUR_SIGNATURE' \
-H 'x-timestamp: 1699999999'

Phan hoi

{
"message": { "content": "Thực thi API thành công" },
"code": 102001,
"request_id": "abc123...",
"data": "success"
}

Buoc tiep theo