{
  "openapi": "3.1.1",
  "info": {
    "title": "api/claims",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/"
    },
    {
      "url": "https://api.ati.su"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/gw/claims/integration/v1/claims/documents/upload": {
      "post": {
        "tags": [
          "IntegrationClaims"
        ],
        "summary": "Загрузка документа в плюшкин (внешние интеграторы)",
        "operationId": "post_integration_v1_claims_documents_upload",
        "requestBody": {
          "description": "Данные о документе претензии",
          "content": {
            "multipart/form-data": {
              "schema": {
                "required": [
                  "ClaimDocTypeId",
                  "File"
                ],
                "type": "object",
                "properties": {
                  "File": {
                    "type": "string",
                    "description": "Прикрепленный файл",
                    "format": "binary",
                    "example": "document.pdf"
                  },
                  "ClaimDocTypeId": {
                    "maximum": 2147483647,
                    "minimum": 0,
                    "type": "integer",
                    "description": "Тип прикрепленного файла из ClaimDocTypes",
                    "format": "int32",
                    "example": 2
                  }
                },
                "example": {
                  "File": "document.pdf",
                  "ClaimDocTypeId": 2
                }
              },
              "example": {
                "File": "document.pdf",
                "ClaimDocTypeId": 2
              },
              "encoding": {
                "File": {
                  "style": "form"
                },
                "ClaimDocTypeId": {
                  "style": "form"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationClaimDocumentUploadResultDto"
                },
                "example": {
                  "file_key": "string"
                }
              }
            }
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    },
    "/gw/claims/integration/v1/claims/defendants": {
      "get": {
        "tags": [
          "IntegrationClaims"
        ],
        "summary": "Получение имён ответчика из связанных фирм (внешние интеграторы)",
        "operationId": "get_integration_v1_claims_defendants",
        "parameters": [
          {
            "name": "atiId",
            "in": "query",
            "description": "Код фирмы ответчика в ATI.SU",
            "schema": {
              "type": "string"
            },
            "example": "12345"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationClaimDefendantFirmsDto"
                },
                "example": {
                  "defendant_firms": [
                    {
                      "name": "string",
                      "inn": "string"
                    }
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    },
    "/gw/claims/integration/v1/claims/add": {
      "post": {
        "tags": [
          "IntegrationClaims"
        ],
        "summary": "Добавление новой претензии с прикрепленными документами для внешних интеграторов",
        "operationId": "post_integration_v1_claims_add",
        "requestBody": {
          "description": "Данные претензии с документами",
          "content": {
            "application/json-patch+json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/IntegrationClaimAddRequestDto"
                  }
                ],
                "description": "Тело запроса на добавление претензии для внешних интеграторов."
              }
            },
            "application/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/IntegrationClaimAddRequestDto"
                  }
                ],
                "description": "Тело запроса на добавление претензии для внешних интеграторов."
              }
            },
            "text/json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/IntegrationClaimAddRequestDto"
                  }
                ],
                "description": "Тело запроса на добавление претензии для внешних интеграторов."
              }
            },
            "application/*+json": {
              "schema": {
                "allOf": [
                  {
                    "$ref": "#/components/schemas/IntegrationClaimAddRequestDto"
                  }
                ],
                "description": "Тело запроса на добавление претензии для внешних интеграторов."
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/IntegrationClaimAddResultDto"
                },
                "example": {
                  "id": "00000000-0000-0000-0000-000000000000",
                  "claim_level": 0
                }
              }
            }
          },
          "400": {
            "description": "Неверные входные данные.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "invalid_input_data",
                  "reason": "Неверные входные данные."
                }
              }
            }
          },
          "401": {
            "description": "Не авторизован",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "un_authorized",
                  "reason": "Не авторизован"
                }
              }
            }
          },
          "402": {
            "description": "Метод доступен только платным пользователям.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "payment_required",
                  "reason": "Метод доступен только платным пользователям."
                }
              }
            }
          },
          "403": {
            "description": "Отсутствует разрешение.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "forbidden",
                  "reason": "Отсутствует разрешение."
                }
              }
            }
          },
          "404": {
            "description": "Ресурс не найден",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "not_found",
                  "reason": "Ресурс не найден"
                }
              }
            }
          },
          "500": {
            "description": "Произошла ошибка во время выполнения запроса.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "internal_error",
                  "reason": "Произошла ошибка во время выполнения запроса."
                }
              }
            }
          },
          "504": {
            "description": "Сервер не ответил во время.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "error": "timeout",
                  "reason": "Сервер не ответил во время."
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "IntegrationClaimAddRequestDto": {
        "type": "object",
        "properties": {
          "claim_type": {
            "type": "null",
            "allOf": [
              {
                "$ref": "#/components/schemas/IntegrationClaimTypeDto"
              }
            ],
            "description": "DTO типа претензии",
            "example": {
              "type_id": 0,
              "user_type": 0
            }
          },
          "owner_firm": {
            "type": "null",
            "allOf": [
              {
                "$ref": "#/components/schemas/IntegrationClaimAddOwnerFirmDto"
              }
            ],
            "description": "Фирма истец",
            "example": {
              "inn": "string"
            }
          },
          "currency_id": {
            "type": "integer",
            "description": "ID валюты выставляемой претензии",
            "format": "int32",
            "example": 0
          },
          "total_sum": {
            "type": "number",
            "description": "Сумма разногласий",
            "format": "double",
            "example": 0
          },
          "fail_to_pay_date": {
            "type": [
              "null",
              "string"
            ],
            "description": "Дата наступления просрочки",
            "format": "date-time",
            "example": "1970-01-01T00:00:00Z"
          },
          "substantiation": {
            "type": [
              "null",
              "string"
            ],
            "description": "Обоснование суммы претензии",
            "example": "string"
          },
          "defendant_firm": {
            "type": "null",
            "allOf": [
              {
                "$ref": "#/components/schemas/IntegrationClaimAddDefendantFirmDto"
              }
            ],
            "description": "Фирма ответчик",
            "example": {
              "ati_id": "string",
              "inn": "string",
              "city_name": "string",
              "ownership_id": 0,
              "firm_name": "string"
            }
          },
          "document_files": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/IntegrationClaimDocumentRequestDto"
            },
            "description": "Прикрепленные документы претензии",
            "example": [
              {
                "file_key": "string"
              }
            ]
          }
        },
        "additionalProperties": false,
        "description": "Тело запроса на добавление претензии для внешних интеграторов.",
        "example": {
          "claim_type": {
            "type_id": 0,
            "user_type": 0
          },
          "owner_firm": {
            "inn": "string"
          },
          "currency_id": 0,
          "total_sum": 0,
          "fail_to_pay_date": "1970-01-01T00:00:00Z",
          "substantiation": "string",
          "defendant_firm": {
            "ati_id": "string",
            "inn": "string",
            "city_name": "string",
            "ownership_id": 0,
            "firm_name": "string"
          },
          "document_files": [
            {
              "file_key": "string"
            }
          ]
        }
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": [
              "null",
              "string"
            ],
            "description": "Код ошибки",
            "example": "invalid_input_data"
          },
          "reason": {
            "type": [
              "null",
              "string"
            ],
            "description": "Описание ошибки",
            "example": "Неверные входные данные."
          }
        },
        "additionalProperties": false,
        "description": "Стандартный ответ с описанием ошибки",
        "example": {
          "error": "invalid_input_data",
          "reason": "Неверные входные данные."
        }
      },
      "IntegrationClaimAddResultDto": {
        "type": "object",
        "properties": {
          "id": {
            "type": [
              "null",
              "string"
            ],
            "description": "Идентификатор новой претензии",
            "format": "uuid",
            "example": "00000000-0000-0000-0000-000000000000"
          },
          "claim_level": {
            "enum": [
              "0",
              "1"
            ],
            "allOf": [
              {
                "$ref": "#/components/schemas/ClaimLevel"
              }
            ],
            "description": "Уровень претензии (лайт / полная)",
            "example": 0
          }
        },
        "additionalProperties": false,
        "description": "Плоский результат добавления претензии для внешних интеграторов (все поля на одном уровне, без наследования).",
        "example": {
          "id": "00000000-0000-0000-0000-000000000000",
          "claim_level": 0
        }
      },
      "IntegrationClaimDefendantFirmsDto": {
        "type": "object",
        "properties": {
          "defendant_firms": {
            "type": [
              "null",
              "array"
            ],
            "items": {
              "$ref": "#/components/schemas/IntegrationClaimDefendantFirmDto"
            },
            "description": "Список связанных фирм ответчика",
            "example": [
              {
                "name": "string",
                "inn": "string"
              }
            ]
          }
        },
        "additionalProperties": false,
        "description": "Список связанных фирм ответчика для внешних интеграторов.",
        "example": {
          "defendant_firms": [
            {
              "name": "string",
              "inn": "string"
            }
          ]
        }
      },
      "IntegrationClaimDocumentUploadResultDto": {
        "type": "object",
        "properties": {
          "file_key": {
            "type": [
              "null",
              "string"
            ],
            "description": "Ключ файла в плюшкине",
            "example": "string"
          }
        },
        "additionalProperties": false,
        "description": "Результат загрузки файла в плюшкин для внешних интеграторов.",
        "example": {
          "file_key": "string"
        }
      },
      "IntegrationClaimTypeDto": {
        "type": "object",
        "properties": {
          "type_id": {
            "type": "integer",
            "description": "Идентификатор типа претензии",
            "format": "int32",
            "example": 0
          },
          "user_type": {
            "enum": [
              "0",
              "1",
              "2"
            ],
            "allOf": [
              {
                "$ref": "#/components/schemas/ClaimForType"
              }
            ],
            "description": "Идентификатор типа на кого выставлена претензия",
            "example": 0
          }
        },
        "additionalProperties": false,
        "example": {
          "type_id": 0,
          "user_type": 0
        }
      },
      "IntegrationClaimAddOwnerFirmDto": {
        "type": "object",
        "properties": {
          "inn": {
            "type": [
              "null",
              "string"
            ],
            "description": "ИНН фирмы истца",
            "example": "string"
          }
        },
        "additionalProperties": false,
        "example": {
          "inn": "string"
        }
      },
      "IntegrationClaimAddDefendantFirmDto": {
        "type": "object",
        "properties": {
          "ati_id": {
            "type": [
              "null",
              "string"
            ],
            "description": "ATI ID фирмы ответчика",
            "example": "string"
          },
          "inn": {
            "type": [
              "null",
              "string"
            ],
            "description": "ИНН фирмы ответчика",
            "example": "string"
          },
          "city_name": {
            "type": [
              "null",
              "string"
            ],
            "description": "Наименование города",
            "example": "string"
          },
          "ownership_id": {
            "type": [
              "null",
              "integer"
            ],
            "description": "Идентификатор формы собственности",
            "format": "int32",
            "example": 0
          },
          "firm_name": {
            "type": [
              "null",
              "string"
            ],
            "description": "Наименование фирмы ответчика",
            "example": "string"
          }
        },
        "additionalProperties": false,
        "example": {
          "ati_id": "string",
          "inn": "string",
          "city_name": "string",
          "ownership_id": 0,
          "firm_name": "string"
        }
      },
      "IntegrationClaimDocumentRequestDto": {
        "required": [
          "file_key"
        ],
        "type": "object",
        "properties": {
          "file_key": {
            "minLength": 1,
            "type": "string",
            "description": "Ключ загруженного файла",
            "example": "string"
          }
        },
        "additionalProperties": false,
        "example": {
          "file_key": "string"
        }
      },
      "ClaimLevel": {
        "enum": [
          0,
          1
        ],
        "type": "integer",
        "oneOf": [
          {
            "const": "0",
            "title": "ClaimLite",
            "description": "Претензия-Лайт"
          },
          {
            "const": "1",
            "title": "Claim",
            "description": "Претензия-Про"
          }
        ],
        "description": "Уровень Претензии\n- 0 = ClaimLite (Претензия-Лайт)\n- 1 = Claim (Претензия-Про)",
        "x-ms-enum-flags": {
          "isFlags": false
        }
      },
      "IntegrationClaimDefendantFirmDto": {
        "type": "object",
        "properties": {
          "name": {
            "type": [
              "null",
              "string"
            ],
            "description": "Наименование связанной фирмы с формой собственности",
            "example": "string"
          },
          "inn": {
            "type": [
              "null",
              "string"
            ],
            "description": "ИНН связанной фирмы",
            "example": "string"
          }
        },
        "additionalProperties": false,
        "description": "Связанная фирма ответчика (контракт для внешних интеграторов).",
        "example": {
          "name": "string",
          "inn": "string"
        }
      },
      "ClaimForType": {
        "enum": [
          0,
          1,
          2
        ],
        "type": "integer",
        "oneOf": [
          {
            "const": "0",
            "title": "None"
          },
          {
            "const": "1",
            "title": "Customer",
            "description": "Претензия как к заказчику"
          },
          {
            "const": "2",
            "title": "Executor",
            "description": "Претензии как к исполнителю"
          }
        ],
        "description": "Тип, определяющий на кого выставлена претензия\n- 0 = None\n- 1 = Customer (Претензия как к заказчику)\n- 2 = Executor (Претензии как к исполнителю)",
        "x-ms-enum-flags": {
          "isFlags": true
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Authorization: Bearer {authorizationToken}"
      }
    }
  }
}