Skip to content

Send and receive SMS messages using your Android phone programmatically via a simple HTTP API

Fix response

Acho Arnold4e5c7f049de6
diff --git a/api/pkg/handlers/handler.go b/api/pkg/handlers/handler.go
index 10475cc2..6e49b238 100644
--- a/api/pkg/handlers/handler.go
+++ b/api/pkg/handlers/handler.go
@@ -57,6 +57,13 @@ func (h *handler) responseNotFound(c *fiber.Ctx, message string) error {
})
}
+func (h *handler) responseNoContent(c *fiber.Ctx, message string) error {
+ return c.Status(fiber.StatusNoContent).JSON(fiber.Map{
+ "status": "success",
+ "message": message,
+ })
+}
+
func (h *handler) responseOK(c *fiber.Ctx, message string, data interface{}) error {
return c.Status(fiber.StatusOK).JSON(fiber.Map{
"status": "success",
diff --git a/api/pkg/handlers/phone_handler.go b/api/pkg/handlers/phone_handler.go
index 1700873d..47e4ed8d 100644
--- a/api/pkg/handlers/phone_handler.go
+++ b/api/pkg/handlers/phone_handler.go
@@ -140,7 +140,7 @@ func (h *PhoneHandler) Upsert(c *fiber.Ctx) error {
// @Accept json
// @Produce json
// @Param phoneID path string true "ID of the phone" default(32343a19-da5e-4b1b-a767-3298a73703ca)
-// @Success 204 {object}
+// @Success 204 {object} responses.NoContent
// @Failure 400 {object} responses.BadRequest
// @Failure 401 {object} responses.Unauthorized
// @Failure 422 {object} responses.UnprocessableEntity
diff --git a/api/pkg/responses/response.go b/api/pkg/responses/response.go
index 0f8e94fc..29d28d2d 100644
--- a/api/pkg/responses/response.go
+++ b/api/pkg/responses/response.go
@@ -37,3 +37,9 @@ type Unauthorized struct {
Message string `json:"message" example:"You are not authorized to carry out this request."`
Data string `json:"data" example:"Make sure your API key is set in the [X-API-Key] header in the request"`
}
+
+// NoContent is the response when status code is 204
+type NoContent struct {
+ Status string `json:"status" example:"success"`
+ Message string `json:"message" example:"phone deleted successfully"`
+}