{
  "openapi": "3.0.3",
  "info": {
    "title": "paid-api/average_prices",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/"
    },
    {
      "url": "https://api.ati.su"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/priceline/license/v2/all_directions": {
      "get": {
        "tags": [
          "License"
        ],
        "summary": "Возвращает список всех доступных направлений и доступные типы кузова для направления",
        "operationId": "get_all_directions_license_license_v2_all_directions_get",
        "parameters": [
          {
            "name": "demo",
            "in": "query",
            "required": false,
            "type": "boolean",
            "default": false,
            "title": "Demo"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllDirectionsResponseLicenseV2"
                }
              }
            }
          }
        }
      }
    },
    "/priceline/license/v1/all_directions": {
      "get": {
        "tags": [
          "License"
        ],
        "summary": "Возвращает список всех доступных направлений и доступные типы кузова для направления",
        "operationId": "get_all_directions_license_license_v1_all_directions_get",
        "parameters": [
          {
            "name": "demo",
            "in": "query",
            "required": false,
            "type": "boolean",
            "default": false,
            "title": "Demo"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AllDirectionsResponseLicenseV1"
                }
              }
            }
          }
        }
      }
    },
    "/priceline/license/v1/average_prices": {
      "post": {
        "tags": [
          "License"
        ],
        "summary": "Метод получения средних цен",
        "operationId": "average_prices_license_v1_average_prices_post",
        "parameters": [
          {
            "name": "demo",
            "in": "query",
            "required": false,
            "type": "boolean",
            "default": false,
            "title": "Demo"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RequestParams"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ResponseParams"
                }
              }
            }
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorFormatResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorFormatResponse"
                }
              }
            },
            "description": "Unprocessable Entity"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorFormatResponse"
                }
              }
            },
            "description": "Too Many Requests"
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "AllDirectionsResponseLicenseV1": {
        "properties": {
          "AllDirections": {
            "items": {
              "$ref": "#/components/schemas/DirectionLicenseV1"
            },
            "type": "array",
            "title": "Alldirections",
            "description": "Все направления для средних ставок"
          }
        },
        "type": "object",
        "required": [
          "AllDirections"
        ],
        "title": "Ответ: список направлений"
      },
      "AllDirectionsResponseLicenseV2": {
        "properties": {
          "AllDirections": {
            "items": {
              "$ref": "#/components/schemas/DirectionLicenseV2"
            },
            "type": "array",
            "title": "Alldirections",
            "description": "Все направления для средних ставок"
          }
        },
        "type": "object",
        "required": [
          "AllDirections"
        ],
        "title": "Ответ: список направлений"
      },
      "DirectionInfo": {
        "properties": {
          "CartypeTonnage": {
            "type": "object",
            "title": "Cartypetonnage",
            "description": "Словарь доступных сочетаний тип кузова - тоннаж"
          },
          "TonnageCartype": {
            "type": "object",
            "title": "Tonnagecartype",
            "description": "Словарь сочетаний тоннаж - тип кузова"
          }
        },
        "type": "object",
        "required": [
          "CartypeTonnage",
          "TonnageCartype"
        ],
        "title": "DirectionInfo"
      },
      "DirectionLicenseV1": {
        "properties": {
          "FromCityId": {
            "type": "integer",
            "title": "Fromcityid",
            "description": "ID города загрузки"
          },
          "FromCity": {
            "type": "string",
            "title": "Fromcity",
            "description": "Название города загрузки"
          },
          "ToCityId": {
            "type": "integer",
            "title": "Tocityid",
            "description": "ID города разгрузки"
          },
          "ToCity": {
            "type": "string",
            "title": "Tocity",
            "description": "Название города разгрузки"
          },
          "FromRegionId": {
            "type": "integer",
            "title": "Fromregionid",
            "description": "ID региона загрузки"
          },
          "FromRegion": {
            "type": "string",
            "title": "Fromregion",
            "description": "Название региона загрузки"
          },
          "ToRegionId": {
            "type": "integer",
            "title": "Toregionid",
            "description": "ID региона разгрузки"
          },
          "ToRegion": {
            "type": "string",
            "title": "Toregion",
            "description": "Название региона разгрузки"
          },
          "CarTypes": {
            "items": {
              "type": "string"
            },
            "type": "array",
            "title": "Cartypes",
            "description": "Список типов кузова, доступных для этого направления"
          },
          "RoundTrips": {
            "items": {
              "type": "string"
            },
            "type": "array"
          },
          "title": "Roundtrips",
          "description": "Список типов кузова, для которых доступно обратное направление"
        },
        "type": "object",
        "required": [
          "CarTypes"
        ],
        "title": "Подпараметр ответа: одно направление, версия АПИ 1"
      },
      "DirectionLicenseV2": {
        "properties": {
          "FromCityId": {
            "type": "integer",
            "title": "Fromcityid",
            "description": "ID города загрузки"
          },
          "FromCity": {
            "type": "string",
            "title": "Fromcity",
            "description": "Название города загрузки"
          },
          "ToCityId": {
            "type": "integer",
            "title": "Tocityid",
            "description": "ID города разгрузки"
          },
          "ToCity": {
            "type": "string",
            "title": "Tocity",
            "description": "Название города разгрузки"
          },
          "FromRegionId": {
            "type": "integer",
            "title": "Fromregionid",
            "description": "ID региона загрузки"
          },
          "FromRegion": {
            "type": "string",
            "title": "Fromregion",
            "description": "Название региона загрузки"
          },
          "ToRegionId": {
            "type": "integer",
            "title": "Toregionid",
            "description": "ID региона разгрузки"
          },
          "ToRegion": {
            "type": "string",
            "title": "Toregion",
            "description": "Название региона разгрузки"
          },
          "DirectionInfo": {
            "$ref": "#/components/schemas/DirectionInfo",
            "description": "Структура информации о направлении - доступные сочетания тоннажа и типов кузова"
          },
          "RoundTripsInfo": {
            "$ref": "#/components/schemas/DirectionInfo",
            "description": "Структура информации о кругорейсе - доступные сочетания тоннажа и типов кузова"
          }
        },
        "type": "object",
        "required": [
          "DirectionInfo"
        ],
        "title": "Подпараметр ответа: одно направление, версия АПИ 2"
      },
      "ErrorFormatResponse": {
        "properties": {
          "error": {
            "type": "string",
            "title": "Error",
            "description": "Основное тело ошибки с описанием"
          },
          "reason": {
            "type": "string",
            "title": "Reason",
            "description": "Тип ошибки если имеется"
          },
          "details": {
            "type": "object",
            "title": "Details",
            "description": "Какие-либо дополнительные детали ошибки"
          }
        },
        "type": "object",
        "required": [
          "error",
          "reason",
          "details"
        ],
        "title": "Ответ: Формат ответа при ошибке"
      },
      "GeoPoint": {
        "properties": {
          "CityId": {
            "type": "integer",
            "title": "Cityid",
            "description": "ID города. Значение поля `id` в структуре `city` из [словаря  ATI.SU](https://ati.su/developers/api/dictionaries/geo/#post-v1-autocomplete-suggestions)",
            "example": 3611
          },
          "RegionId": {
            "type": "integer",
            "title": "Regionid",
            "description": "ID региона. Значение поля `id` в структуре `region` из [словаря  ATI.SU](https://ati.su/developers/api/dictionaries/geo/#post-v1-autocomplete-suggestions)",
            "example": 1
          }
        },
        "type": "object",
        "title": "Подпараметр ответа: геоточка"
      },
      "Price": {
        "properties": {
          "UpperPrice": {
            "type": "number",
            "title": "Upperprice",
            "description": "Верхняя граница ставок в руб или в руб/км",
            "example": 30
          },
          "BottomPrice": {
            "type": "number",
            "title": "Bottomprice",
            "description": "Нижняя граница ставок в руб или в руб/км",
            "example": 10
          },
          "AveragePrice": {
            "type": "number",
            "title": "Averageprice",
            "description": "Средняя ставка в руб или в руб/км",
            "example": 20
          }
        },
        "type": "object",
        "required": [
          "UpperPrice",
          "BottomPrice",
          "AveragePrice"
        ],
        "title": "Подпараметр ответа: данные по ставкам"
      },
      "PriceData": {
        "properties": {
          "DateFrom": {
            "type": "string",
            "format": "date",
            "title": "Datefrom",
            "description": "Начало периода. Формат ISO-8601.\n        ",
            "example": "2022-03-01"
          },
          "DateTo": {
            "type": "string",
            "format": "date",
            "title": "Dateto",
            "description": "Конец периода. Формат ISO-8601.\n        ",
            "example": "2022-03-02"
          },
          "Prices": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Price"
              }
            ],
            "description": "Данные по ставкам в руб/км",
            "nullable": true
          },
          "PricesInRub": {
            "allOf": [
              {
                "$ref": "#/components/schemas/Price"
              }
            ],
            "description": "Данные по ставкам в руб",
            "nullable": true
          },
          "LoadsCount": {
            "type": "integer",
            "title": "Loadscount",
            "description": "Количество грузов",
            "example": 121
          }
        },
        "type": "object",
        "required": [
          "DateFrom"
        ],
        "title": "Подпараметр ответа: одна точка средних цен во времени"
      },
      "RequestParams": {
        "properties": {
          "From": {
            "allOf": [
              {
                "$ref": "#/components/schemas/GeoPoint"
              }
            ],
            "description": "Город или регион откуда"
          },
          "To": {
            "allOf": [
              {
                "$ref": "#/components/schemas/GeoPoint"
              }
            ],
            "description": "Город или регион куда"
          },
          "CarType": {
            "type": "string",
            "title": "Cartype",
            "description": "Тип кузова.\n* `ref` - рефрижераторы.\n* `close` - закрытые. Значение по умолчанию.\n* `open` - открытые.\n* `tent` - тентованный.\n* `tral` - трал.\n* `docker` - контейнер.\n        ",
            "default": "close",
            "example": "close"
          },
          "DateFrom": {
            "type": "string",
            "format": "date",
            "title": "Datefrom",
            "description": "Начало периода. Формат ISO-8601.\n         Если интересует только одна дата, то передавать ее здесь.\n         По умолчанию - последний день, за который есть данные.\n        ",
            "example": "2022-03-01"
          },
          "DateTo": {
            "type": "string",
            "format": "date",
            "title": "Dateto",
            "description": "Конец периода. Формат ISO-8601.\n        Если интересует только одна дата, то данное поле не заполнять.\n        ",
            "example": "2022-03-02"
          },
          "Frequency": {
            "type": "string",
            "title": "Frequency",
            "description": "Дискретность выдачи данных.\n* `day` - для каждого дня будут выданы данные. Значение по умолчанию.\n     Опция `day` доступна только в том случае,\n     если общий временной период составляет меньше 6 месяцев.\n* `week` - будут выданы усредненные данные по неделе.\n* `month`- будут выданы усредненные данные по месяцу.\n        ",
            "default": "day",
            "example": "day"
          },
          "WithNds": {
            "type": "boolean",
            "title": "Withnds",
            "description": "Учитывать ли НДС в цене.\n* `false` - не учитывать. Значение по умолчанию.\n* `true` - учитывать.\n    ",
            "default": false,
            "example": false
          },
          "RoundTrip": {
            "type": "boolean",
            "title": "Roundtrip",
            "description": "Параметр позволяет получить цену кругорейса,\n        то есть ставку для маршрута «туда и обратно».\n* `false` - для прямого рейса. Значение по умолчанию.\n* `true` - для кругового рейса (если доступен).\n        ",
            "default": false,
            "example": false
          },
          "Tonnage": {
            "type": "integer",
            "title": "Tonnage",
            "description": "Тоннаж. Одно из:\n * `1.5`\n * `3` \n * `5`\n * `10`\n * `20` - значение по умолчанию.",
            "example": 3
          }
        },
        "type": "object",
        "required": [
          "From",
          "To"
        ],
        "title": "Запрос: входные параметры для средних цен",
        "example": {
          "CarType": "close",
          "DateFrom": "2022-03-01",
          "DateTo": "2022-03-02",
          "Frequency": "day",
          "From": {
            "CityId": 1
          },
          "RoundTrip": false,
          "To": {
            "CityId": 3611
          },
          "Tonnage": 5,
          "WithNds": false
        }
      },
      "ResponseParams": {
        "properties": {
          "Data": {
            "items": {
              "$ref": "#/components/schemas/PriceData"
            },
            "type": "array",
            "title": "Data",
            "description": "Данные по запрошенному интервалу"
          },
          "Distance": {
            "type": "integer",
            "title": "Distance",
            "description": "Расстояние маршрута в километрах",
            "example": 750
          },
          "WithNDS": {
            "type": "boolean",
            "title": "Withnds",
            "description": "Являются ли данные ставки ставками с учётом НДС",
            "example": false
          }
        },
        "type": "object",
        "required": [
          "Data",
          "WithNDS"
        ],
        "title": "Ответ: данные по средним ценам за выбранный временной период"
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Authorization: Bearer {authorizationToken}"
      }
    }
  }
}