asg-server/api/swagger.yaml
2024-03-18 21:25:16 +07:00

501 lines
13 KiB
YAML

basePath: /api
definitions:
smsgateway.Device:
properties:
createdAt:
description: Created at (read only)
example: "2020-01-01T00:00:00Z"
type: string
deletedAt:
description: Deleted at (read only)
example: "2020-01-01T00:00:00Z"
type: string
id:
description: ID
example: PyDmBQZZXYmyxMwED8Fzy
type: string
lastSeen:
description: Last seen at (read only)
example: "2020-01-01T00:00:00Z"
type: string
name:
description: Name
example: My Device
type: string
updatedAt:
description: Updated at (read only)
example: "2020-01-01T00:00:00Z"
type: string
type: object
smsgateway.ErrorResponse:
properties:
code:
description: Error code
type: integer
data:
description: Error context
message:
description: Error message
example: An error occurred
type: string
type: object
smsgateway.Message:
properties:
id:
description: ID (if not set - will be generated)
example: PyDmBQZZXYmyxMwED8Fzy
maxLength: 36
type: string
isEncrypted:
description: Is encrypted
example: true
type: boolean
message:
description: Content
example: Hello World!
maxLength: 65535
type: string
phoneNumbers:
description: Recipients (phone numbers)
example:
- "79990001234"
items:
type: string
maxItems: 100
minItems: 1
type: array
simNumber:
description: SIM card number (1-3)
example: 1
maximum: 3
type: integer
ttl:
description: Time to live in seconds (conflicts with `validUntil`)
example: 86400
minimum: 5
type: integer
validUntil:
description: Valid until (conflicts with `ttl`)
example: "2020-01-01T00:00:00Z"
type: string
withDeliveryReport:
description: With delivery report
example: true
type: boolean
required:
- message
- phoneNumbers
type: object
smsgateway.MessageState:
properties:
id:
description: Message ID
example: PyDmBQZZXYmyxMwED8Fzy
maxLength: 36
type: string
isEncrypted:
description: Encrypted
example: false
type: boolean
isHashed:
description: Hashed
example: false
type: boolean
recipients:
description: Recipients states
items:
$ref: '#/definitions/smsgateway.RecipientState'
minItems: 1
type: array
state:
allOf:
- $ref: '#/definitions/smsgateway.ProcessState'
description: State
example: Pending
required:
- recipients
- state
type: object
smsgateway.MobileRegisterRequest:
properties:
name:
description: Device name
example: Android Phone
maxLength: 128
type: string
pushToken:
description: FCM token
example: gHz-T6NezDlOfllr7F-Be
maxLength: 256
type: string
type: object
smsgateway.MobileRegisterResponse:
properties:
id:
description: New device ID
example: QslD_GefqiYV6RQXdkM6V
type: string
login:
description: User login
example: VQ4GII
type: string
password:
description: User password
example: cp2pydvxd2zwpx
type: string
token:
description: Device access token
example: bP0ZdK6rC6hCYZSjzmqhQ
type: string
type: object
smsgateway.MobileUpdateRequest:
properties:
id:
description: ID
example: QslD_GefqiYV6RQXdkM6V
type: string
pushToken:
description: FCM token
example: gHz-T6NezDlOfllr7F-Be
maxLength: 256
type: string
type: object
smsgateway.ProcessState:
enum:
- Pending
- Processed
- Sent
- Delivered
- Failed
type: string
x-enum-comments:
MessageStateDelivered: Delivered
MessageStateFailed: Failed
MessageStatePending: Pending
MessageStateProcessed: Processed (received by device)
MessageStateSent: Sent
x-enum-varnames:
- MessageStatePending
- MessageStateProcessed
- MessageStateSent
- MessageStateDelivered
- MessageStateFailed
smsgateway.PushNotification:
properties:
token:
description: Device FCM token
example: PyDmBQZZXYmyxMwED8Fzy
type: string
required:
- token
type: object
smsgateway.RecipientState:
properties:
error:
description: Error (for `Failed` state)
example: timeout
type: string
phoneNumber:
description: Phone number or first 16 symbols of SHA256 hash
example: "79990001234"
maxLength: 128
minLength: 10
type: string
state:
allOf:
- $ref: '#/definitions/smsgateway.ProcessState'
description: State
example: Pending
required:
- phoneNumber
- state
type: object
host: sms.capcom.me
info:
contact:
email: i@capcom.me
name: Aleksandr Soloshenko
description: End-user authentication key
title: SMS Gateway - API
version: 1.0.0
paths:
/3rdparty/v1/device:
get:
description: Returns list of registered devices
produces:
- application/json
responses:
"200":
description: Device list
schema:
items:
$ref: '#/definitions/smsgateway.Device'
type: array
"400":
description: Invalid request
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
security:
- ApiAuth: []
summary: List devices
tags:
- User
/3rdparty/v1/message:
get:
description: Returns message state by ID
parameters:
- description: Message ID
in: path
name: id
required: true
type: string
produces:
- application/json
responses:
"200":
description: Message state
schema:
$ref: '#/definitions/smsgateway.MessageState'
"400":
description: Invalid request
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
security:
- ApiAuth: []
summary: Get message state
tags:
- User
- Messages
post:
consumes:
- application/json
description: Enqueues message for sending. If ID is not specified, it will be
generated
parameters:
- description: Skip phone validation
in: query
name: skipPhoneValidation
type: boolean
- description: Send message request
in: body
name: request
required: true
schema:
$ref: '#/definitions/smsgateway.Message'
produces:
- application/json
responses:
"202":
description: Message enqueued
headers:
Location:
description: Get message state URL
type: string
schema:
$ref: '#/definitions/smsgateway.MessageState'
"400":
description: Invalid request
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"401":
description: Unauthorized
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
security:
- ApiAuth: []
summary: Enqueue message
tags:
- User
- Messages
/mobile/v1/device:
patch:
consumes:
- application/json
description: Updates push token for device
parameters:
- description: Device update request
in: body
name: request
required: true
schema:
$ref: '#/definitions/smsgateway.MobileUpdateRequest'
responses:
"204":
description: Successfully updated
"400":
description: Invalid request
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"403":
description: Forbidden (wrong device ID)
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
security:
- MobileToken: []
summary: Update device
tags:
- Device
post:
consumes:
- application/json
description: Registers new device and returns credentials
parameters:
- description: Device registration request
in: body
name: request
required: true
schema:
$ref: '#/definitions/smsgateway.MobileRegisterRequest'
produces:
- application/json
responses:
"201":
description: Device registered
schema:
$ref: '#/definitions/smsgateway.MobileRegisterResponse'
"400":
description: Invalid request
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"401":
description: Unauthorized (private mode only)
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"429":
description: Too many requests
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
summary: Register device
tags:
- Device
/mobile/v1/message:
get:
consumes:
- application/json
description: Returns list of pending messages
produces:
- application/json
responses:
"200":
description: List of pending messages
schema:
items:
$ref: '#/definitions/smsgateway.Message'
type: array
"500":
description: Internal server error
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
security:
- MobileToken: []
summary: Get messages for sending
tags:
- Device
- Messages
patch:
consumes:
- application/json
description: Updates message state
parameters:
- description: New message state
in: body
name: request
required: true
schema:
items:
$ref: '#/definitions/smsgateway.MessageState'
type: array
produces:
- application/json
responses:
"204":
description: Successfully updated
"400":
description: Invalid request
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
security:
- MobileToken: []
summary: Update message state
tags:
- Device
- Messages
/upstream/v1/push:
post:
consumes:
- application/json
description: Enqueues notifications for sending to devices
parameters:
- description: Push request
in: body
name: request
required: true
schema:
items:
$ref: '#/definitions/smsgateway.PushNotification'
type: array
produces:
- application/json
responses:
"202":
description: Notification enqueued
"400":
description: Invalid request
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"429":
description: Too many requests
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
"500":
description: Internal server error
schema:
$ref: '#/definitions/smsgateway.ErrorResponse'
summary: Send push notifications
tags:
- Device
- Upstream
schemes:
- https
securityDefinitions:
ApiAuth:
type: basic
MobileToken:
description: Mobile device token
in: header
name: Authorization
type: apiKey
swagger: "2.0"