{"openapi":"3.0.0","info":{"description":"Сервис для работы с 1С:Фреш.\nСоздание счетов, чтение статусов этих счетов.\nСоздано на основе\n[Технического задания](https://livedune.atlassian.net/wiki/spaces/LIV/pages/2551611442/1C)\n","version":"1.0.1","title":"1С Fresh Service","contact":{"email":"ruslan.ri@livedune.ru"}},"servers":[{"description":"SwaggerHub API Auto Mocking","url":"https://virtserver.swaggerhub.com/RUSLANRI/1c_fresh_module/1.0.1"},{"url":"https://1c-fresh.swagger.io/v1.0.1"}],"tags":[{"name":"invoice","description":"Эндпоинты Модуля (поставщика)","externalDocs":{"description":"Более подробно в ТЗ","url":"https://livedune.atlassian.net/wiki/spaces/LIV/pages/2551611442/1C#%D0%9F%D1%80%D0%B8%D0%BA%D0%BB%D0%B0%D0%B4%D0%BD%D0%BE%D0%B9-%D1%83%D1%80%D0%BE%D0%B2%D0%B5%D0%BD%D1%8C"}},{"name":"telemetry","description":"Телеметрия сервиса"},{"name":"webhook","description":"Веб-хуки Сервиса (потребителя)"},{"name":"queue","description":"Управление очередями в 1С модуле."},{"name":"search","description":"Поиск контрагента в 1С"}],"paths":{"/-/healthy":{"get":{"tags":["telemetry"],"summary":"Телеметрия сервиса овечает 200 ОК, если все в порядке в 1С и можно с ней работать.","operationId":"metricsHealth","responses":{"200":{"description":"OK","content":{"text/html":{"schema":{"type":"string","example":"OK"}}}},"500":{"$ref":"#/components/responses/MetricsError"}}}},"/invoice/create":{"post":{"tags":["invoice"],"summary":"Создание нового счета в 1С","operationId":"addInvoice","requestBody":{"$ref":"#/components/requestBodies/Invoice"},"responses":{"200":{"$ref":"#/components/responses/Invoice"},"405":{"$ref":"#/components/responses/ValidationError"}},"security":[{"livedune_auth":[]}]}},"/invoice/update":{"post":{"tags":["invoice"],"summary":"Обновление статуса у счета (только в тестовом режиме)","operationId":"updateInvoice","requestBody":{"$ref":"#/components/requestBodies/Status"},"responses":{"200":{"$ref":"#/components/responses/Invoice"},"405":{"$ref":"#/components/responses/ValidationError"}},"security":[{"livedune_auth":[]}]}},"/invoice/file/{id}":{"get":{"tags":["invoice"],"summary":"Получение счета в PDF формате","operationId":"getInvoiceFileById","parameters":[{"name":"id","in":"path","description":"ID счета Livedune","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"PDF файл","content":{"application/pdf":{"schema":{"type":"string","format":"base64"}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}}}},"/invoice/info/{id}":{"get":{"tags":["invoice"],"summary":"Поиск счета по ID в 1С:Фреш","description":"Возвращает данные по счету со всеми реквизитами","operationId":"getInvoiceById","parameters":[{"name":"id","in":"path","description":"ID счета Livedune","required":true,"schema":{"type":"integer","format":"int64"}}],"responses":{"200":{"description":"Если счет есть в 1С, то она должна вернуть нам данные счета","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"400":{"$ref":"#/components/responses/ClientError"},"401":{"$ref":"#/components/responses/UnauthorizedError"},"404":{"$ref":"#/components/responses/NotFoundError"}},"security":[{"livedune_auth":[]}]}},"/search/{inn}":{"get":{"tags":["search"],"summary":"Поиск контрагента по ИНН в 1С","operationId":"searchInn","parameters":[{"name":"inn","in":"path","description":"ИНН компании","required":true,"schema":{"type":"number"}}],"responses":{"200":{"$ref":"#/components/responses/Company"},"404":{"$ref":"#/components/responses/NotFoundError"}}}},"/webhook/invoice/update":{"post":{"tags":["webhook"],"summary":"Когда в 1С изменяется статуса счета, то в Livedune приходит уведомление","operationId":"webhookUpdate","requestBody":{"$ref":"#/components/requestBodies/Status"},"responses":{"200":{"description":"Сервис успешно принял данные","content":{"text/html":{"schema":{"type":"string","example":"OK"}}}},"500":{"description":"Ошибка сервиса. Нужна повторная отправка.","content":{"text/html":{"schema":{"type":"string","example":"OK"}}}},"404":{"description":"Счет не найден","content":{"text/html":{"schema":{"type":"string","example":"OK"}}}},"401":{"description":"Ошибка валидации счета.","content":{"text/html":{"schema":{"type":"string","example":"OK"}}}}}}},"/queue/start":{"post":{"tags":["queue"],"summary":"Запускает очередь отправки уведомлений","responses":{"200":{"description":"OK","content":{"text/html":{"schema":{"type":"string","example":"OK"}}}}}}},"/queue/stop":{"post":{"tags":["queue"],"summary":"Останавливает очередь","responses":{"200":{"description":"OK","content":{"text/html":{"schema":{"type":"string","example":"OK"}}}}}}},"/queue/stat":{"get":{"tags":["queue"],"summary":"Текущее состояние очереди","responses":{"200":{"description":"OK","content":{"text/html":{"schema":{"type":"string","example":"online"}}}}}}}},"components":{"schemas":{"Customer":{"type":"object","description":"В ответ от 1С должны прийти полные реквизиты клиента.","required":["inn","kpp","email"],"properties":{"inn":{"type":"string"},"kpp":{"type":"string"},"name":{"type":"string","description":"Заполняется клиентом, может содержать опечатки, кавычки или не полное название."},"email":{"type":"string"}},"example":{"inn":7705905548,"kpp":772501001,"name":"ООО \"ВАРИТУН СВЕРНЫЙ ЗАПАДНЫЙ ОКРУГ\"","email":"company@livedune.com"}},"Status":{"type":"object","description":"Cтатус счета и сумма","required":["id","status","total"],"properties":{"id":{"type":"integer","description":"Livedune ID"},"status":{"type":"string","enum":["new","paid","partly","return","failure"]},"total":{"type":"number","description":"Итоговая сумма. Для частичной оплаты всегда нужно знать какая сумма уже внесена."}}},"Product":{"type":"object","description":"Услуга, которую приобретает клиент. Тип услуги в type, кол-во (чего-либо) в amount, месяцы (для тарифа) в month. Из этого складывается стоимость, которая передается в total","required":["name","price","currency","discount","amount","month","total"],"properties":{"name":{"type":"string","description":"Название услуги в Livedune. Обычно это название передается в платежную систему при оплате клиентом наличными."},"operation":{"type":"integer","enum":[4,5,6,7,8],"description":"4 - Оплата тарифа, 5 - Покупка кредитов на удаление, 6 - Покупка проверки блогеров, 7 - Покупка аккаунтов на дашбоард, 8 - Покупка доп. сотрудников"},"amount":{"type":"integer"},"month":{"type":"integer"},"price":{"type":"number"},"discount":{"type":"number"},"total":{"type":"number"},"currecy":{"type":"string","enum":["RUB","KZT","USD"]}},"example":{"name":"Блогер","amount":2,"month":6,"price":2000.0,"discount":10,"total":1800.0,"currency":"RUB"}},"Invoice":{"type":"object","description":"Cчет на оплату от 1С.","required":["id","guid","number","file_name","created","total","customer"],"properties":{"id":{"type":"integer","description":"Идентификатор счета Livedune. Храним в 1С, чтоб его было проще найти в Livedune","example":1740},"guid":{"type":"string","description":"Идентификатор счета 1С","example":"df406400-8b3e-11ec-80a8-fa163e889793"},"env":{"type":"string","enum":["testing","production"],"example":"testing"},"number":{"type":"string","description":"Номер счета в 1С. Уникальный в пределах года.","example":"0000-000349"},"created":{"type":"string","description":"Дата и время создания счета в 1С передается в формате 'Y-m-d H:i:s'","example":"2022-03-15 12:08:54"},"file_name":{"type":"string","example":"No_334_03_2023_2.pdf"},"total":{"type":"number","description":"Итого. Для валидации правильности создания счета."},"currency":{"type":"string","enum":["RUB","KZT","USD"]},"customer":{"$ref":"#/components/schemas/Customer"},"status":{"type":"string","enum":["new","paid","partly","canceled"]}}},"Env":{"type":"string","enum":["testing","production"],"example":"testing","description":"Режим работы или счета. Если это тестовый счет, то должно стоять testing."},"Company":{"description":"Информация о контрагенте в 1С","type":"object","properties":{"name":{"type":"string","description":"Короткое название компании"},"fullname":{"type":"string","description":"Полное название"},"inn":{"type":"number"},"kpp":{"type":"number"},"address":{"type":"string"}},"required":["name","inn","address"],"example":{"name":"ООО \"ДЮНА\"","fullname":"Общество с ограниченной ответственностью \"ДЮНА\"","inn":2311243031,"kpp":231101001,"address":"350005, Краснодарский Край, г. Краснодар, ул. Им. Героя Сарабеева В.и., д. 5"}},"Error":{"type":"object","properties":{"code":{"type":"string"},"message":{"type":"string"}},"required":["code","message"],"example":{"code":1001,"message":"Создание счета не доступно"}}},"requestBodies":{"Invoice":{"description":"Сначала он создается в Livedune, затем передаем POST-запрос в 1С и ждем ответ","content":{"application/json":{"schema":{"type":"object","required":["id","total","currency","customer","products","env"],"properties":{"id":{"type":"integer","description":"Идентификатор счета Livedune","example":1740},"env":{"$ref":"#/components/schemas/Env"},"total":{"type":"number","description":"Общая стоимость. Итого.","example":36000.0},"currency":{"type":"string","example":"RUB"},"comment":{"type":"string","example":"Нужно поправить адрес компании на 350005, Краснодарский Край, г. Краснодар, ул. Им. Героя Сарабеева В.и., д. 5"},"customer":{"$ref":"#/components/schemas/Customer"},"products":{"type":"array","items":{"$ref":"#/components/schemas/Product"},"example":[{"name":"Тариф: Бизнес, 10 аккаунтов, 2 сотрудника","operation":4,"months":12,"amount":1,"price":3000,"discount":20},{"name":"Покупка 2 сотрудников","operation":8,"months":12,"amount":2,"price":300,"discount":0}]}}}}},"required":true},"Status":{"description":"Передача статуса счета в Livedune когда он поменяется в 1С","content":{"application/json":{"schema":{"type":"object","properties":{"id":{"type":"integer","description":"Идентификатор счета Livedune"},"guid":{"type":"string"},"total":{"type":"number"},"currency":{"type":"string","enum":["RUB"]},"env":{"type":"string"},"status":{"$ref":"#/components/schemas/Status"}},"example":{"id":152045780,"guid":"df406400-8b3e-11ec-80a8-fa163e889793","total":10500.0,"currency":"RUB","env":"testing","status":"partly"}}}}}},"securitySchemes":{"livedune_auth":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}},"responses":{"Invoice":{"description":"Данные счета из 1С","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invoice"}}}},"Company":{"description":"Информация о контрагенте в 1С","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Company"}}}},"UnauthorizedError":{"description":"Токен доступа отсутствует или недействителен"},"ClientError":{"description":"Предоставлен неверный ID"},"NotFoundError":{"description":"Счет не найден"},"ValidationError":{"description":"Проверка вызвала исключение"},"MetricsError":{"description":"Ошибки метрики живучести","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}}}}}