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:
@@ -14,7 +14,6 @@ import (
|
||||
|
||||
type RequestAddScheduledMessage struct {
|
||||
Scheduled time.Time `json:"scheduled"`
|
||||
Created time.Time `json:"created"`
|
||||
Status string `json:"status"`
|
||||
UserId uuid.UUID `json:"user_id"`
|
||||
}
|
||||
@@ -42,6 +41,18 @@ func NewScheduledMessageHandler(str store.ScheduledMessageStore) *ScheduledMessa
|
||||
return &ScheduledMessageHandler{ScheduledMessageStore: str}
|
||||
}
|
||||
|
||||
// AddScheduledMessage godoc
|
||||
// @Summary Add scheduled message
|
||||
// @Description Adds a scheduled message (requires JWT)
|
||||
// @Tags scheduled messages
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param request body RequestAddScheduledMessage true "Data to add scheduled message"
|
||||
// @Success 201 {object} AddScheduledMessageResponse
|
||||
// @Failure 400 {object} AddScheduledMessageResponse
|
||||
// @Failure 500 {object} AddScheduledMessageResponse
|
||||
// @Router /schedule/message [post]
|
||||
func (s *ScheduledMessageHandler) AddScheduledMessage(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
@@ -93,6 +104,19 @@ func (s *ScheduledMessageHandler) AddScheduledMessage(w http.ResponseWriter, r *
|
||||
RespondWithJSON(w, statusCode, &resp)
|
||||
}
|
||||
|
||||
// GetScheduledMessage godoc
|
||||
// @Summary Get scheduled message
|
||||
// @Description Get a scheduled message (requires JWT)
|
||||
// @Tags scheduled messages
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param id path string true "Contact Id"
|
||||
// @Param user_id path string true "User Id"
|
||||
// @Success 200 {object} GetScheduledMessageResponse
|
||||
// @Failure 400 {object} GetScheduledMessageResponse
|
||||
// @Failure 500 {object} GetScheduledMessageResponse
|
||||
// @Router /schedule/message [get]
|
||||
func (s *ScheduledMessageHandler) GetScheduledMessage(w http.ResponseWriter, r *http.Request) {
|
||||
var id, userId uuid.UUID
|
||||
|
||||
@@ -157,6 +181,17 @@ func (s *ScheduledMessageHandler) GetScheduledMessage(w http.ResponseWriter, r *
|
||||
RespondWithJSON(w, statusCode, &resp)
|
||||
}
|
||||
|
||||
// FetchNextMessage godoc
|
||||
// @Summary Fetch scheduled message
|
||||
// @Description Fetches a scheduled message that is available to be processed (requires JWT)
|
||||
// @Tags scheduled messages
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} FetchNextMessageResponse
|
||||
// @Failure 400 {object} FetchNextMessageResponse
|
||||
// @Failure 500 {object} FetchNextMessageResponse
|
||||
// @Router /schedule/message/fetch [get]
|
||||
func (s *ScheduledMessageHandler) FetchNextMessage(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
var resp FetchNextMessageResponse
|
||||
|
||||
Reference in New Issue
Block a user