配信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 OK
" 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 OK
{
"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 OK
{
"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 (integer):取得する販売のID。回答:
200 OK
{
"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 (integer):削除するための販売のID。回答:
204コンテンツなし
400悪いリクエスト
{
"message" : " Error message "
}404見つかりません
{
"message" : " Sale with ID {id} not found. "
}