@@ -40,30 +40,29 @@ func NewPhoneAPIKeyHandler(
4040
4141// RegisterRoutes registers the routes for the PhoneAPIKeyHandler
4242func (h * PhoneAPIKeyHandler ) RegisterRoutes (app * fiber.App , middlewares ... fiber.Handler ) {
43- router := app .Group ("/v1/api-keys/" )
44- router .Get ("/" , h .computeRoute (middlewares , h .Index )... )
45- router .Post ("/" , h .computeRoute (middlewares , h .Store )... )
46- router .Delete ("/:phoneAPIKeyID" , h .computeRoute (middlewares , h .Delete )... )
47- router .Delete ("/:phoneAPIKeyID/phones/:phoneID" , h .computeRoute (middlewares , h .DeletePhone )... )
43+ router := app .Group ("/v1/phone- api-keys/" )
44+ router .Get ("/" , h .computeRoute (middlewares , h .index )... )
45+ router .Post ("/" , h .computeRoute (middlewares , h .store )... )
46+ router .Delete ("/:phoneAPIKeyID" , h .computeRoute (middlewares , h .delete )... )
47+ router .Delete ("/:phoneAPIKeyID/phones/:phoneID" , h .computeRoute (middlewares , h .deletePhone )... )
4848}
4949
50- // Index returns the phone API Keys of a user
5150// @Summary Get the phone API keys of a user
5251// @Description Get list phone API keys which a user has registered on the httpSMS application
5352// @Security ApiKeyAuth
5453// @Tags PhoneAPIKeys
5554// @Accept json
5655// @Produce json
57- // @Param skip query int false "number of heartbeats to skip" minimum(0)
58- // @Param query query string false "filter api keys with name containing query"
59- // @Param limit query int false "number of phone api keys to return" minimum(1) maximum(100)
56+ // @Param skip query int false "number of phone api keys to skip" minimum(0)
57+ // @Param query query string false "filter phone api keys with name containing query"
58+ // @Param limit query int false "number of phone api keys to return" minimum(1) maximum(100)
6059// @Success 200 {object} responses.PhoneAPIKeysResponse
6160// @Failure 400 {object} responses.BadRequest
6261// @Failure 401 {object} responses.Unauthorized
6362// @Failure 422 {object} responses.UnprocessableEntity
6463// @Failure 500 {object} responses.InternalServerError
6564// @Router /api-keys [get]
66- func (h * PhoneAPIKeyHandler ) Index (c * fiber.Ctx ) error {
65+ func (h * PhoneAPIKeyHandler ) index (c * fiber.Ctx ) error {
6766 ctx , span , ctxLogger := h .tracer .StartFromFiberCtxWithLogger (c , h .logger )
6867 defer span .End ()
6968
@@ -90,7 +89,6 @@ func (h *PhoneAPIKeyHandler) Index(c *fiber.Ctx) error {
9089 return h .responseOK (c , fmt .Sprintf ("fetched %d phone API %s" , len (apiKeys ), h .pluralize ("key" , len (apiKeys ))), apiKeys )
9190}
9291
93- // Store a new Phone API key
9492// @Summary Store phone API key
9593// @Description Creates a new phone API key which can be used to log in to the httpSMS app on your Android phone
9694// @Security ApiKeyAuth
@@ -104,7 +102,7 @@ func (h *PhoneAPIKeyHandler) Index(c *fiber.Ctx) error {
104102// @Failure 422 {object} responses.UnprocessableEntity
105103// @Failure 500 {object} responses.InternalServerError
106104// @Router /api-keys [post]
107- func (h * PhoneAPIKeyHandler ) Store (c * fiber.Ctx ) error {
105+ func (h * PhoneAPIKeyHandler ) store (c * fiber.Ctx ) error {
108106 ctx , span , ctxLogger := h .tracer .StartFromFiberCtxWithLogger (c , h .logger )
109107 defer span .End ()
110108
@@ -121,32 +119,31 @@ func (h *PhoneAPIKeyHandler) Store(c *fiber.Ctx) error {
121119 return h .responseUnprocessableEntity (c , errors , "validation errors while updating phones" )
122120 }
123121
124- phone , err := h .service .Create (ctx , h .userFromContext (c ), request .Name )
122+ phoneAPIKey , err := h .service .Create (ctx , h .userFromContext (c ), request .Name )
125123 if err != nil {
126124 msg := fmt .Sprintf ("cannot update phones with params [%+#v]" , request )
127125 ctxLogger .Error (stacktrace .Propagate (err , msg ))
128126 return h .responseInternalServerError (c )
129127 }
130128
131- return h .responseOK (c , "phone updated successfully" , phone )
129+ return h .responseOK (c , "phone API key created successfully" , phoneAPIKey )
132130}
133131
134- // Delete a phone API Key
135132// @Summary Delete a phone API key from the database.
136133// @Description Delete a phone API Key from the database and cannot be used for authentication anymore.
137134// @Security ApiKeyAuth
138135// @Tags PhoneAPIKeys
139136// @Accept json
140137// @Produce json
141- // @Param phoneAPIKeyID path string true "ID of the phone API key" default(32343a19-da5e-4b1b-a767-3298a73703ca)
138+ // @Param phoneAPIKeyID path string true "ID of the phone API key" default(32343a19-da5e-4b1b-a767-3298a73703ca)
142139// @Success 204 {object} responses.NoContent
143140// @Failure 400 {object} responses.BadRequest
144141// @Failure 401 {object} responses.Unauthorized
145142// @Failure 404 {object} responses.NotFound
146143// @Failure 422 {object} responses.UnprocessableEntity
147144// @Failure 500 {object} responses.InternalServerError
148145// @Router /api-keys/{phoneAPIKeyID} [delete]
149- func (h * PhoneAPIKeyHandler ) Delete (c * fiber.Ctx ) error {
146+ func (h * PhoneAPIKeyHandler ) delete (c * fiber.Ctx ) error {
150147 ctx , span , ctxLogger := h .tracer .StartFromFiberCtxWithLogger (c , h .logger )
151148 defer span .End ()
152149
@@ -171,7 +168,6 @@ func (h *PhoneAPIKeyHandler) Delete(c *fiber.Ctx) error {
171168 return h .responseNoContent (c , "phone API key deleted successfully" )
172169}
173170
174- // DeletePhone removes a phone from a phone API key
175171// @Summary Remove the association of a phone from the phone API key.
176172// @Description You will need to login again to the httpSMS app on your Android phone with a new phone API key.
177173// @Security ApiKeyAuth
@@ -187,7 +183,7 @@ func (h *PhoneAPIKeyHandler) Delete(c *fiber.Ctx) error {
187183// @Failure 422 {object} responses.UnprocessableEntity
188184// @Failure 500 {object} responses.InternalServerError
189185// @Router /api-keys/{phoneAPIKeyID}/phones/{phoneID} [delete]
190- func (h * PhoneAPIKeyHandler ) DeletePhone (c * fiber.Ctx ) error {
186+ func (h * PhoneAPIKeyHandler ) deletePhone (c * fiber.Ctx ) error {
191187 ctx , span , ctxLogger := h .tracer .StartFromFiberCtxWithLogger (c , h .logger )
192188 defer span .End ()
193189
0 commit comments