{
  "openapi": "3.0.1",
  "info": {
    "title": "api/orders/gps-open-api",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/"
    },
    {
      "url": "https://api.ati.su"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/v1/driver/public/gps/device": {
      "post": {
        "tags": [
          "GpsIntegrator"
        ],
        "summary": "Добавить или обновить gps устройство",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/AddGpsDeviceRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddGpsDeviceRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/AddGpsDeviceRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/AddGpsDeviceRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ок"
          },
          "201": {
            "description": "Создан новый объект"
          },
          "4XX": {
            "description": "Ошибка запроса",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "GpsIntegrator"
        ],
        "summary": "Удалить gps устройство",
        "parameters": [
          {
            "name": "deviceId",
            "in": "query",
            "description": "Id устройства",
            "schema": {
              "type": "string",
              "nullable": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ок"
          },
          "4XX": {
            "description": "Ошибка запроса",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              }
            }
          }
        }
      }
    },
    "/v1/driver/public/gps/device_info": {
      "get": {
        "tags": [
          "GpsIntegrator"
        ],
        "summary": "Получить gps устройство по device_id",
        "parameters": [
          {
            "name": "deviceId",
            "in": "query",
            "schema": {
              "type": "string",
              "nullable": true
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Ок"
          },
          "401": {
            "description": "Ошибка авторизации"
          },
          "404": {
            "description": "Девайс не найден",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              }
            }
          },
          "4XX": {
            "description": "Ошибка запроса",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              }
            }
          }
        }
      }
    },
    "/v1/driver/public/gps/all_devices": {
      "get": {
        "tags": [
          "GpsIntegrator"
        ],
        "summary": "Получить все gps устройства контакта",
        "parameters": [],
        "responses": {
          "200": {
            "description": "Ок"
          },
          "4XX": {
            "description": "Ошибка запроса",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              }
            }
          }
        }
      }
    },
    "/v1/driver/public/gps/coordinates": {
      "post": {
        "tags": [
          "GpsIntegrator"
        ],
        "summary": "Записать координаты",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/json-patch+json": {
              "schema": {
                "$ref": "#/components/schemas/GpsLocationRequest"
              }
            },
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GpsLocationRequest"
              }
            },
            "text/json": {
              "schema": {
                "$ref": "#/components/schemas/GpsLocationRequest"
              }
            },
            "application/*+json": {
              "schema": {
                "$ref": "#/components/schemas/GpsLocationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ок"
          },
          "4XX": {
            "description": "Ошибка запроса",
            "content": {
              "text/plain": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              },
              "text/json": {
                "schema": {
                  "$ref": "#/components/schemas/SwaggerExampleBaseApiException"
                }
              }
            }
          }
        }
      }
    },
    "/v1.2/orders/carrier/map_route/by_deal": {
      "get": {
        "tags": [
          "АТИ Водитель"
        ],
        "summary": "Получение информации о пройденном маршруте АТИ Водителя",
        "description": "Возвращает информацию о маршруте, пройденном водителем с использованием приложения, а также о начальной, конечной и промежуточных точках маршрута.\nОтвет метода можно использовать, например, для отображения маршрута на карте.",
        "operationId": "Carrier_GetRoutedMapInfo",
        "parameters": [
          {
            "name": "deal_id",
            "x-originalName": "dealId",
            "in": "query",
            "description": "Id Заказа",
            "schema": {
              "type": "string",
              "format": "guid"
            },
            "x-position": 1
          },
          {
            "name": "south_west_lat",
            "x-originalName": "southWestLat",
            "in": "query",
            "description": "Широта юго-запад",
            "schema": {
              "type": "number",
              "format": "double"
            },
            "x-position": 2
          },
          {
            "name": "south_west_lng",
            "x-originalName": "southWestLng",
            "in": "query",
            "description": "Долгота юго-запад",
            "schema": {
              "type": "number",
              "format": "double"
            },
            "x-position": 3
          },
          {
            "name": "north_east_lat",
            "x-originalName": "northEastLat",
            "in": "query",
            "description": "Широта северо-восток",
            "schema": {
              "type": "number",
              "format": "double"
            },
            "x-position": 4
          },
          {
            "name": "north_east_lng",
            "x-originalName": "northEastLng",
            "in": "query",
            "description": "Долгота северо-восток",
            "schema": {
              "type": "number",
              "format": "double"
            },
            "x-position": 5
          },
          {
            "name": "zoom",
            "in": "query",
            "description": "Коэффициент масштабирования",
            "schema": {
              "type": "number",
              "format": "double"
            },
            "x-position": 6
          }
        ],
        "responses": {
          "200": {
            "description": "Информация для карты",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/DealMapView"
                  }
                }
              }
            }
          },
          "4XX": {
            "description": "Ошибка запроса. [Подробнее про ошибки API](https://ati.su/developers/documentation/errors/)",
            "content": {
              "application/json": {
                "schema": {
                  "nullable": true,
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/FinalExceptionModelOfFinalException"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "JWT": []
          }
        ]
      }
    },
    "/v1.2/orders/carrier/map/history": {
      "get": {
        "tags": [
          "АТИ Водитель"
        ],
        "summary": "Получение истории",
        "description": "Массив событий, произошедших в пути следования водителя. Например: поломка, ДТП.",
        "operationId": "Carrier_GetHistory",
        "parameters": [
          {
            "name": "deal_id",
            "x-originalName": "dealId",
            "in": "query",
            "description": "Id Заказа ",
            "schema": {
              "type": "string",
              "format": "guid"
            },
            "x-position": 1
          }
        ],
        "responses": {
          "200": {
            "description": "История выполнения заказа водителем",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/MapHistoryView"
                  }
                }
              }
            }
          },
          "4XX": {
            "description": "Ошибка запроса. [Подробнее про ошибки API](https://ati.su/developers/documentation/errors/)",
            "content": {
              "application/json": {
                "schema": {
                  "nullable": true,
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/FinalExceptionModelOfFinalException"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "JWT": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "AddGpsDeviceRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Название для GPS устройства",
            "nullable": true,
            "example": "Моё gps устройство"
          },
          "description": {
            "type": "string",
            "description": "Описание вашего устройства",
            "nullable": true,
            "example": "Лежит в машине Х000ХY178"
          },
          "device_id": {
            "type": "string",
            "description": "Идентификатор устройства. Если не задан, генерируется самостоятельно",
            "nullable": true,
            "example": "2fb965f2-85e9-4213-90e7-f396e47219e7"
          }
        },
        "additionalProperties": false
      },
      "SwaggerExampleBaseApiException": {
        "type": "object",
        "properties": {
          "error_code": {
            "type": "string",
            "description": "Код ошибки",
            "nullable": true,
            "example": "validation_error"
          },
          "reason": {
            "type": "string",
            "description": "Описание ошибки для разработчиков",
            "nullable": true,
            "example": "Ошибка валидации полей phone и device_id"
          }
        },
        "additionalProperties": false
      },
      "GeoCoordinateRequest": {
        "type": "object",
        "properties": {
          "lon": {
            "type": "number",
            "format": "double"
          },
          "lat": {
            "type": "number",
            "format": "double"
          },
          "location_date": {
            "type": "string",
            "format": "date-time"
          }
        },
        "additionalProperties": false
      },
      "GpsLocationRequest": {
        "type": "object",
        "properties": {
          "deal_id": {
            "type": "string",
            "format": "uuid"
          },
          "device_id": {
            "type": "string",
            "nullable": true
          },
          "coordinates": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/GeoCoordinateRequest"
            },
            "nullable": true
          }
        },
        "additionalProperties": false
      },
      "MapCarType": {
        "type": "integer",
        "description": "",
        "x-enumNames": [
          "Ok",
          "GpsDisabled",
          "GpsSpoof",
          "NoData",
          "PowerSaving",
          "Parking"
        ],
        "enum": [
          0,
          1,
          2,
          3,
          4,
          5
        ]
      },
      "FinalExceptionModelOfFinalException": {
        "type": "object",
        "description": "Модель ошибки",
        "additionalProperties": false,
        "properties": {
          "reason": {
            "type": "string",
            "description": "Причина ошибки"
          },
          "error": {
            "type": "string",
            "description": "Ключ ошибки"
          }
        }
      },
      "DealMapView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "goals": {
            "type": "array",
            "description": "Точки загрузки/разгрузки",
            "items": {
              "$ref": "#/components/schemas/GoalView"
            }
          },
          "traces": {
            "type": "array",
            "description": "Точки траектории движения водителя",
            "items": {
              "$ref": "#/components/schemas/TraceView"
            }
          }
        }
      },
      "GoalView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "longitude": {
            "type": "number",
            "description": "Долгота",
            "format": "double"
          },
          "latitude": {
            "type": "number",
            "description": "Широта",
            "format": "double"
          },
          "events": {
            "type": "array",
            "description": "События",
            "items": {
              "$ref": "#/components/schemas/EventView"
            }
          },
          "ordinal_id": {
            "type": "integer",
            "description": "Номер по порядку",
            "format": "int32"
          },
          "trace": {
            "type": "boolean",
            "description": "Нужно ли прокладывать маршрут для этой точки"
          }
        }
      },
      "EventView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "type": {
            "description": "Тип события\n\n* `0` — Значение по умолчанию\n* `1` — Метаинформация об устройстве. Включает в себя события выключения GPS, подмены GPS координат, выключения телефона.\n* `2` — Информация о статусе заказа (статусы выбираются водителем в приложении)",
            "oneOf": [
              {
                "$ref": "#/components/schemas/TrackerEventType"
              }
            ]
          },
          "tag": {
            "type": "string",
            "description": "Тэг произошедшего события"
          },
          "date": {
            "type": "string",
            "description": "Дата начала",
            "format": "date-time"
          },
          "date_to": {
            "type": "string",
            "description": "Дата окончания",
            "format": "date-time",
            "nullable": true
          },
          "time": {
            "type": "string",
            "description": "Время начала"
          },
          "time_to": {
            "type": "string",
            "description": "Время окончания"
          },
          "location_name": {
            "description": "Информация о местоположении",
            "oneOf": [
              {
                "$ref": "#/components/schemas/LocationNameView"
              }
            ]
          }
        }
      },
      "TrackerEventType": {
        "type": "integer",
        "description": "",
        "x-enumNames": [
          "NotSet",
          "Meta",
          "Status"
        ],
        "enum": [
          0,
          1,
          2
        ]
      },
      "LocationNameView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "country": {
            "type": "string",
            "description": "Страна"
          },
          "region": {
            "type": "string",
            "description": "Регион"
          },
          "city": {
            "type": "string",
            "description": "Город"
          },
          "address": {
            "type": "string",
            "description": "Адрес"
          }
        }
      },
      "TraceView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "car": {
            "description": "Транспортное средство",
            "oneOf": [
              {
                "$ref": "#/components/schemas/CarView"
              }
            ]
          },
          "first_action": {
            "type": "string",
            "description": "Время начала действия",
            "format": "date-time"
          },
          "last_action": {
            "type": "string",
            "description": "Время окончания действия",
            "format": "date-time"
          },
          "points": {
            "type": "array",
            "description": "Точки маршрута",
            "items": {
              "$ref": "#/components/schemas/PointView"
            }
          }
        }
      },
      "CarView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "driver_phone": {
            "type": "string",
            "description": "Номер телефона водителя"
          },
          "car_status": {
            "description": "Тип события\n            \n* `0` — Без происшествий\n* `1` — GPS был выключен\n* `2` — Попытка подделки GPS\n* `3` — Не было данных\n* `4` — Режим энергосбережения\n* `5` — Стоянка",
            "oneOf": [
              {
                "$ref": "#/components/schemas/MapCarType"
              }
            ]
          }
        }
      },
      "PointView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "longitude": {
            "type": "number",
            "description": "Долгота",
            "format": "double"
          },
          "latitude": {
            "type": "number",
            "description": "Широта",
            "format": "double"
          },
          "events": {
            "type": "array",
            "description": "События",
            "items": {
              "$ref": "#/components/schemas/EventView"
            }
          },
          "location_date": {
            "type": "string",
            "description": "Время местоположения",
            "format": "date-time"
          },
          "is_fake": {
            "type": "boolean",
            "description": "Флаг поддельного сигнала GPS"
          },
          "is_disabled": {
            "type": "boolean",
            "description": "Фдаг выключенности GPS"
          },
          "is_no_data": {
            "type": "boolean",
            "description": "Флаг наличия данных"
          },
          "is_power_saving": {
            "type": "boolean",
            "description": "Флаг включенности режима энергосбережения"
          },
          "is_empty_run": {
            "type": "boolean",
            "description": "Флаг холостого хода"
          },
          "is_parking": {
            "type": "boolean",
            "description": "Стоянка"
          }
        }
      },
      "MapHistoryView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "events": {
            "type": "array",
            "description": "События в пути",
            "items": {
              "$ref": "#/components/schemas/UserDealsHistoryView"
            }
          }
        }
      },
      "UserDealsHistoryView": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "date": {
            "type": "string",
            "description": "Время события",
            "format": "date-time"
          },
          "event": {
            "description": "Событие",
            "oneOf": [
              {
                "$ref": "#/components/schemas/EventView"
              }
            ]
          },
          "longitude": {
            "type": "number",
            "description": "Долгота",
            "format": "double"
          },
          "latitude": {
            "type": "number",
            "description": "Широта",
            "format": "double"
          },
          "params": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Authorization: Bearer {authorizationToken}"
      }
    }
  }
}