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:
@@ -33,6 +33,18 @@ func NewContactHandler(str store.ContactStore) *ContactHandler {
|
||||
return &ContactHandler{ContactStore: str}
|
||||
}
|
||||
|
||||
// AddContact godoc
|
||||
// @Summary Add contact
|
||||
// @Description Add a contact record to have a recipient to send a text to (requires JWT)
|
||||
// @Tags contacts
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Security BearerAuth
|
||||
// @Param request body RequestAddContact true "Data to add contact"
|
||||
// @Success 201 {object} AddContactResponse
|
||||
// @Failure 400 {object} AddContactResponse
|
||||
// @Failure 500 {object} AddContactResponse
|
||||
// @Router /contact/new [post]
|
||||
func (c *ContactHandler) AddContact(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodPost {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
@@ -76,6 +88,19 @@ func (c *ContactHandler) AddContact(w http.ResponseWriter, r *http.Request) {
|
||||
RespondWithJSON(w, statusCode, &resp)
|
||||
}
|
||||
|
||||
// GetContact godoc
|
||||
// @Summary Get contact
|
||||
// @Description Get a contact record to have a recipient to send a text to (requires JWT)
|
||||
// @Tags contacts
|
||||
// @Accept json
|
||||
// @Produce json
|
||||
// @Param id path string true "Contact Id"
|
||||
// @Param user_id path string true "User Id"
|
||||
// @Security BearerAuth
|
||||
// @Success 200 {object} GetContactResponse
|
||||
// @Failure 400 {object} GetContactResponse
|
||||
// @Failure 500 {object} GetContactResponse
|
||||
// @Router /contact [get]
|
||||
func (c *ContactHandler) GetContact(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method != http.MethodGet {
|
||||
fmt.Println("Method:", r.Method)
|
||||
@@ -83,6 +108,7 @@ func (c *ContactHandler) GetContact(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
// One or the other
|
||||
var id, userId uuid.UUID
|
||||
queryParams := r.URL.Query()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user