delivery api
1.0.0
歡迎來到送貨API!此API是用於管理應用程序中產品和銷售的解決方案。它以.NET為基礎,為創建和管理產品和處理銷售交易提供了一個寧靜的接口。本文檔概述了交付API端點,包括詳細的描述,請求參數和響應格式。 API包括用於健康檢查,管理產品和處理銷售的端點。
克隆存儲庫:
git clone https://github.com/anthonyvii27/delivery-api更改為存儲庫目錄:
cd delivery-api運行命令以啟動容器化環境:
make compose-up-v2 API將在計算機上的端口:8080上運行。
可選地,在此存儲庫的根部,有一個名為delivery-api.http的文件,該文件提供了一個易於使用的接口,用於執行已實現的端點。
GET /health摘要:檢查API的健康狀況。
回答:
200好
" Database connection is healthy. "503服務不可用
" Database connection isn't available. "500內部服務器錯誤
" An error occurred while checking the database connection. "GET /products摘要:檢索所有產品。
回答:
[
{
"id" : 1 ,
"name" : " Product Name " ,
"unitOfMeasurement" : " UN " ,
"price" : 9.99
}
]GET /products/{id}摘要:通過其ID檢索產品。
參數:
id (整數):要檢索的產品ID。回答:
200好
{
"id" : 1 ,
"name" : " Product Name " ,
"unitOfMeasurement" : " UN " ,
"price" : 9.99
}404找不到
{
"message" : " Product with ID {id} not found. "
}POST /products摘要:創建一個新產品。
請求主體:
{
"name" : " Product Name " ,
"unitOfMeasurement" : " Unit " ,
"price" : 9.99
}回答:
201創建
{
"id" : 1 ,
"name" : " Product Name " ,
"unitOfMeasurement" : " Unit " ,
"price" : 9.99
}400不良要求
{
"message" : " Validation error messages "
}PUT /products/{id}摘要:更新現有產品。
參數:
id (整數):要更新產品的ID。請求主體:
{
"name" : " Updated Product Name " ,
"unitOfMeasurement" : " Updated Unit " ,
"price" : 9.99
}回答:
200好
{
"id" : 1 ,
"name" : " Updated Product Name " ,
"unitOfMeasurement" : " Updated Unit " ,
"price" : 9.99
}400不良要求
{
"message" : " Validation error messages "
}404找不到
{
"message" : " Product with ID {id} not found. "
}DELETE /products/{id}摘要:通過其ID刪除產品。
參數:
id (整數):要刪除產品的ID。回答:
204沒有內容
400不良要求
{
"message" : " Error message "
}404找不到
{
"message" : " Product with ID {id} not found. "
}409衝突
{
"message" : " Cannot delete the product as it has associated sale items. "
}GET /sales摘要:檢索所有銷售(歷史)。
回答:
[
{
"id" : 1 ,
"saleDate" : " 2024-08-14T00:00:00Z " ,
"totalAmount" : 100.00 ,
"saleItems" : [
{
"id" : 1 ,
"productId" : 1 ,
"quantity" : 2 ,
"unitPrice" : 50.00
}
]
}
]GET /sales/{id}摘要:通過ID檢索銷售。
參數:
id (整數):檢索出售的ID。回答:
200好
{
"id" : 1 ,
"saleDate" : " 2024-08-14T00:00:00Z " ,
"totalAmount" : 100.00 ,
"saleItems" : [
{
"id" : 1 ,
"productId" : 1 ,
"quantity" : 2 ,
"unitPrice" : 50.00
}
]
}404找不到
{
"message" : " Sale with ID {id} not found. "
}POST /sales摘要:創建新的銷售。
請求主體:
{
"saleDate" : " 2024-08-14T00:00:00Z " ,
"zipCode" : " 12345678 " ,
"saleItems" : [
{
"productId" : 1 ,
"quantity" : 2
}
]
}回答:
201創建
{
"id" : 1 ,
"saleDate" : " 2024-08-14T00:00:00Z " ,
"totalAmount" : 100.00 ,
"saleItems" : [
{
"id" : 1 ,
"productId" : 1 ,
"quantity" : 2 ,
"unitPrice" : 50.00 ,
"product" : {
"id" : 1 ,
"name" : " Product Name " ,
"unitOfMeasurement" : " Unit " ,
"price" : 50.00
}
}
]
}400不良要求
{
"message" : " Validation error messages "
}DELETE /sales/{id}摘要:刪除(取消)通過其ID銷售。
參數:
id (整數):刪除銷售的ID。回答:
204沒有內容
400不良要求
{
"message" : " Error message "
}404找不到
{
"message" : " Sale with ID {id} not found. "
}