mirror of
https://github.com/makayabou/asg-server.git
synced 2026-05-02 17:43:36 +02:00
650 lines
24 KiB
JSON
650 lines
24 KiB
JSON
{
|
||
"schemes": [
|
||
"http"
|
||
],
|
||
"swagger": "2.0",
|
||
"info": {
|
||
"description": "Авторизацию пользователя по логин-паролю",
|
||
"title": "SMS-шлюз - API сервера",
|
||
"contact": {
|
||
"name": "Aleksandr Soloshenko",
|
||
"email": "capcom@soft-c.ru"
|
||
},
|
||
"version": "1.0.0"
|
||
},
|
||
"host": "localhost:3000",
|
||
"basePath": "/api",
|
||
"paths": {
|
||
"/3rdparty/v1/device": {
|
||
"get": {
|
||
"security": [
|
||
{
|
||
"ApiAuth": []
|
||
}
|
||
],
|
||
"description": "Возвращает все устройства пользователя",
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Пользователь",
|
||
"Устройства"
|
||
],
|
||
"summary": "Получить устройства",
|
||
"responses": {
|
||
"200": {
|
||
"description": "Состояние сообщения",
|
||
"schema": {
|
||
"type": "array",
|
||
"items": {
|
||
"$ref": "#/definitions/smsgateway.Device"
|
||
}
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Некорректный запрос",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"401": {
|
||
"description": "Ошибка авторизации",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Внутренняя ошибка сервера",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/3rdparty/v1/message": {
|
||
"get": {
|
||
"security": [
|
||
{
|
||
"ApiAuth": []
|
||
}
|
||
],
|
||
"description": "Возвращает состояние сообщения по его ID",
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Пользователь",
|
||
"Сообщения"
|
||
],
|
||
"summary": "Получить состояние сообщения",
|
||
"parameters": [
|
||
{
|
||
"type": "string",
|
||
"description": "ИД сообщения",
|
||
"name": "id",
|
||
"in": "path",
|
||
"required": true
|
||
}
|
||
],
|
||
"responses": {
|
||
"200": {
|
||
"description": "Состояние сообщения",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.MessageState"
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Некорректный запрос",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"401": {
|
||
"description": "Ошибка авторизации",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Внутренняя ошибка сервера",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"post": {
|
||
"security": [
|
||
{
|
||
"ApiAuth": []
|
||
}
|
||
],
|
||
"description": "Ставит сообщение в очередь на отправку. Если идентификатор не указан, то он будет сгенерирован автоматически",
|
||
"consumes": [
|
||
"application/json"
|
||
],
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Пользователь",
|
||
"Сообщения"
|
||
],
|
||
"summary": "Поставить сообщение в очередь",
|
||
"parameters": [
|
||
{
|
||
"type": "boolean",
|
||
"description": "Пропустить проверку номеров телефона",
|
||
"name": "skipPhoneValidation",
|
||
"in": "query"
|
||
},
|
||
{
|
||
"description": "Сообщение",
|
||
"name": "request",
|
||
"in": "body",
|
||
"required": true,
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.Message"
|
||
}
|
||
}
|
||
],
|
||
"responses": {
|
||
"202": {
|
||
"description": "Сообщение поставлено в очередь",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.MessageState"
|
||
},
|
||
"headers": {
|
||
"Location": {
|
||
"type": "string",
|
||
"description": "URL для получения состояния сообщения"
|
||
}
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Некорректный запрос",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"401": {
|
||
"description": "Ошибка авторизации",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Внутренняя ошибка сервера",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/mobile/v1/device": {
|
||
"post": {
|
||
"description": "Регистрирует устройство на сервере, генерируя авторизационные данные",
|
||
"consumes": [
|
||
"application/json"
|
||
],
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Устройство",
|
||
"Регистрация"
|
||
],
|
||
"summary": "Регистрация устройства",
|
||
"parameters": [
|
||
{
|
||
"description": "Запрос на регистрацию",
|
||
"name": "request",
|
||
"in": "body",
|
||
"required": true,
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.MobileRegisterRequest"
|
||
}
|
||
}
|
||
],
|
||
"responses": {
|
||
"201": {
|
||
"description": "Успешная регистрация",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.MobileRegisterResponse"
|
||
}
|
||
},
|
||
"400": {
|
||
"description": "Некорректный запрос",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Внутренняя ошибка сервера",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"patch": {
|
||
"security": [
|
||
{
|
||
"MobileToken": []
|
||
}
|
||
],
|
||
"description": "Обновляет push-токен устройства",
|
||
"consumes": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Устройство"
|
||
],
|
||
"summary": "Обновление устройства",
|
||
"parameters": [
|
||
{
|
||
"description": "Запрос на обновление",
|
||
"name": "request",
|
||
"in": "body",
|
||
"required": true,
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.MobileUpdateRequest"
|
||
}
|
||
}
|
||
],
|
||
"responses": {
|
||
"204": {
|
||
"description": "Успешное обновление"
|
||
},
|
||
"400": {
|
||
"description": "Некорректный запрос",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"403": {
|
||
"description": "Операция запрещена",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Внутренняя ошибка сервера",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"/mobile/v1/message": {
|
||
"get": {
|
||
"security": [
|
||
{
|
||
"MobileToken": []
|
||
}
|
||
],
|
||
"description": "Возвращает список сообщений, требующих отправки",
|
||
"consumes": [
|
||
"application/json"
|
||
],
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Устройство",
|
||
"Сообщения"
|
||
],
|
||
"summary": "Получить сообщения для отправки",
|
||
"responses": {
|
||
"200": {
|
||
"description": "Список сообщений",
|
||
"schema": {
|
||
"type": "array",
|
||
"items": {
|
||
"$ref": "#/definitions/smsgateway.Message"
|
||
}
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Внутренняя ошибка сервера",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"patch": {
|
||
"security": [
|
||
{
|
||
"MobileToken": []
|
||
}
|
||
],
|
||
"description": "Обновляет состояние сообщений. Состояние обновляется индивидуально для каждого сообщения, игнорируя ошибки",
|
||
"consumes": [
|
||
"application/json"
|
||
],
|
||
"produces": [
|
||
"application/json"
|
||
],
|
||
"tags": [
|
||
"Устройство",
|
||
"Сообщения"
|
||
],
|
||
"summary": "Обновить состояние сообщений",
|
||
"parameters": [
|
||
{
|
||
"description": "Состояние сообщений",
|
||
"name": "request",
|
||
"in": "body",
|
||
"required": true,
|
||
"schema": {
|
||
"type": "array",
|
||
"items": {
|
||
"$ref": "#/definitions/smsgateway.MessageState"
|
||
}
|
||
}
|
||
}
|
||
],
|
||
"responses": {
|
||
"204": {
|
||
"description": "Обновление выполнено"
|
||
},
|
||
"400": {
|
||
"description": "Некорректный запрос",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
},
|
||
"500": {
|
||
"description": "Внутренняя ошибка сервера",
|
||
"schema": {
|
||
"$ref": "#/definitions/smsgateway.ErrorResponse"
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"definitions": {
|
||
"smsgateway.Device": {
|
||
"type": "object",
|
||
"properties": {
|
||
"createdAt": {
|
||
"description": "Дата создания",
|
||
"type": "string",
|
||
"example": "2020-01-01T00:00:00Z"
|
||
},
|
||
"deletedAt": {
|
||
"description": "Дата удаления",
|
||
"type": "string",
|
||
"example": "2020-01-01T00:00:00Z"
|
||
},
|
||
"id": {
|
||
"description": "Идентификатор",
|
||
"type": "string",
|
||
"example": "PyDmBQZZXYmyxMwED8Fzy"
|
||
},
|
||
"lastSeen": {
|
||
"description": "Последняя активность",
|
||
"type": "string",
|
||
"example": "2020-01-01T00:00:00Z"
|
||
},
|
||
"name": {
|
||
"description": "Название устройства",
|
||
"type": "string",
|
||
"example": "My Device"
|
||
},
|
||
"updatedAt": {
|
||
"description": "Дата обновления",
|
||
"type": "string",
|
||
"example": "2020-01-01T00:00:00Z"
|
||
}
|
||
}
|
||
},
|
||
"smsgateway.ErrorResponse": {
|
||
"type": "object",
|
||
"properties": {
|
||
"code": {
|
||
"description": "код ошибки",
|
||
"type": "integer"
|
||
},
|
||
"data": {
|
||
"description": "контекст"
|
||
},
|
||
"message": {
|
||
"description": "текст ошибки",
|
||
"type": "string",
|
||
"example": "Произошла ошибка"
|
||
}
|
||
}
|
||
},
|
||
"smsgateway.Message": {
|
||
"type": "object",
|
||
"required": [
|
||
"message",
|
||
"phoneNumbers"
|
||
],
|
||
"properties": {
|
||
"id": {
|
||
"description": "Идентификатор",
|
||
"type": "string",
|
||
"maxLength": 36,
|
||
"example": "PyDmBQZZXYmyxMwED8Fzy"
|
||
},
|
||
"isEncrypted": {
|
||
"description": "Зашифровано",
|
||
"type": "boolean",
|
||
"example": true
|
||
},
|
||
"message": {
|
||
"description": "Текст сообщения",
|
||
"type": "string",
|
||
"maxLength": 65535,
|
||
"example": "Hello World!"
|
||
},
|
||
"phoneNumbers": {
|
||
"description": "Получатели",
|
||
"type": "array",
|
||
"maxItems": 100,
|
||
"minItems": 1,
|
||
"items": {
|
||
"type": "string"
|
||
},
|
||
"example": [
|
||
"79990001234"
|
||
]
|
||
},
|
||
"simNumber": {
|
||
"description": "Номер сим-карты",
|
||
"type": "integer",
|
||
"maximum": 3,
|
||
"example": 1
|
||
},
|
||
"ttl": {
|
||
"description": "Время жизни сообщения в секундах",
|
||
"type": "integer",
|
||
"minimum": 5,
|
||
"example": 86400
|
||
},
|
||
"validUntil": {
|
||
"description": "Время окончания жизни сообщения",
|
||
"type": "string",
|
||
"example": "2020-01-01T00:00:00Z"
|
||
},
|
||
"withDeliveryReport": {
|
||
"description": "Запрашивать отчет о доставке",
|
||
"type": "boolean",
|
||
"example": true
|
||
}
|
||
}
|
||
},
|
||
"smsgateway.MessageState": {
|
||
"type": "object",
|
||
"required": [
|
||
"recipients",
|
||
"state"
|
||
],
|
||
"properties": {
|
||
"id": {
|
||
"description": "Идентификатор",
|
||
"type": "string",
|
||
"maxLength": 36,
|
||
"example": "PyDmBQZZXYmyxMwED8Fzy"
|
||
},
|
||
"isEncrypted": {
|
||
"description": "Зашифровано",
|
||
"type": "boolean",
|
||
"example": false
|
||
},
|
||
"isHashed": {
|
||
"description": "Хэшировано",
|
||
"type": "boolean",
|
||
"example": false
|
||
},
|
||
"recipients": {
|
||
"description": "Детализация состояния по получателям",
|
||
"type": "array",
|
||
"minItems": 1,
|
||
"items": {
|
||
"$ref": "#/definitions/smsgateway.RecipientState"
|
||
}
|
||
},
|
||
"state": {
|
||
"description": "Состояние",
|
||
"allOf": [
|
||
{
|
||
"$ref": "#/definitions/smsgateway.ProcessState"
|
||
}
|
||
],
|
||
"example": "Pending"
|
||
}
|
||
}
|
||
},
|
||
"smsgateway.MobileRegisterRequest": {
|
||
"type": "object",
|
||
"properties": {
|
||
"name": {
|
||
"description": "Имя устройства",
|
||
"type": "string",
|
||
"maxLength": 128,
|
||
"example": "Android Phone"
|
||
},
|
||
"pushToken": {
|
||
"description": "Токен для отправки PUSH-уведомлений",
|
||
"type": "string",
|
||
"maxLength": 256,
|
||
"example": "gHz-T6NezDlOfllr7F-Be"
|
||
}
|
||
}
|
||
},
|
||
"smsgateway.MobileRegisterResponse": {
|
||
"type": "object",
|
||
"properties": {
|
||
"id": {
|
||
"description": "Идентификатор",
|
||
"type": "string",
|
||
"example": "QslD_GefqiYV6RQXdkM6V"
|
||
},
|
||
"login": {
|
||
"description": "Логин пользователя",
|
||
"type": "string",
|
||
"example": "VQ4GII"
|
||
},
|
||
"password": {
|
||
"description": "Пароль пользователя",
|
||
"type": "string",
|
||
"example": "cp2pydvxd2zwpx"
|
||
},
|
||
"token": {
|
||
"description": "Ключ доступа",
|
||
"type": "string",
|
||
"example": "bP0ZdK6rC6hCYZSjzmqhQ"
|
||
}
|
||
}
|
||
},
|
||
"smsgateway.MobileUpdateRequest": {
|
||
"type": "object",
|
||
"properties": {
|
||
"id": {
|
||
"description": "Идентификатор, если есть",
|
||
"type": "string",
|
||
"example": "QslD_GefqiYV6RQXdkM6V"
|
||
},
|
||
"pushToken": {
|
||
"description": "Токен для отправки PUSH-уведомлений",
|
||
"type": "string",
|
||
"maxLength": 256,
|
||
"example": "gHz-T6NezDlOfllr7F-Be"
|
||
}
|
||
}
|
||
},
|
||
"smsgateway.ProcessState": {
|
||
"type": "string",
|
||
"enum": [
|
||
"Pending",
|
||
"Processed",
|
||
"Sent",
|
||
"Delivered",
|
||
"Failed"
|
||
],
|
||
"x-enum-comments": {
|
||
"MessageStateDelivered": "Доставлено",
|
||
"MessageStateFailed": "Ошибка",
|
||
"MessageStatePending": "В ожидании",
|
||
"MessageStateProcessed": "Обработано",
|
||
"MessageStateSent": "Отправлено"
|
||
},
|
||
"x-enum-varnames": [
|
||
"MessageStatePending",
|
||
"MessageStateProcessed",
|
||
"MessageStateSent",
|
||
"MessageStateDelivered",
|
||
"MessageStateFailed"
|
||
]
|
||
},
|
||
"smsgateway.RecipientState": {
|
||
"type": "object",
|
||
"required": [
|
||
"phoneNumber",
|
||
"state"
|
||
],
|
||
"properties": {
|
||
"error": {
|
||
"description": "Ошибка",
|
||
"type": "string",
|
||
"example": "timeout"
|
||
},
|
||
"phoneNumber": {
|
||
"description": "Номер телефона или первые 16 символов SHA256",
|
||
"type": "string",
|
||
"maxLength": 128,
|
||
"minLength": 10,
|
||
"example": "79990001234"
|
||
},
|
||
"state": {
|
||
"description": "Состояние",
|
||
"allOf": [
|
||
{
|
||
"$ref": "#/definitions/smsgateway.ProcessState"
|
||
}
|
||
],
|
||
"example": "Pending"
|
||
}
|
||
}
|
||
}
|
||
},
|
||
"securityDefinitions": {
|
||
"ApiAuth": {
|
||
"type": "basic"
|
||
},
|
||
"MobileToken": {
|
||
"description": "Авторизацию устройства по токену",
|
||
"type": "apiKey",
|
||
"name": "Authorization",
|
||
"in": "header"
|
||
}
|
||
}
|
||
} |