{
  "openapi": "3.0.3",
  "info": {
    "title": "api/trucks",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/"
    },
    {
      "url": "https://api.ati.su"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/v1.1/trucks/{truckId}/counter_offers": {
      "put": {
        "tags": [
          "TruckResponses"
        ],
        "parameters": [
          {
            "name": "truckId",
            "in": "path",
            "required": true,
            "description": "ID машины",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Данные встречного предложения",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateTruckCounterOfferRequest"
              },
              "example": {
                "offerer_contact_id": 0,
                "cash_sum": 65000,
                "currency_id": 1,
                "sum_with_nds": 0,
                "nds_currency_id": 0,
                "sum_without_nds": 0,
                "not_nds_currency_id": 0,
                "note": "Готовы забрать сегодня",
                "prepay_percent": 30,
                "delay_payment_days": 5,
                "loading_city_id": 146,
                "unloading_city_id": 2,
                "weight": 20,
                "volume": 82,
                "car_delivery_date": "2026-04-24T00:00:00Z",
                "unload_payment": false,
                "coloading": false
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Встречное предложение создано или изменено",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CounterOfferWithSenderView"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      },
      "delete": {
        "tags": [
          "TruckResponses"
        ],
        "parameters": [
          {
            "name": "truckId",
            "in": "path",
            "required": true,
            "description": "ID машины",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Удаленные встречные предложения",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CounterOfferWithSenderView"
                  }
                }
              }
            }
          },
          "204": {
            "description": "На машине не было отзывов"
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    },
    "/v1.1/trucks/counter_offers/received": {
      "get": {
        "tags": [
          "TruckResponses"
        ],
        "parameters": [
          {
            "name": "newerThan",
            "in": "query",
            "required": false,
            "description": "Вернуть отзывы, измененные после указанной даты. Если модификатора часового пояса нет, дата отправляется в формате UTC+3 (Москва)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "includeArchived",
            "in": "query",
            "required": false,
            "description": "Включать архивные машины",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Список отзывов на ваши машины",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CounterOfferWithSenderView"
                  }
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    },
    "/v1.1/trucks/counter_offers/by_truck_ids": {
      "post": {
        "tags": [
          "TruckResponses"
        ],
        "parameters": [
          {
            "name": "includeArchived",
            "in": "query",
            "required": false,
            "description": "Включать архивные машины",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "requestBody": {
          "required": true,
          "description": "Список ID машин",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TruckIdUuidList"
              },
              "example": [
                "ce303e3c-210b-ec11-bb9f-0cc47af30c1b",
                "80f2f0f4-89a9-4ff5-95eb-6cf7b4a577c1"
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Встречные предложения по списку машин",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CounterOffersByTruckIdsView"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    },
    "/v1.1/trucks/counter_offers/my": {
      "get": {
        "tags": [
          "TruckResponses"
        ],
        "parameters": [
          {
            "name": "newerThan",
            "in": "query",
            "required": false,
            "description": "Вернуть отзывы, измененные после указанной даты. Если модификатора часового пояса нет, дата отправляется в формате UTC+3 (Москва)",
            "schema": {
              "type": "string",
              "format": "date-time"
            }
          },
          {
            "name": "includeArchived",
            "in": "query",
            "required": false,
            "description": "Включать архивные машины",
            "schema": {
              "type": "boolean",
              "default": false
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Список ваших отзывов на чужие машины",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/CounterOfferWithSenderView"
                  }
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    },
    "/gw/truck_responses/public/v1.1/trucks/counter_offers/{offerId}": {
      "delete": {
        "tags": [
          "TruckResponses"
        ],
        "parameters": [
          {
            "name": "offerId",
            "in": "path",
            "required": true,
            "description": "ID отзыва",
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Удаленный отзыв",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CounterOfferWithSenderView"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    },
    "/gw/truck_responses/public/v1.1/trucks/counter_offers/unviewed_count/by_truck_ids": {
      "post": {
        "tags": [
          "TruckResponses"
        ],
        "requestBody": {
          "required": true,
          "description": "Список truck_id машин.",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TruckIdUuidList"
              },
              "example": [
                "ce303e3c-210b-ec11-bb9f-0cc47af30c1b",
                "80f2f0f4-89a9-4ff5-95eb-6cf7b4a577c1"
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Количество непросмотренных встречных предложений по машинам",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnviewedCounterOffersCountByTruckResponse"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    },
    "/gw/truck_responses/v2/trucks/counter-offers/unviewed-count/by-truck-ids": {
      "post": {
        "tags": [
          "TruckResponses"
        ],
        "requestBody": {
          "required": true,
          "description": "Список ID машин",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TruckIdUuidList"
              },
              "example": [
                "ce303e3c-210b-ec11-bb9f-0cc47af30c1b",
                "80f2f0f4-89a9-4ff5-95eb-6cf7b4a577c1"
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Количество непросмотренных встречных предложений по машинам",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnviewedCounterOffersCountByTruckResponse"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    },
    "/gw/truck_responses/v1/trucks/published/counter_offers/count": {
      "post": {
        "tags": [
          "TruckResponses"
        ],
        "requestBody": {
          "required": true,
          "description": "Список ID опубликованных машин",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TruckIdUuidList"
              },
              "example": [
                "ce303e3c-210b-ec11-bb9f-0cc47af30c1b",
                "80f2f0f4-89a9-4ff5-95eb-6cf7b4a577c1"
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Счетчики встречных предложений по опубликованным машинам",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "x-dictionary-key-name": "truck_id",
                  "additionalProperties": {
                    "$ref": "#/components/schemas/YourCounterOffersCountView"
                  }
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    },
    "/gw/truck_responses/v1/trucks/archive/counter_offers/count": {
      "post": {
        "tags": [
          "TruckResponses"
        ],
        "requestBody": {
          "required": true,
          "description": "Список ID архивных машин",
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TruckIdUuidList"
              },
              "example": [
                "ce303e3c-210b-ec11-bb9f-0cc47af30c1b",
                "80f2f0f4-89a9-4ff5-95eb-6cf7b4a577c1"
              ]
            }
          }
        },
        "responses": {
          "200": {
            "description": "Счетчики встречных предложений по архивным машинам",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "x-dictionary-key-name": "truck_id",
                  "additionalProperties": {
                    "$ref": "#/components/schemas/ArchiveCounterOffersCountView"
                  }
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/CommonError"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "TruckIdUuid": {
        "title": "truck_id",
        "type": "string",
        "format": "uuid",
        "description": "ID машины (truck_id)."
      },
      "TruckIdUuidList": {
        "type": "array",
        "description": "Массив UUID.",
        "items": {
          "$ref": "#/components/schemas/TruckIdUuid"
        }
      },
      "UnviewedCounterOffersCountByTruckResponse": {
        "type": "object",
        "description": "Ключи свойств — строки UUID машин, значения — целые числа.",
        "additionalProperties": {
          "type": "integer",
          "format": "int32"
        }
      },
      "CreateTruckCounterOfferRequest": {
        "type": "object",
        "description": "Тело запроса для создания или изменения встречного предложения",
        "required": [
          "cash_sum",
          "sum_with_nds",
          "sum_without_nds",
          "weight",
          "volume",
          "car_delivery_date"
        ],
        "properties": {
          "offerer_contact_id": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "ID контакта автора предложения (если не передан, подставляется текущий контакт)"
          },
          "cash_sum": {
            "type": "number",
            "format": "double",
            "description": "Сумма наличными"
          },
          "currency_id": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Валюта для наличной суммы. Значение из [словаря валют АТИ](https://ati.su/developers/api/dictionaries/trucks/)"
          },
          "sum_with_nds": {
            "type": "number",
            "format": "double",
            "description": "Сумма с НДС"
          },
          "nds_currency_id": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Валюта суммы с НДС. Значение из [словаря валют АТИ](https://ati.su/developers/api/dictionaries/trucks/)"
          },
          "sum_without_nds": {
            "type": "number",
            "format": "double",
            "description": "Сумма без НДС"
          },
          "not_nds_currency_id": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Валюта суммы без НДС. Значение из [словаря валют АТИ](https://ati.su/developers/api/dictionaries/trucks/)"
          },
          "note": {
            "type": "string",
            "nullable": true,
            "description": "Комментарий к предложению. Максимальное количество символов 512"
          },
          "prepay_percent": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Процент предоплаты"
          },
          "delay_payment_days": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Отсрочка оплаты в банковских днях"
          },
          "loading_city_id": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "ID города погрузки. Значение из [словаря городов АТИ](https://ati.su/developers/api/dictionaries/geo/)"
          },
          "unloading_city_id": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "ID города выгрузки. Значение из [словаря городов АТИ](https://ati.su/developers/api/dictionaries/geo/)"
          },
          "weight": {
            "type": "number",
            "format": "double",
            "description": "Максимальная грузоподъемность, т"
          },
          "volume": {
            "type": "number",
            "format": "double",
            "description": "Максимальный объем, м3"
          },
          "car_delivery_date": {
            "type": "string",
            "format": "date-time",
            "description": "Дата подачи машины. При передаче времени учитывается только дата."
          },
          "unload_payment": {
            "type": "boolean",
            "nullable": true,
            "description": "Оплата на выгрузке"
          },
          "coloading": {
            "type": "boolean",
            "nullable": true,
            "description": "Разрешена догрузка"
          }
        }
      },
      "CounterOffersByTruckIdsView": {
        "type": "object",
        "description": "Словарь отзывов по ID машин",
        "x-dictionary-key-name": "truck_id",
        "additionalProperties": {
          "type": "array",
          "items": {
            "$ref": "#/components/schemas/CounterOfferWithSenderView"
          }
        }
      },
      "CounterOfferWithSenderView": {
        "allOf": [
          {
            "$ref": "#/components/schemas/CounterOfferViewBase"
          },
          {
            "type": "object",
            "properties": {
              "sender_firm_info": {
                "description": "Информация о фирме, оставившей встречное предложение",
                "$ref": "#/components/schemas/FirmSummary"
              }
            }
          }
        ]
      },
      "CounterOfferViewBase": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Id встречного предложения"
          },
          "truck_id": {
            "type": "string",
            "format": "uuid",
            "description": "Id машины"
          },
          "addition_date": {
            "type": "string",
            "format": "date-time",
            "description": "Дата добавления встречного предложения"
          },
          "change_date": {
            "type": "string",
            "format": "date-time",
            "description": "Дата изменения встречного предложения"
          },
          "viewed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Дата и время просмотра встречного предложения"
          },
          "cash_sum": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "Ставка наличными"
          },
          "currency_id": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Валюта ставки наличными. Значение из [словаря валют АТИ](https://ati.su/developers/api/dictionaries/trucks/)"
          },
          "sum_with_nds": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "Ставка с НДС"
          },
          "nds_currency_id": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Валюта ставки с НДС. Значение из [словаря валют АТИ](https://ati.su/developers/api/dictionaries/trucks/)"
          },
          "sum_without_nds": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "Ставка без НДС"
          },
          "not_nds_currency_id": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Валюта ставки без НДС. Значение из [словаря валют АТИ](https://ati.su/developers/api/dictionaries/trucks/)"
          },
          "note": {
            "type": "string",
            "nullable": true,
            "description": "Комментарий к предложению. Максимальное количество символов 512"
          },
          "prepay_percent": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Предоплата в процентах"
          },
          "delay_payment_days": {
            "type": "integer",
            "format": "int32",
            "nullable": true,
            "description": "Оплата через банковских дней"
          },
          "loading_city_id": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Id города загрузки. Значение из [словаря городов АТИ](https://ati.su/developers/api/dictionaries/geo/)"
          },
          "unloading_city_id": {
            "type": "integer",
            "format": "int64",
            "nullable": true,
            "description": "Id города разгрузки. Значение из [словаря городов АТИ](https://ati.su/developers/api/dictionaries/geo/)"
          },
          "weight": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "Максимальная грузоподъемность, т"
          },
          "volume": {
            "type": "number",
            "format": "double",
            "nullable": true,
            "description": "Максимальный объем, м3"
          },
          "car_delivery_date": {
            "type": "string",
            "format": "date-time",
            "description": "Дата подачи транспорта"
          },
          "is_actual": {
            "type": "boolean",
            "description": "Актуальность встречного предложения"
          },
          "unload_payment": {
            "type": "boolean",
            "description": "Оплата на выгрузке"
          },
          "coloading": {
            "type": "boolean",
            "description": "Догруз"
          }
        }
      },
      "FirmSummary": {
        "type": "object",
        "properties": {
          "ati_id": {
            "type": "string",
            "description": "ATI ID контакта"
          },
          "contact_id": {
            "type": "integer",
            "format": "int32",
            "description": "Id контакта"
          },
          "firm_id": {
            "type": "integer",
            "format": "int32",
            "description": "Id фирмы"
          },
          "contact": {
            "description": "Краткая информация о контакте",
            "$ref": "#/components/schemas/FirmContactSummary"
          },
          "name": {
            "type": "string",
            "description": "Название фирмы"
          },
          "score": {
            "type": "number",
            "format": "double",
            "description": "Рейтинг фирмы"
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "description": "Статус фирмы"
          }
        }
      },
      "FirmContactSummary": {
        "type": "object",
        "properties": {
          "firm_id": {
            "type": "integer",
            "format": "int32",
            "description": "Id фирмы"
          },
          "ati_id": {
            "type": "string",
            "description": "ATI ID контакта"
          },
          "contact_id": {
            "type": "integer",
            "format": "int32",
            "description": "Id контакта"
          },
          "name": {
            "type": "string",
            "nullable": true,
            "description": "Имя контакта"
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "description": "Телефон"
          },
          "mobile_phone": {
            "type": "string",
            "nullable": true,
            "description": "Мобильный телефон"
          },
          "claims_count": {
            "type": "integer",
            "format": "int32",
            "description": "Количество претензий"
          },
          "recommendations_count": {
            "type": "integer",
            "format": "int32",
            "description": "Количество рекомендаций"
          },
          "bad_partner_mentions_count": {
            "type": "integer",
            "format": "int32",
            "description": "Количество упоминаний в НП"
          },
          "city": {
            "type": "string",
            "nullable": true,
            "description": "Город"
          },
          "firm_type": {
            "type": "string",
            "nullable": true,
            "description": "Тип фирмы"
          },
          "firm_name": {
            "type": "string",
            "nullable": true,
            "description": "Название фирмы"
          },
          "ownership": {
            "type": "string",
            "nullable": true,
            "description": "Форма собственности"
          },
          "score": {
            "type": "number",
            "format": "double",
            "description": "Рейтинг контакта"
          },
          "status": {
            "type": "integer",
            "format": "int32",
            "description": "Статус контакта"
          },
          "skype_name": {
            "type": "string",
            "nullable": true,
            "description": "Skype"
          },
          "fax": {
            "type": "string",
            "nullable": true,
            "description": "Факс"
          },
          "email": {
            "type": "string",
            "nullable": true,
            "description": "E-mail"
          }
        }
      },
      "CommonErrorDetail": {
        "type": "object",
        "properties": {
          "property": {
            "type": "string",
            "description": "Имя поля в теле запроса, к которому относится ошибка."
          },
          "reason": {
            "type": "string",
            "description": "Текстовое описание нарушения для этого поля (например, неверный формат или диапазон)."
          }
        }
      },
      "CommonError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "Ключ ошибки (идентификатор сценария отказа или типа сбоя)."
          },
          "reason": {
            "type": "string",
            "description": "Пояснение: что не так с запросом и при валидации — какие ограничения нарушены."
          },
          "details": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/CommonErrorDetail"
            },
            "description": "Ошибки валидации по полям: каждый элемент соответствует одному полю JSON-тела."
          }
        }
      },
      "YourCounterOffersCountView": {
        "type": "object",
        "properties": {
          "active_count": {
            "type": "integer",
            "format": "int32",
            "description": "Количество активных встречных предложений"
          },
          "has_counter_offers": {
            "type": "boolean",
            "description": "Есть ли встречные предложения по машине"
          },
          "unviewed_count": {
            "type": "integer",
            "format": "int32",
            "description": "Количество непросмотренных встречных предложений"
          }
        }
      },
      "ArchiveCounterOffersCountView": {
        "type": "object",
        "properties": {
          "has_counter_offers": {
            "type": "boolean",
            "description": "Есть ли встречные предложения по архивной машине"
          }
        }
      }
    },
    "responses": {
      "CommonError": {
        "description": "Ошибка запроса",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/CommonError"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Authorization: Bearer {authorizationToken}"
      }
    }
  }
}