{
  "openapi": "3.1.0",
  "info": {
    "title": "千飞 CNC 报价 API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://aibaojia.creating5dreams.com"
    }
  ],
  "paths": {
    "/v1/quotes": {
      "post": {
        "tags": [
          "Quotes"
        ],
        "summary": "接收报价资料",
        "description": "保存资料并返回 received 状态。此接口当前提供收件与查询。",
        "operationId": "submit_v1_quotes_post",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Idempotency-Key"
            }
          }
        ],
        "responses": {
          "202": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteReceipt"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "files"
                ],
                "properties": {
                  "files": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "binary"
                    }
                  },
                  "quantities": {
                    "type": "string",
                    "example": "[10,50,100]"
                  },
                  "quantity": {
                    "type": "integer",
                    "minimum": 1,
                    "maximum": 10000000
                  },
                  "currency": {
                    "type": "string",
                    "default": "CNY",
                    "enum": [
                      "CNY",
                      "EUR",
                      "GBP",
                      "JPY",
                      "USD"
                    ]
                  },
                  "material": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "process": {
                    "type": "string",
                    "maxLength": 200
                  },
                  "part_requirements": {
                    "type": "string",
                    "example": "[{\"drawing_no\":\"QM-001\",\"quantity\":17}]"
                  },
                  "exchange_rate": {
                    "type": "number",
                    "description": "每单位报价币种对应人民币金额"
                  },
                  "notes": {
                    "type": "string",
                    "maxLength": 2000
                  },
                  "billing_mode": {
                    "type": "string",
                    "enum": [
                      "trial_only",
                      "auto"
                    ],
                    "default": "trial_only"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/v1/quotes/{quote_id}": {
      "get": {
        "tags": [
          "Quotes"
        ],
        "summary": "查询报价收件与处理进度",
        "operationId": "get_quote_v1_quotes__quote_id__get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "quote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Quote Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/QuoteReceipt"
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/quotes/{quote_id}/previews/{part_index}/{kind}": {
      "get": {
        "tags": [
          "Quotes"
        ],
        "summary": "查看图纸或模型预览",
        "operationId": "preview_api_v1_quotes__quote_id__previews__part_index___kind__get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "quote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Quote Id"
            }
          },
          {
            "name": "part_index",
            "in": "path",
            "required": true,
            "schema": {
              "type": "integer",
              "title": "Part Index"
            }
          },
          {
            "name": "kind",
            "in": "path",
            "required": true,
            "schema": {
              "enum": [
                "drawing",
                "model"
              ],
              "type": "string",
              "title": "Kind"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "image/jpeg": {}
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/quotes/{quote_id}/report.html": {
      "get": {
        "tags": [
          "Quotes"
        ],
        "summary": "下载可打印报价报告",
        "operationId": "download_report_v1_quotes__quote_id__report_html_get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "quote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Quote Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "text/html": {}
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/quotes/{quote_id}/files/{file_id}": {
      "get": {
        "tags": [
          "Quotes"
        ],
        "summary": "下载报价附件",
        "operationId": "download_v1_quotes__quote_id__files__file_id__get",
        "security": [
          {
            "HTTPBearer": []
          }
        ],
        "parameters": [
          {
            "name": "quote_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "Quote Id"
            }
          },
          {
            "name": "file_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid",
              "title": "File Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": [
          "Quotes"
        ],
        "summary": "查询工作区收件用量",
        "operationId": "usage_v1_usage_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        },
        "security": [
          {
            "HTTPBearer": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "Attachment": {
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "title": "Id"
          },
          "filename": {
            "type": "string",
            "title": "Filename"
          },
          "size": {
            "type": "integer",
            "title": "Size"
          },
          "sha256": {
            "type": "string",
            "title": "Sha256"
          }
        },
        "type": "object",
        "required": [
          "id",
          "filename",
          "size",
          "sha256"
        ],
        "title": "Attachment"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "QuoteReceipt": {
        "properties": {
          "quote_id": {
            "type": "string",
            "format": "uuid",
            "title": "Quote Id"
          },
          "status": {
            "type": "string",
            "enum": [
              "received",
              "processing",
              "succeeded",
              "review_required",
              "failed"
            ],
            "title": "Status"
          },
          "quantities": {
            "items": {
              "type": "integer"
            },
            "type": "array",
            "title": "Quantities"
          },
          "currency": {
            "type": "string",
            "title": "Currency"
          },
          "notes": {
            "type": "string",
            "title": "Notes"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "title": "Created At"
          },
          "source": {
            "anyOf": [
              {
                "type": "string",
                "enum": [
                  "web",
                  "api"
                ]
              },
              {
                "type": "null"
              }
            ],
            "title": "Source"
          },
          "started_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Started At"
          },
          "finished_at": {
            "anyOf": [
              {
                "type": "string",
                "format": "date-time"
              },
              {
                "type": "null"
              }
            ],
            "title": "Finished At"
          },
          "allowance": {
            "type": "string",
            "enum": [
              "trial",
              "simulation"
            ],
            "title": "Allowance",
            "default": "trial"
          },
          "files": {
            "items": {
              "$ref": "#/components/schemas/Attachment"
            },
            "type": "array",
            "title": "Files"
          },
          "result": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Result"
          },
          "failure_code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Failure Code"
          },
          "options": {
            "anyOf": [
              {
                "additionalProperties": true,
                "type": "object"
              },
              {
                "type": "null"
              }
            ],
            "title": "Options"
          }
        },
        "type": "object",
        "required": [
          "quote_id",
          "status",
          "quantities",
          "currency",
          "notes",
          "created_at",
          "files"
        ],
        "title": "QuoteReceipt"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "HTTPBearer": {
        "type": "http",
        "scheme": "bearer"
      }
    }
  }
}
