asg-server/api/swagger.yaml
2024-02-11 20:55:51 +07:00

391 lines
12 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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