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
+906
View File
@@ -0,0 +1,906 @@
// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs
import "github.com/swaggo/swag"
const docTemplate = `{
"schemes": {{ marshal .Schemes }},
"swagger": "2.0",
"info": {
"description": "{{escape .Description}}",
"title": "{{.Title}}",
"contact": {},
"version": "{{.Version}}"
},
"host": "{{.Host}}",
"basePath": "{{.BasePath}}",
"paths": {
"/contact": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get a contact record to have a recipient to send a text to (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"contacts"
],
"summary": "Get contact",
"parameters": [
{
"type": "string",
"description": "Contact Id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User Id",
"name": "user_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/contact/new": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Add a contact record to have a recipient to send a text to (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"contacts"
],
"summary": "Add contact",
"parameters": [
{
"description": "Data to add contact",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestAddContact"
}
}
],
"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"
}
}
}
}
},
"/message": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get a message record to have a recipient to send a text to (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"messages"
],
"summary": "Get message",
"parameters": [
{
"type": "string",
"description": "Message Id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User Id",
"name": "user_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/message/new": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Add a message record to send a text to (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"messages"
],
"summary": "Add message",
"parameters": [
{
"description": "Data to add message",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestAddMessage"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/handler.AddMessageResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.AddMessageResponse"
}
}
}
}
},
"/schedule/message": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get a scheduled message (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled messages"
],
"summary": "Get scheduled message",
"parameters": [
{
"type": "string",
"description": "Contact Id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User Id",
"name": "user_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Adds a scheduled message (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled messages"
],
"summary": "Add scheduled message",
"parameters": [
{
"description": "Data to add scheduled message",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestAddScheduledMessage"
}
}
],
"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"
}
}
}
}
},
"/schedule/message/event": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Gets a scheduled message event (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled message events"
],
"summary": "Get scheduled message event",
"parameters": [
{
"type": "string",
"description": "Contact Id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Scheduled Message Id",
"name": "scheduled_message_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Add a scheduled message event (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled message events"
],
"summary": "Add scheduled message event",
"parameters": [
{
"description": "Data to add scheduled message event",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestAddScheduledMessageEvent"
}
}
],
"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"
}
}
}
}
},
"/schedule/message/event/{id}": {
"delete": {
"security": [
{
"BearerAuth": []
}
],
"description": "Deletes a scheduled message event (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled message events"
],
"summary": "Delete scheduled message event",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "scheduled message event Id",
"name": "id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/schedule/message/fetch": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Fetches a scheduled message that is available to be processed (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled messages"
],
"summary": "Fetch scheduled message",
"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"
}
}
}
}
},
"/schedule/message/status/update": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the status of a scheduled message (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"status"
],
"summary": "Update status",
"parameters": [
{
"description": "Used to update scheduled message status",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestScheduledMessageStatus"
}
}
],
"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"
}
}
}
}
}
},
"definitions": {
"contact.Contact": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"phone_number": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"handler.AddContactResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/contact.Contact"
}
},
"message": {
"type": "string"
}
}
},
"handler.AddMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message.Message"
}
},
"message": {
"type": "string"
}
}
},
"handler.AddScheduledMessageEventResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessageEvent"
}
},
"message": {
"type": "string"
}
}
},
"handler.AddScheduledMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessage"
}
},
"message": {
"type": "string"
}
}
},
"handler.DeleteScheduledMessageEventResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessageEvent"
}
},
"message": {
"type": "string"
}
}
},
"handler.FetchNextMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessage"
}
},
"message": {
"type": "string"
}
}
},
"handler.GetContactResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/contact.Contact"
}
},
"message": {
"type": "string"
}
}
},
"handler.GetMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message.Message"
}
},
"message": {
"type": "string"
}
}
},
"handler.GetScheduledMessageEventResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessageEvent"
}
},
"message": {
"type": "string"
}
}
},
"handler.GetScheduledMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessage"
}
},
"message": {
"type": "string"
}
}
},
"handler.RequestAddContact": {
"type": "object",
"properties": {
"phone_number": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"handler.RequestAddMessage": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"handler.RequestAddScheduledMessage": {
"type": "object",
"properties": {
"scheduled": {
"type": "string"
},
"status": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"handler.RequestAddScheduledMessageEvent": {
"type": "object",
"properties": {
"message_id": {
"type": "string"
},
"recipient_id": {
"type": "string"
},
"scheduled_message_id": {
"type": "string"
}
}
},
"handler.RequestScheduledMessageStatus": {
"type": "object",
"properties": {
"scheduled_message_id": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"handler.ScheduledMessageChange": {
"type": "object",
"properties": {
"old_status": {
"type": "string"
},
"scheduled_message": {
"$ref": "#/definitions/scheduling.ScheduledMessage"
}
}
},
"handler.ScheduledMessageStatusResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/handler.ScheduledMessageChange"
}
},
"message": {
"type": "string"
}
}
},
"message.Message": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"id": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"scheduling.ScheduledMessage": {
"type": "object",
"properties": {
"created": {
"type": "string"
},
"id": {
"type": "string"
},
"scheduled": {
"type": "string"
},
"status": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"scheduling.ScheduledMessageEvent": {
"type": "object",
"properties": {
"created": {
"type": "string"
},
"id": {
"type": "string"
},
"message_id": {
"type": "string"
},
"recipient_id": {
"type": "string"
},
"scheduled_message_id": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"BearerAuth": {
"description": "JWT Bearer Token",
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}`
// SwaggerInfo holds exported Swagger Info so clients can modify it
var SwaggerInfo = &swag.Spec{
Version: "1.0",
Host: "localhost:8080",
BasePath: "/api/v1",
Schemes: []string{},
Title: "textsender-api",
Description: "Core API to send text messages",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}
func init() {
swag.Register(SwaggerInfo.InstanceName(), SwaggerInfo)
}
+882
View File
@@ -0,0 +1,882 @@
{
"swagger": "2.0",
"info": {
"description": "Core API to send text messages",
"title": "textsender-api",
"contact": {},
"version": "1.0"
},
"host": "localhost:8080",
"basePath": "/api/v1",
"paths": {
"/contact": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get a contact record to have a recipient to send a text to (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"contacts"
],
"summary": "Get contact",
"parameters": [
{
"type": "string",
"description": "Contact Id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User Id",
"name": "user_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/contact/new": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Add a contact record to have a recipient to send a text to (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"contacts"
],
"summary": "Add contact",
"parameters": [
{
"description": "Data to add contact",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestAddContact"
}
}
],
"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"
}
}
}
}
},
"/message": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get a message record to have a recipient to send a text to (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"messages"
],
"summary": "Get message",
"parameters": [
{
"type": "string",
"description": "Message Id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User Id",
"name": "user_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/message/new": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Add a message record to send a text to (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"messages"
],
"summary": "Add message",
"parameters": [
{
"description": "Data to add message",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestAddMessage"
}
}
],
"responses": {
"201": {
"description": "Created",
"schema": {
"$ref": "#/definitions/handler.AddMessageResponse"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/handler.AddMessageResponse"
}
}
}
}
},
"/schedule/message": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Get a scheduled message (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled messages"
],
"summary": "Get scheduled message",
"parameters": [
{
"type": "string",
"description": "Contact Id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "User Id",
"name": "user_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Adds a scheduled message (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled messages"
],
"summary": "Add scheduled message",
"parameters": [
{
"description": "Data to add scheduled message",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestAddScheduledMessage"
}
}
],
"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"
}
}
}
}
},
"/schedule/message/event": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Gets a scheduled message event (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled message events"
],
"summary": "Get scheduled message event",
"parameters": [
{
"type": "string",
"description": "Contact Id",
"name": "id",
"in": "path",
"required": true
},
{
"type": "string",
"description": "Scheduled Message Id",
"name": "scheduled_message_id",
"in": "path",
"required": true
}
],
"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"
}
}
}
},
"post": {
"security": [
{
"BearerAuth": []
}
],
"description": "Add a scheduled message event (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled message events"
],
"summary": "Add scheduled message event",
"parameters": [
{
"description": "Data to add scheduled message event",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestAddScheduledMessageEvent"
}
}
],
"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"
}
}
}
}
},
"/schedule/message/event/{id}": {
"delete": {
"security": [
{
"BearerAuth": []
}
],
"description": "Deletes a scheduled message event (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled message events"
],
"summary": "Delete scheduled message event",
"parameters": [
{
"type": "string",
"format": "uuid",
"description": "scheduled message event Id",
"name": "id",
"in": "path",
"required": true
}
],
"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"
}
}
}
}
},
"/schedule/message/fetch": {
"get": {
"security": [
{
"BearerAuth": []
}
],
"description": "Fetches a scheduled message that is available to be processed (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"scheduled messages"
],
"summary": "Fetch scheduled message",
"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"
}
}
}
}
},
"/schedule/message/status/update": {
"patch": {
"security": [
{
"BearerAuth": []
}
],
"description": "Update the status of a scheduled message (requires JWT)",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"status"
],
"summary": "Update status",
"parameters": [
{
"description": "Used to update scheduled message status",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/handler.RequestScheduledMessageStatus"
}
}
],
"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"
}
}
}
}
}
},
"definitions": {
"contact.Contact": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"phone_number": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"handler.AddContactResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/contact.Contact"
}
},
"message": {
"type": "string"
}
}
},
"handler.AddMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message.Message"
}
},
"message": {
"type": "string"
}
}
},
"handler.AddScheduledMessageEventResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessageEvent"
}
},
"message": {
"type": "string"
}
}
},
"handler.AddScheduledMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessage"
}
},
"message": {
"type": "string"
}
}
},
"handler.DeleteScheduledMessageEventResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessageEvent"
}
},
"message": {
"type": "string"
}
}
},
"handler.FetchNextMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessage"
}
},
"message": {
"type": "string"
}
}
},
"handler.GetContactResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/contact.Contact"
}
},
"message": {
"type": "string"
}
}
},
"handler.GetMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/message.Message"
}
},
"message": {
"type": "string"
}
}
},
"handler.GetScheduledMessageEventResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessageEvent"
}
},
"message": {
"type": "string"
}
}
},
"handler.GetScheduledMessageResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/scheduling.ScheduledMessage"
}
},
"message": {
"type": "string"
}
}
},
"handler.RequestAddContact": {
"type": "object",
"properties": {
"phone_number": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"handler.RequestAddMessage": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"handler.RequestAddScheduledMessage": {
"type": "object",
"properties": {
"scheduled": {
"type": "string"
},
"status": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"handler.RequestAddScheduledMessageEvent": {
"type": "object",
"properties": {
"message_id": {
"type": "string"
},
"recipient_id": {
"type": "string"
},
"scheduled_message_id": {
"type": "string"
}
}
},
"handler.RequestScheduledMessageStatus": {
"type": "object",
"properties": {
"scheduled_message_id": {
"type": "string"
},
"status": {
"type": "string"
}
}
},
"handler.ScheduledMessageChange": {
"type": "object",
"properties": {
"old_status": {
"type": "string"
},
"scheduled_message": {
"$ref": "#/definitions/scheduling.ScheduledMessage"
}
}
},
"handler.ScheduledMessageStatusResponse": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/handler.ScheduledMessageChange"
}
},
"message": {
"type": "string"
}
}
},
"message.Message": {
"type": "object",
"properties": {
"content": {
"type": "string"
},
"id": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"scheduling.ScheduledMessage": {
"type": "object",
"properties": {
"created": {
"type": "string"
},
"id": {
"type": "string"
},
"scheduled": {
"type": "string"
},
"status": {
"type": "string"
},
"user_id": {
"type": "string"
}
}
},
"scheduling.ScheduledMessageEvent": {
"type": "object",
"properties": {
"created": {
"type": "string"
},
"id": {
"type": "string"
},
"message_id": {
"type": "string"
},
"recipient_id": {
"type": "string"
},
"scheduled_message_id": {
"type": "string"
}
}
}
},
"securityDefinitions": {
"BearerAuth": {
"description": "JWT Bearer Token",
"type": "apiKey",
"name": "Authorization",
"in": "header"
}
}
}
+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"