Closes #51 Reviewed-on: phoenix/textsender-api#52 Co-authored-by: phoenix <kundeng00@pm.me> Co-committed-by: phoenix <kundeng00@pm.me>
641 lines
16 KiB
YAML
641 lines
16 KiB
YAML
basePath: /api/v1
|
|
definitions:
|
|
contact.Contact:
|
|
properties:
|
|
id:
|
|
type: string
|
|
phone_number:
|
|
type: string
|
|
user_id:
|
|
type: string
|
|
type: object
|
|
handler.AddContactResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/contact.Contact'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.AddMessageResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/message.Message'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.AddScheduledMessageEventResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/scheduling.ScheduledMessageEvent'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.AddScheduledMessageResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/scheduling.ScheduledMessage'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.DeleteScheduledMessageEventResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/scheduling.ScheduledMessageEvent'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.FetchNextMessageResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/scheduling.ScheduledMessage'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.GetContactResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/contact.Contact'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.GetMessageResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/message.Message'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.GetScheduledMessageEventResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/scheduling.ScheduledMessageEvent'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.GetScheduledMessageResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/scheduling.ScheduledMessage'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.RequestAddContact:
|
|
properties:
|
|
phone_number:
|
|
type: string
|
|
user_id:
|
|
type: string
|
|
type: object
|
|
handler.RequestAddMessage:
|
|
properties:
|
|
content:
|
|
type: string
|
|
user_id:
|
|
type: string
|
|
type: object
|
|
handler.RequestAddScheduledMessage:
|
|
properties:
|
|
scheduled:
|
|
type: string
|
|
status:
|
|
type: string
|
|
user_id:
|
|
type: string
|
|
type: object
|
|
handler.RequestAddScheduledMessageEvent:
|
|
properties:
|
|
message_id:
|
|
type: string
|
|
recipient_id:
|
|
type: string
|
|
scheduled_message_id:
|
|
type: string
|
|
type: object
|
|
handler.RequestScheduledMessageStatus:
|
|
properties:
|
|
scheduled_message_id:
|
|
type: string
|
|
status:
|
|
type: string
|
|
type: object
|
|
handler.ScheduledMessageChange:
|
|
properties:
|
|
old_status:
|
|
type: string
|
|
scheduled_message:
|
|
$ref: '#/definitions/scheduling.ScheduledMessage'
|
|
type: object
|
|
handler.ScheduledMessageStatusResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/handler.ScheduledMessageChange'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
handler.SendInstantMessageRequest:
|
|
properties:
|
|
contact_ids:
|
|
items:
|
|
type: string
|
|
type: array
|
|
message_id:
|
|
type: string
|
|
user_id:
|
|
type: string
|
|
type: object
|
|
handler.SendInstantMessageResponse:
|
|
properties:
|
|
data:
|
|
items:
|
|
$ref: '#/definitions/message.MessageEventResponse'
|
|
type: array
|
|
message:
|
|
type: string
|
|
type: object
|
|
message.Message:
|
|
properties:
|
|
content:
|
|
type: string
|
|
id:
|
|
type: string
|
|
user_id:
|
|
type: string
|
|
type: object
|
|
message.MessageEventResponse:
|
|
properties:
|
|
id:
|
|
type: string
|
|
response:
|
|
items:
|
|
type: integer
|
|
type: array
|
|
scheduled_message_event_id:
|
|
type: string
|
|
sent:
|
|
type: string
|
|
user_id:
|
|
type: string
|
|
type: object
|
|
scheduling.ScheduledMessage:
|
|
properties:
|
|
created:
|
|
type: string
|
|
id:
|
|
type: string
|
|
scheduled:
|
|
type: string
|
|
status:
|
|
type: string
|
|
user_id:
|
|
type: string
|
|
type: object
|
|
scheduling.ScheduledMessageEvent:
|
|
properties:
|
|
created:
|
|
type: string
|
|
id:
|
|
type: string
|
|
message_id:
|
|
type: string
|
|
recipient_id:
|
|
type: string
|
|
scheduled_message_id:
|
|
type: string
|
|
type: object
|
|
host: localhost:8080
|
|
info:
|
|
contact: {}
|
|
description: Core API to send text messages
|
|
title: textsender-api
|
|
version: "1.0"
|
|
paths:
|
|
/contact:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: Get a contact record to have a recipient to send a text to (requires
|
|
JWT)
|
|
parameters:
|
|
- description: Contact Id
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: User Id
|
|
in: path
|
|
name: user_id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/handler.GetContactResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.GetContactResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.GetContactResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Get contact
|
|
tags:
|
|
- contacts
|
|
/contact/new:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Add a contact record to have a recipient to send a text to (requires
|
|
JWT)
|
|
parameters:
|
|
- description: Data to add contact
|
|
in: body
|
|
name: request
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.RequestAddContact'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/handler.AddContactResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.AddContactResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.AddContactResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Add contact
|
|
tags:
|
|
- contacts
|
|
/instant/message:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Send a message without the constraints of scheduled messages (requires
|
|
JWT)
|
|
parameters:
|
|
- description: Send an instnt message
|
|
in: body
|
|
name: request
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.SendInstantMessageRequest'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/handler.SendInstantMessageResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.SendInstantMessageResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.SendInstantMessageResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Send instant message
|
|
tags:
|
|
- messages
|
|
/message:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: Get a message record to have a recipient to send a text to (requires
|
|
JWT)
|
|
parameters:
|
|
- description: Message Id
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: User Id
|
|
in: path
|
|
name: user_id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/handler.GetMessageResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.GetMessageResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.GetMessageResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Get message
|
|
tags:
|
|
- messages
|
|
/message/new:
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Add a message record to send a text to (requires JWT)
|
|
parameters:
|
|
- description: Data to add message
|
|
in: body
|
|
name: request
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.RequestAddMessage'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/handler.AddMessageResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.AddMessageResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.AddMessageResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Add message
|
|
tags:
|
|
- messages
|
|
/schedule/message:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: Get a scheduled message (requires JWT)
|
|
parameters:
|
|
- description: Contact Id
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: User Id
|
|
in: path
|
|
name: user_id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/handler.GetScheduledMessageResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.GetScheduledMessageResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.GetScheduledMessageResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Get scheduled message
|
|
tags:
|
|
- scheduled messages
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Adds a scheduled message (requires JWT)
|
|
parameters:
|
|
- description: Data to add scheduled message
|
|
in: body
|
|
name: request
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.RequestAddScheduledMessage'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/handler.AddScheduledMessageResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.AddScheduledMessageResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.AddScheduledMessageResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Add scheduled message
|
|
tags:
|
|
- scheduled messages
|
|
/schedule/message/event:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: Gets a scheduled message event (requires JWT)
|
|
parameters:
|
|
- description: Contact Id
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
- description: Scheduled Message Id
|
|
in: path
|
|
name: scheduled_message_id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/handler.GetScheduledMessageEventResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.GetScheduledMessageEventResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.GetScheduledMessageEventResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Get scheduled message event
|
|
tags:
|
|
- scheduled message events
|
|
post:
|
|
consumes:
|
|
- application/json
|
|
description: Add a scheduled message event (requires JWT)
|
|
parameters:
|
|
- description: Data to add scheduled message event
|
|
in: body
|
|
name: request
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.RequestAddScheduledMessageEvent'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/handler.AddScheduledMessageEventResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.AddScheduledMessageEventResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.AddScheduledMessageEventResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Add scheduled message event
|
|
tags:
|
|
- scheduled message events
|
|
/schedule/message/event/{id}:
|
|
delete:
|
|
consumes:
|
|
- application/json
|
|
description: Deletes a scheduled message event (requires JWT)
|
|
parameters:
|
|
- description: scheduled message event Id
|
|
format: uuid
|
|
in: path
|
|
name: id
|
|
required: true
|
|
type: string
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/handler.DeleteScheduledMessageEventResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.DeleteScheduledMessageEventResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.DeleteScheduledMessageEventResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Delete scheduled message event
|
|
tags:
|
|
- scheduled message events
|
|
/schedule/message/fetch:
|
|
get:
|
|
consumes:
|
|
- application/json
|
|
description: Fetches a scheduled message that is available to be processed (requires
|
|
JWT)
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"200":
|
|
description: OK
|
|
schema:
|
|
$ref: '#/definitions/handler.FetchNextMessageResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.FetchNextMessageResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.FetchNextMessageResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Fetch scheduled message
|
|
tags:
|
|
- scheduled messages
|
|
/schedule/message/status/update:
|
|
patch:
|
|
consumes:
|
|
- application/json
|
|
description: Update the status of a scheduled message (requires JWT)
|
|
parameters:
|
|
- description: Used to update scheduled message status
|
|
in: body
|
|
name: request
|
|
required: true
|
|
schema:
|
|
$ref: '#/definitions/handler.RequestScheduledMessageStatus'
|
|
produces:
|
|
- application/json
|
|
responses:
|
|
"201":
|
|
description: Created
|
|
schema:
|
|
$ref: '#/definitions/handler.ScheduledMessageStatusResponse'
|
|
"400":
|
|
description: Bad Request
|
|
schema:
|
|
$ref: '#/definitions/handler.ScheduledMessageStatusResponse'
|
|
"404":
|
|
description: Not Found
|
|
schema:
|
|
$ref: '#/definitions/handler.ScheduledMessageStatusResponse'
|
|
"500":
|
|
description: Internal Server Error
|
|
schema:
|
|
$ref: '#/definitions/handler.ScheduledMessageStatusResponse'
|
|
security:
|
|
- BearerAuth: []
|
|
summary: Update status
|
|
tags:
|
|
- status
|
|
securityDefinitions:
|
|
BearerAuth:
|
|
description: JWT Bearer Token
|
|
in: header
|
|
name: Authorization
|
|
type: apiKey
|
|
swagger: "2.0"
|