{
  "openapi": "3.0.0",
  "info": {
    "title": "api/orders/files",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "/"
    },
    {
      "url": "https://api.ati.su"
    }
  ],
  "security": [
    {
      "BearerAuth": []
    }
  ],
  "paths": {
    "/v1.2/orders/files/info": {
      "post": {
        "tags": [
          "Файлы в заказах"
        ],
        "summary": "Добавление данных файла к заказу",
        "description": "Позволяет добавить данные файла к заказу",
        "operationId": "Files_SaveFileInfo",
        "requestBody": {
          "x-name": "file",
          "description": "Данные файла",
          "content": {
            "application/json": {
              "schema": {
                "nullable": true,
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/DealFileInfoDto3"
                  }
                ]
              }
            }
          },
          "x-position": 1
        },
        "responses": {
          "200": {
            "description": "Успешное добавление",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/DealFileView"
                }
              }
            }
          },
          "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/files/{fileId}": {
      "delete": {
        "tags": [
          "Файлы в заказах"
        ],
        "summary": "Удаление приложенного файла заказа",
        "operationId": "Files_RemoveFile",
        "parameters": [
          {
            "name": "fileId",
            "in": "path",
            "required": true,
            "description": "Id файла",
            "schema": {
              "type": "string",
              "format": "guid"
            },
            "x-position": 1
          }
        ],
        "responses": {
          "200": {
            "description": "Успешное удаление"
          },
          "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/files/{fileId}/access": {
      "put": {
        "tags": [
          "Файлы в заказах"
        ],
        "summary": "Настройка доступа к файлу заказа",
        "operationId": "Files_ChangeAccess",
        "parameters": [
          {
            "name": "fileId",
            "in": "path",
            "required": true,
            "description": "Id файла",
            "schema": {
              "type": "string",
              "format": "guid"
            },
            "x-position": 1
          }
        ],
        "requestBody": {
          "x-name": "dto",
          "description": "Настройка доступа",
          "content": {
            "application/json": {
              "schema": {
                "nullable": true,
                "oneOf": [
                  {
                    "$ref": "#/components/schemas/DealFileAccessDto"
                  }
                ]
              }
            }
          },
          "x-position": 2
        },
        "responses": {
          "200": {
            "description": "Успешное изменение доступа",
            "content": {
              "application/octet-stream": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "description": "Ошибка запроса. [Подробнее про ошибки API](https://ati.su/developers/documentation/errors/)",
            "content": {
              "application/json": {
                "schema": {
                  "nullable": true,
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/FinalExceptionModelOfFinalException"
                    }
                  ]
                }
              }
            }
          }
        },
        "security": [
          {
            "JWT": []
          }
        ]
      }
    }
  },
  "components": {
    "schemas": {
      "DealFileAccess": {
        "type": "integer",
        "description": "Доступ к файлу\n            \n* `0` — только загрузивший файл\n* `1` — обе стороны\n* `2` — загрузивший файл и водитель\n* `3` — доступен обеим сторонам и водителю",
        "x-enumFlags": true,
        "x-enumNames": [
          "OnlyYou",
          "SharedWithCounterparty",
          "SharedWithAtiTrucker",
          "SharedWithAtiTruckerAndCounterparty"
        ],
        "enum": [
          0,
          1,
          2,
          3
        ]
      },
      "DealFileSourceTypes": {
        "type": "integer",
        "description": "Источник файла\n            \n* `0` — Загружен в заказ\n* `1` — Скопирован из груза\n* `2` — Скопирован из данных о водителе\n* `3` — Скопироване из данных о грузовике\n* `4` — Скопирован из данных о прицепе\n* `5` — Скопирован из данных о полуприцепе\n* `6` — Скопирован из данных о тягаче\n* `7` — Загружен для Ати-водителя\n* `8` — Загружен из приложения АТИ-водитель\n* `9` — Загружен из Gallifrey (Временные окна)",
        "x-enumNames": [
          "SimpleLoader",
          "Load",
          "Driver",
          "Truck",
          "Trailer",
          "SemiTrailer",
          "Tractor",
          "AtiTruckerPopupLoader",
          "FromAtiDriver",
          "FromGallifrey"
        ],
        "enum": [
          0,
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9
        ]
      },
      "DealFileSourceFileTypes": {
        "type": "integer",
        "description": "Тип загруженного файла\n            \n* `0` — Обычный файл\n* `1` — Скан водительского удостоверения\n* `2` — Скан гражданского паспорта водителя\n* `3` — Скан ПТС\n* `4` — Скан пластикового ПТС\n* `5` — Фото ТС\n* `8` - Скан договора о безвоздмездном пользовании",
        "x-enumNames": [
          "None",
          "DriverLicense",
          "DriverPassport",
          "TruckTechPassport",
          "TruckPlasticTechPassport",
          "TruckPhoto",
          "FreeUse"
        ],
        "enum": [
          0,
          1,
          2,
          3,
          4,
          5,
          8
        ]
      },
      "DealFileType": {
        "type": "integer",
        "description": "Тип файла\n            \n* `0` — Другой документ\n* `1` — Товарно-транспортная накладная\n* `2` — Товарная накладная\n* `3` — Транспортная накладная\n* `4` — Накладная\n* `5` — Счет-фактура\n* `6` — Счет на оплату\n* `7` — Платежное поручение\n* `8` — Акт выполненных работ\n* `9` — Заявка\n* `10` — Заявка к договору\n* `11` — Заказ\n* `12` — Договор\n* `13` — Доп. соглашение к договору\n* `14` — Доверенность\n* `15` — Поручение экспедитору\n* `16` — Информационное письмо\n* `17` — Документ о происшествии с грузом/ТС",
        "x-enumNames": [
          "OtherDoc",
          "ConsignmentNote",
          "PackingList",
          "WayBill",
          "WayBillGeneral",
          "Invoice",
          "InvoiceForPayment",
          "PaymentOrder",
          "CertificateOfCompletion",
          "Request",
          "RequestForOrder",
          "Order",
          "Contract",
          "SupplementaryAgreement",
          "Dealership",
          "Assignment",
          "InfoLetter",
          "AccidentAct"
        ],
        "enum": [
          0,
          1,
          2,
          3,
          4,
          5,
          6,
          7,
          8,
          9,
          10,
          11,
          12,
          13,
          14,
          15,
          16,
          17
        ]
      },
      "DealFileView": {
        "type": "object",
        "description": "Файлы заказа",
        "additionalProperties": false,
        "properties": {
          "id": {
            "type": "string",
            "description": "Id файла",
            "format": "guid",
            "nullable": true
          },
          "storage_file_id": {
            "type": "string",
            "description": "Id файла в хранилище",
            "nullable": true
          },
          "access": {
            "description": "Доступ к файлу\n            \n* `0` — только загрузивший файл\n* `1` — обе стороны\n* `2` — загрузивший файл и водитель\n* `3` — доступен обеим сторонам и водителю",
            "nullable": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealFileAccess"
              }
            ]
          },
          "add_date": {
            "type": "string",
            "description": "Время загрузки файла",
            "format": "date-time",
            "nullable": true
          },
          "deal_id": {
            "type": "string",
            "description": "Id связанного Заказа",
            "format": "guid"
          },
          "is_counterparty_file": {
            "type": "boolean",
            "description": "Файл контрагента",
            "nullable": true
          },
          "file_name": {
            "type": "string",
            "description": "Имя файла",
            "nullable": true
          },
          "size": {
            "type": "integer",
            "description": "Размер файла",
            "format": "int32",
            "nullable": true
          },
          "link": {
            "type": "string",
            "description": "Ссылка на файл",
            "nullable": true
          },
          "file_id": {
            "type": "string",
            "description": "ID файла",
            "nullable": true
          },
          "source_type": {
            "description": "Источник файла\n            \n* `0` — Загружен в заказ\n* `1` — Скопирован из груза\n* `2` — Скопирован из данных о водителе\n* `3` — Скопироване из данных о грузовике\n* `4` — Скопирован из данных о прицепе\n* `5` — Скопирован из данных о полуприцепе\n* `6` — Скопирован из данных о тягаче\n* `7` — Загружен для Ати-водителя",
            "nullable": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealFileSourceTypes"
              }
            ]
          },
          "source_file_type": {
            "description": "Тип загруженного файла\n            \n* `0` — Обычный файл\n* `1` — Водительское удостоверение\n* `2` — Паспорт водителя\n* `3` — Техпаспорт ТС\n* `4` — Пластик\n* `5` — Фото ТС",
            "nullable": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealFileSourceFileTypes"
              }
            ]
          },
          "file_type": {
            "description": "Тип файла\n            \n* `0` — Другой документ\n* `1` — Товарно-транспортная накладная\n* `2` — Товарная накладная\n* `3` — Транспортная накладная\n* `4` — Накладная\n* `5` — Счет-фактура\n* `6` — Счет на оплату\n* `7` — Платежное поручение\n* `8` — Акт выполненных работ\n* `9` — Заявка\n* `10` — Заявка (к договору)\n* `11` — Заказ\n* `12` — Договор\n* `13` — Доп. соглашение (к договору)\n* `14` — Доверенность\n* `15` — Поручение экспедитору\n* `16` — Информационное письмо\n* `17` — Документ о происшествии с грузом/ТС",
            "nullable": true,
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealFileType"
              }
            ]
          },
          "timeslots_warehouse_ids": {
            "type": "array",
            "description": "Список складов с Временными окнами с доступом  к файлу",
            "nullable": true,
            "items": {
              "type": "integer",
              "format": "int32"
            }
          }
        }
      },
      "FinalExceptionModelOfFinalException": {
        "type": "object",
        "description": "Модель ошибки",
        "additionalProperties": false,
        "properties": {
          "reason": {
            "type": "string",
            "description": "Причина ошибки"
          },
          "error": {
            "type": "string",
            "description": "Ключ ошибки"
          }
        }
      },
      "DealFileAccessDto": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "access": {
            "description": "Доступ к файлу",
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealFileAccess"
              }
            ]
          },
          "timeslots_warehouse_ids": {
            "type": "array",
            "description": "Список складов с Временными окнами с доступом к файлу",
            "items": {
              "type": "integer",
              "format": "int32"
            }
          }
        }
      },
      "DealFileInfoDto3": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "deal_id": {
            "type": "string",
            "description": "ID заказа",
            "format": "guid"
          },
          "file_info": {
            "description": "Данные о загруженном файле",
            "oneOf": [
              {
                "$ref": "#/components/schemas/FileInfoDto3"
              }
            ]
          },
          "file_type": {
            "description": "Тип файла",
            "oneOf": [
              {
                "$ref": "#/components/schemas/DealFileType"
              }
            ]
          }
        }
      },
      "FileInfoDto3": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "file_id": {
            "type": "string",
            "description": "Id файла"
          },
          "file_name": {
            "type": "string",
            "description": "Название файла"
          }
        }
      }
    },
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Authorization: Bearer {authorizationToken}"
      }
    }
  }
}