Skip to content

Commit fa8e6f5

Browse files
committed
[docs] minor improvements to the API docs
1 parent 18dabe5 commit fa8e6f5

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

internal/sms-gateway/handlers/messages/3rdparty.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,21 @@ type ThirdPartyController struct {
4040
}
4141

4242
// @Summary Enqueue message
43-
// @Description Enqueues message for sending. If multiple devices are registered, it will be sent via a random one
43+
// @Description Enqueues a message for sending. If `deviceId` is set, the specified device is used; otherwise a random registered device is chosen.
4444
// @Security ApiAuth
4545
// @Tags User, Messages
4646
// @Accept json
4747
// @Produce json
4848
// @Param skipPhoneValidation query bool false "Skip phone validation"
49-
// @Param deviceActiveWithin query int false "Filter devices active within the specified number of hours" default(0)
49+
// @Param deviceActiveWithin query int false "Filter devices active within the specified number of hours" default(0) minimum(0)
5050
// @Param request body smsgateway.Message true "Send message request"
5151
// @Success 202 {object} smsgateway.GetMessageResponse "Message enqueued"
5252
// @Failure 400 {object} smsgateway.ErrorResponse "Invalid request"
5353
// @Failure 401 {object} smsgateway.ErrorResponse "Unauthorized"
5454
// @Failure 409 {object} smsgateway.ErrorResponse "Message with such ID already exists"
5555
// @Failure 500 {object} smsgateway.ErrorResponse "Internal server error"
5656
// @Header 202 {string} Location "Get message state URL"
57-
// @Router /3rdparty/v1/messages [post]
57+
// @Router /3rdparty/v1/messages [post]
5858
//
5959
// Enqueue message
6060
func (h *ThirdPartyController) post(user models.User, c *fiber.Ctx) error {
@@ -179,7 +179,7 @@ func (h *ThirdPartyController) post(user models.User, c *fiber.Ctx) error {
179179
// @Failure 400 {object} smsgateway.ErrorResponse "Invalid request"
180180
// @Failure 401 {object} smsgateway.ErrorResponse "Unauthorized"
181181
// @Failure 500 {object} smsgateway.ErrorResponse "Internal server error"
182-
// @Router /3rdparty/v1/messages/{id} [get]
182+
// @Router /3rdparty/v1/messages/{id} [get]
183183
//
184184
// Get message state
185185
func (h *ThirdPartyController) get(user models.User, c *fiber.Ctx) error {
@@ -216,7 +216,7 @@ func (h *ThirdPartyController) get(user models.User, c *fiber.Ctx) error {
216216
// @Failure 400 {object} smsgateway.ErrorResponse "Invalid request"
217217
// @Failure 401 {object} smsgateway.ErrorResponse "Unauthorized"
218218
// @Failure 500 {object} smsgateway.ErrorResponse "Internal server error"
219-
// @Router /3rdparty/v1/inbox/export [post]
219+
// @Router /3rdparty/v1/inbox/export [post]
220220
//
221221
// Export inbox
222222
func (h *ThirdPartyController) postInboxExport(user models.User, c *fiber.Ctx) error {

internal/sms-gateway/handlers/mobile.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,12 +195,13 @@ func (h *mobileHandler) patchMessage(device models.Device, c *fiber.Ctx) error {
195195
return fiber.NewError(fiber.StatusBadRequest, err.Error())
196196
}
197197

198-
var messageState messages.MessageStateIn
199198
for _, v := range req {
200-
messageState.ID = v.ID
201-
messageState.State = messages.ProcessingState(v.State)
202-
messageState.Recipients = v.Recipients
203-
messageState.States = v.States
199+
messageState := messages.MessageStateIn{
200+
ID: v.ID,
201+
State: messages.ProcessingState(v.State),
202+
Recipients: v.Recipients,
203+
States: v.States,
204+
}
204205

205206
err := h.messagesSvc.UpdateState(device.ID, messageState)
206207
if err != nil && !errors.Is(err, messages.ErrMessageNotFound) {

pkg/swagger/docs/swagger.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@
271271
"ApiAuth": []
272272
}
273273
],
274-
"description": "Enqueues message for sending. If multiple devices are registered, it will be sent via a random one",
274+
"description": "Enqueues a message for sending. If `deviceId` is set, the specified device is used; otherwise a random registered device is chosen.",
275275
"consumes": [
276276
"application/json"
277277
],
@@ -291,6 +291,7 @@
291291
"in": "query"
292292
},
293293
{
294+
"minimum": 0,
294295
"type": "integer",
295296
"default": 0,
296297
"description": "Filter devices active within the specified number of hours",

pkg/swagger/docs/swagger.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -893,8 +893,8 @@ paths:
893893
post:
894894
consumes:
895895
- application/json
896-
description: Enqueues message for sending. If multiple devices are registered,
897-
it will be sent via a random one
896+
description: Enqueues a message for sending. If `deviceId` is set, the specified
897+
device is used; otherwise a random registered device is chosen.
898898
parameters:
899899
- description: Skip phone validation
900900
in: query
@@ -903,6 +903,7 @@ paths:
903903
- default: 0
904904
description: Filter devices active within the specified number of hours
905905
in: query
906+
minimum: 0
906907
name: deviceActiveWithin
907908
type: integer
908909
- description: Send message request

0 commit comments

Comments
 (0)