tsk-35: Add API documentation (#39)

Closes #35

Reviewed-on: phoenix/textsender-api#39
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
This commit is contained in:
phoenix
2025-11-13 21:45:17 +00:00
committed by phoenix
parent 0cd71c5506
commit f69d56f527
14 changed files with 2597 additions and 23 deletions
+568
View File
@@ -0,0 +1,568 @@
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
message.Message:
properties:
content:
type: string
id:
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
/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'
"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"