diff --git a/src/app/dto/adopt.dto.go b/src/app/dto/adopt.dto.go deleted file mode 100644 index 56ecaef..0000000 --- a/src/app/dto/adopt.dto.go +++ /dev/null @@ -1,15 +0,0 @@ -package dto - -type AdoptDto struct { - UserID string `json:"user_id" validate:"required"` - PetID string `json:"pet_id" validate:"required"` -} - -type AdoptByRequest struct { - UserID string `json:"user_id" validate:"required"` - PetID string `json:"pet_id" validate:"required"` -} - -type AdoptByResponse struct { - Success bool `json:"success"` -} diff --git a/src/app/dto/pet.dto.go b/src/app/dto/pet.dto.go index 0d7c5b1..d6b7ce3 100644 --- a/src/app/dto/pet.dto.go +++ b/src/app/dto/pet.dto.go @@ -35,10 +35,10 @@ type CreatePetRequest struct { Species string `json:"species" validate:"required"` Name string `json:"name" validate:"required"` Birthdate string `json:"birthdate" validate:"required"` - Gender pet.Gender `json:"gender" validate:"required" example:"male"` + Gender pet.Gender `json:"gender" validate:"required" example:"1"` Habit string `json:"habit" validate:"required"` Caption string `json:"caption"` - Status pet.Status `json:"status" validate:"required" example:"findhome"` + Status pet.Status `json:"status" validate:"required" example:"1"` IsSterile *bool `json:"is_sterile" validate:"required"` IsVaccinated *bool `json:"is_vaccinated" validate:"required"` IsVisible *bool `json:"is_visible" validate:"required"` @@ -58,6 +58,15 @@ type ChangeViewPetResponse struct { Success bool `json:"success" validate:"required"` } +type AdoptByRequest struct { + UserID string `json:"user_id" validate:"required"` + PetID string `json:"pet_id" validate:"required"` +} + +type AdoptByResponse struct { + Success bool `json:"success"` +} + type UpdatePetRequest struct { Type string `json:"type"` Species string `json:"species"` diff --git a/src/app/handler/pet/pet.handler.go b/src/app/handler/pet/pet.handler.go index 7dae48c..3e5b91f 100644 --- a/src/app/handler/pet/pet.handler.go +++ b/src/app/handler/pet/pet.handler.go @@ -23,13 +23,13 @@ func NewHandler(service petSvc.Service, imageService imageSvc.Service, validate return &Handler{service, imageService, validate} } -// FindAll is a function that return all pets in database -// @Summary find all pets -// @Description Return the data of pets if successfully -// @Tags auth +// FindAll is a function that returns all pets in database +// @Summary finds all pets +// @Description Returns the data of pets if successful +// @Tags pet // @Accept json // @Produce json -// @Success 200 {object} dto.PetDto +// @Success 200 {object} []dto.PetResponse // @Failure 500 {object} dto.ResponseInternalErr "Internal service error" // @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" // @Router /v1/pets/ [get] @@ -48,14 +48,14 @@ func (h *Handler) FindAll(c router.IContext) { return } -// FindOne is a function that return all pet in database -// @Summary find one pet -// @Description Return the data of pets if successfully +// FindOne is a function that returns a pet by id in database +// @Summary finds one pet +// @Description Returns the data of a pet if successful // @Param id path string true "pet id" -// @Tags auth +// @Tags pet // @Accept json // @Produce json -// @Success 200 {object} dto.PetDto +// @Success 200 {object} dto.PetResponse // @Failure 400 {object} dto.ResponseBadRequestErr "Invalid request body" // @Failure 500 {object} dto.ResponseInternalErr "Internal service error" // @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" @@ -85,14 +85,14 @@ func (h *Handler) FindOne(c router.IContext) { return } -// Create is a function that create pet in database -// @Summary create pet -// @Description Return the data of pet if successfully +// Create is a function that creates pet in database +// @Summary creates pet +// @Description Returns the data of pet if successful // @Param create body dto.CreatePetRequest true "pet dto" -// @Tags auth +// @Tags pet // @Accept json // @Produce json -// @Success 201 {object} dto.PetDto +// @Success 201 {object} dto.PetResponse // @Failure 400 {object} dto.ResponseBadRequestErr "Invalid request body" // @Failure 500 {object} dto.ResponseInternalErr "Internal service error" // @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" @@ -136,15 +136,15 @@ func (h *Handler) Create(c router.IContext) { return } -// Update is a function that update pet in database -// @Summary update pet -// @Description Return the data of pet if successfully +// Update is a function that updates pet in database +// @Summary updates pet +// @Description Returns the data of pet if successfully // @Param update body dto.UpdatePetRequest true "update pet dto" -// @Param id path stirng true "pet id" -// @Tags auth +// @Param id path string true "pet id" +// @Tags pet // @Accept json // @Produce json -// @Success 201 {object} dto.PetDto +// @Success 201 {object} dto.PetResponse // @Failure 400 {object} dto.ResponseBadRequestErr "Invalid request body" // @Failure 500 {object} dto.ResponseInternalErr "Internal service error" // @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" @@ -199,19 +199,19 @@ func (h *Handler) Update(c router.IContext) { return } -// Change is a function that change visibility of pet in database -// @Summary change view pet -// @Description Return the status true of pet if successfully else false -// @Param change view body dto.ChangeViewPetRequest true "change view pet dto" -// @Param id string true "pet id" -// @Tags auth +// ChangeView is a function that changes visibility of pet in database +// @Summary changes pet's public visiblility +// @Description Returns successful status if pet's IsVisible is successfully changed +// @Param changeViewDto body dto.ChangeViewPetRequest true "changeView pet dto" +// @Param id path string true "pet id" +// @Tags pet // @Accept json // @Produce json -// @Success 201 {object} bool +// @Success 201 {object} dto.ChangeViewPetResponse // @Failure 400 {object} dto.ResponseBadRequestErr "Invalid request body" // @Failure 500 {object} dto.ResponseInternalErr "Internal service error" // @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" -// @Router /v1/pets/ [put] +// @Router /v1/pets/{id}/visible [put] func (h *Handler) ChangeView(c router.IContext) { id, err := c.Param("id") if err != nil { @@ -262,14 +262,14 @@ func (h *Handler) ChangeView(c router.IContext) { return } -// Delete is a function that delete pet in database -// @Summary delete pet -// @Description Return the status true of pet if successfully else false -// @Param id string true "pet id" -// @Tags auth +// Delete is a function that deletes pet in database +// @Summary deletes pet +// @Description Returns successful status if pet is successfully deleted +// @Param id path string true "pet id" +// @Tags pet // @Accept json // @Produce json -// @Success 201 {object} bool +// @Success 201 {object} dto.DeleteResponse // @Failure 400 {object} dto.ResponseBadRequestErr "Invalid request body" // @Failure 500 {object} dto.ResponseInternalErr "Internal service error" // @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" @@ -300,15 +300,14 @@ func (h *Handler) Delete(c router.IContext) { } // Adopt is a function that handles the adoption of a pet in the database -// @Summary Adopt a pet +// @Summary Change a pet's adoptBy status // @Description Return true if the pet is successfully adopted +// @Param adoptDto body dto.AdoptByRequest true "adopt pet dto" // @Param id path string true "Pet ID" -// @Param user_id body string true "User ID" -// @Param pet_id body string true "Pet ID" // @Tags pet // @Accept json // @Produce json -// @Success 201 {object} bool +// @Success 201 {object} dto.AdoptByResponse // @Failure 400 {object} dto.ResponseBadRequestErr "Invalid request body" // @Failure 500 {object} dto.ResponseInternalErr "Internal service error" // @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" diff --git a/src/docs/docs.go b/src/docs/docs.go index de72062..ee19d5a 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -1,5 +1,4 @@ -// Code generated by swaggo/swag. DO NOT EDIT. - +// Package docs Code generated by swaggo/swag. DO NOT EDIT package docs import "github.com/swaggo/swag" @@ -234,9 +233,9 @@ const docTemplate = `{ } } }, - "/v1/pet/": { + "/v1/pets/": { "get": { - "description": "Return the data of pets if successfully", + "description": "Returns the data of pets if successful", "consumes": [ "application/json" ], @@ -244,17 +243,103 @@ const docTemplate = `{ "application/json" ], "tags": [ - "auth" + "pet" + ], + "summary": "finds all pets", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PetResponse" + } + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + }, + "delete": { + "description": "Returns successful status if pet is successfully deleted", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "deletes pet", + "parameters": [ + { + "type": "string", + "description": "pet id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.DeleteResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + } + }, + "/v1/pets/create": { + "post": { + "description": "Returns the data of pet if successful", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" ], - "summary": "find all pets", + "summary": "creates pet", "parameters": [ { "description": "pet dto", - "name": "signup", + "name": "create", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.PetDto" + "$ref": "#/definitions/dto.CreatePetRequest" } } ], @@ -262,7 +347,7 @@ const docTemplate = `{ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/dto.PetDto" + "$ref": "#/definitions/dto.PetResponse" } }, "400": { @@ -271,10 +356,229 @@ const docTemplate = `{ "$ref": "#/definitions/dto.ResponseBadRequestErr" } }, - "409": { - "description": "Duplicate email", + "500": { + "description": "Internal service error", "schema": { - "$ref": "#/definitions/dto.ResponseConflictErr" + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + } + }, + "/v1/pets/{id}": { + "get": { + "description": "Returns the data of a pet if successful", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "finds one pet", + "parameters": [ + { + "type": "string", + "description": "pet id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.PetResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + }, + "put": { + "description": "Returns the data of pet if successfully", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "updates pet", + "parameters": [ + { + "description": "update pet dto", + "name": "update", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdatePetRequest" + } + }, + { + "type": "string", + "description": "pet id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.PetResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + } + }, + "/v1/pets/{id}/adopt": { + "put": { + "description": "Return true if the pet is successfully adopted", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "Change a pet's adoptBy status", + "parameters": [ + { + "description": "adopt pet dto", + "name": "adoptDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.AdoptByRequest" + } + }, + { + "type": "string", + "description": "Pet ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.AdoptByResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + } + }, + "/v1/pets/{id}/visible": { + "put": { + "description": "Returns successful status if pet's IsVisible is successfully changed", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "changes pet's public visiblility", + "parameters": [ + { + "description": "changeView pet dto", + "name": "changeViewDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.ChangeViewPetRequest" + } + }, + { + "type": "string", + "description": "pet id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.ChangeViewPetResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" } }, "500": { @@ -294,6 +598,29 @@ const docTemplate = `{ } }, "definitions": { + "dto.AdoptByRequest": { + "type": "object", + "required": [ + "pet_id", + "user_id" + ], + "properties": { + "pet_id": { + "type": "string" + }, + "user_id": { + "type": "string" + } + } + }, + "dto.AdoptByResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + }, "dto.BadReqErrResponse": { "type": "object", "properties": { @@ -306,6 +633,102 @@ const docTemplate = `{ "value": {} } }, + "dto.ChangeViewPetRequest": { + "type": "object", + "required": [ + "visible" + ], + "properties": { + "visible": { + "type": "boolean" + } + } + }, + "dto.ChangeViewPetResponse": { + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean" + } + } + }, + "dto.CreatePetRequest": { + "type": "object", + "required": [ + "birthdate", + "gender", + "habit", + "is_club_pet", + "is_sterile", + "is_vaccinated", + "is_visible", + "name", + "species", + "status", + "type" + ], + "properties": { + "address": { + "type": "string" + }, + "adopt_by": { + "type": "string" + }, + "background": { + "type": "string" + }, + "birthdate": { + "type": "string" + }, + "caption": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "gender": { + "type": "integer", + "example": 1 + }, + "habit": { + "type": "string" + }, + "images": { + "type": "array", + "items": { + "type": "string" + } + }, + "is_club_pet": { + "type": "boolean" + }, + "is_sterile": { + "type": "boolean" + }, + "is_vaccinated": { + "type": "boolean" + }, + "is_visible": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "species": { + "type": "string" + }, + "status": { + "type": "integer", + "example": 1 + }, + "type": { + "type": "string" + } + } + }, "dto.Credential": { "type": "object", "properties": { @@ -323,6 +746,90 @@ const docTemplate = `{ } } }, + "dto.DeleteResponse": { + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean" + } + } + }, + "dto.ImageResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "dto.PetResponse": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "adopt_by": { + "type": "string" + }, + "background": { + "type": "string" + }, + "birthdate": { + "type": "string" + }, + "caption": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "habit": { + "type": "string" + }, + "id": { + "type": "string" + }, + "images": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.ImageResponse" + } + }, + "is_club_pet": { + "type": "boolean" + }, + "is_sterile": { + "type": "boolean" + }, + "is_vaccinated": { + "type": "boolean" + }, + "is_visible": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "species": { + "type": "string" + }, + "status": { + "type": "integer" + }, + "type": { + "type": "string" + } + } + }, "dto.RefreshTokenRequest": { "type": "object", "required": [ @@ -334,9 +841,6 @@ const docTemplate = `{ } } }, - "dto.PetDto": { - "type": "object" - }, "dto.ResponseBadRequestErr": { "type": "object", "properties": { @@ -492,6 +996,65 @@ const docTemplate = `{ "type": "string" } } + }, + "dto.UpdatePetRequest": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "adopt_by": { + "type": "string" + }, + "background": { + "type": "string" + }, + "birthdate": { + "type": "string" + }, + "caption": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "habit": { + "type": "string" + }, + "images": { + "type": "array", + "items": { + "type": "string" + } + }, + "is_club_pet": { + "type": "boolean" + }, + "is_sterile": { + "type": "boolean" + }, + "is_vaccinated": { + "type": "boolean" + }, + "is_visible": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "species": { + "type": "string" + }, + "status": { + "type": "integer" + }, + "type": { + "type": "string" + } + } } }, "securityDefinitions": { diff --git a/src/docs/swagger.json b/src/docs/swagger.json index 1303f34..deaf951 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -229,9 +229,9 @@ } } }, - "/v1/pet/": { + "/v1/pets/": { "get": { - "description": "Return the data of pets if successfully", + "description": "Returns the data of pets if successful", "consumes": [ "application/json" ], @@ -239,17 +239,103 @@ "application/json" ], "tags": [ - "auth" + "pet" + ], + "summary": "finds all pets", + "responses": { + "200": { + "description": "OK", + "schema": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.PetResponse" + } + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + }, + "delete": { + "description": "Returns successful status if pet is successfully deleted", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "deletes pet", + "parameters": [ + { + "type": "string", + "description": "pet id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.DeleteResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + } + }, + "/v1/pets/create": { + "post": { + "description": "Returns the data of pet if successful", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" ], - "summary": "find all pets", + "summary": "creates pet", "parameters": [ { "description": "pet dto", - "name": "signup", + "name": "create", "in": "body", "required": true, "schema": { - "$ref": "#/definitions/dto.PetDto" + "$ref": "#/definitions/dto.CreatePetRequest" } } ], @@ -257,7 +343,7 @@ "201": { "description": "Created", "schema": { - "$ref": "#/definitions/dto.PetDto" + "$ref": "#/definitions/dto.PetResponse" } }, "400": { @@ -266,10 +352,229 @@ "$ref": "#/definitions/dto.ResponseBadRequestErr" } }, - "409": { - "description": "Duplicate email", + "500": { + "description": "Internal service error", "schema": { - "$ref": "#/definitions/dto.ResponseConflictErr" + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + } + }, + "/v1/pets/{id}": { + "get": { + "description": "Returns the data of a pet if successful", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "finds one pet", + "parameters": [ + { + "type": "string", + "description": "pet id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.PetResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + }, + "put": { + "description": "Returns the data of pet if successfully", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "updates pet", + "parameters": [ + { + "description": "update pet dto", + "name": "update", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdatePetRequest" + } + }, + { + "type": "string", + "description": "pet id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.PetResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + } + }, + "/v1/pets/{id}/adopt": { + "put": { + "description": "Return true if the pet is successfully adopted", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "Change a pet's adoptBy status", + "parameters": [ + { + "description": "adopt pet dto", + "name": "adoptDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.AdoptByRequest" + } + }, + { + "type": "string", + "description": "Pet ID", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.AdoptByResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" + } + }, + "500": { + "description": "Internal service error", + "schema": { + "$ref": "#/definitions/dto.ResponseInternalErr" + } + }, + "503": { + "description": "Service is down", + "schema": { + "$ref": "#/definitions/dto.ResponseServiceDownErr" + } + } + } + } + }, + "/v1/pets/{id}/visible": { + "put": { + "description": "Returns successful status if pet's IsVisible is successfully changed", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "pet" + ], + "summary": "changes pet's public visiblility", + "parameters": [ + { + "description": "changeView pet dto", + "name": "changeViewDto", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.ChangeViewPetRequest" + } + }, + { + "type": "string", + "description": "pet id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.ChangeViewPetResponse" + } + }, + "400": { + "description": "Invalid request body", + "schema": { + "$ref": "#/definitions/dto.ResponseBadRequestErr" } }, "500": { @@ -289,6 +594,29 @@ } }, "definitions": { + "dto.AdoptByRequest": { + "type": "object", + "required": [ + "pet_id", + "user_id" + ], + "properties": { + "pet_id": { + "type": "string" + }, + "user_id": { + "type": "string" + } + } + }, + "dto.AdoptByResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + }, "dto.BadReqErrResponse": { "type": "object", "properties": { @@ -301,6 +629,102 @@ "value": {} } }, + "dto.ChangeViewPetRequest": { + "type": "object", + "required": [ + "visible" + ], + "properties": { + "visible": { + "type": "boolean" + } + } + }, + "dto.ChangeViewPetResponse": { + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean" + } + } + }, + "dto.CreatePetRequest": { + "type": "object", + "required": [ + "birthdate", + "gender", + "habit", + "is_club_pet", + "is_sterile", + "is_vaccinated", + "is_visible", + "name", + "species", + "status", + "type" + ], + "properties": { + "address": { + "type": "string" + }, + "adopt_by": { + "type": "string" + }, + "background": { + "type": "string" + }, + "birthdate": { + "type": "string" + }, + "caption": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "gender": { + "type": "integer", + "example": 1 + }, + "habit": { + "type": "string" + }, + "images": { + "type": "array", + "items": { + "type": "string" + } + }, + "is_club_pet": { + "type": "boolean" + }, + "is_sterile": { + "type": "boolean" + }, + "is_vaccinated": { + "type": "boolean" + }, + "is_visible": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "species": { + "type": "string" + }, + "status": { + "type": "integer", + "example": 1 + }, + "type": { + "type": "string" + } + } + }, "dto.Credential": { "type": "object", "properties": { @@ -318,6 +742,90 @@ } } }, + "dto.DeleteResponse": { + "type": "object", + "required": [ + "success" + ], + "properties": { + "success": { + "type": "boolean" + } + } + }, + "dto.ImageResponse": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "url": { + "type": "string" + } + } + }, + "dto.PetResponse": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "adopt_by": { + "type": "string" + }, + "background": { + "type": "string" + }, + "birthdate": { + "type": "string" + }, + "caption": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "habit": { + "type": "string" + }, + "id": { + "type": "string" + }, + "images": { + "type": "array", + "items": { + "$ref": "#/definitions/dto.ImageResponse" + } + }, + "is_club_pet": { + "type": "boolean" + }, + "is_sterile": { + "type": "boolean" + }, + "is_vaccinated": { + "type": "boolean" + }, + "is_visible": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "species": { + "type": "string" + }, + "status": { + "type": "integer" + }, + "type": { + "type": "string" + } + } + }, "dto.RefreshTokenRequest": { "type": "object", "required": [ @@ -329,9 +837,6 @@ } } }, - "dto.PetDto": { - "type": "object" - }, "dto.ResponseBadRequestErr": { "type": "object", "properties": { @@ -487,6 +992,65 @@ "type": "string" } } + }, + "dto.UpdatePetRequest": { + "type": "object", + "properties": { + "address": { + "type": "string" + }, + "adopt_by": { + "type": "string" + }, + "background": { + "type": "string" + }, + "birthdate": { + "type": "string" + }, + "caption": { + "type": "string" + }, + "contact": { + "type": "string" + }, + "gender": { + "type": "integer" + }, + "habit": { + "type": "string" + }, + "images": { + "type": "array", + "items": { + "type": "string" + } + }, + "is_club_pet": { + "type": "boolean" + }, + "is_sterile": { + "type": "boolean" + }, + "is_vaccinated": { + "type": "boolean" + }, + "is_visible": { + "type": "boolean" + }, + "name": { + "type": "string" + }, + "species": { + "type": "string" + }, + "status": { + "type": "integer" + }, + "type": { + "type": "string" + } + } } }, "securityDefinitions": { diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index b6ed6da..e585f99 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -1,4 +1,19 @@ definitions: + dto.AdoptByRequest: + properties: + pet_id: + type: string + user_id: + type: string + required: + - pet_id + - user_id + type: object + dto.AdoptByResponse: + properties: + success: + type: boolean + type: object dto.BadReqErrResponse: properties: failed_field: @@ -7,6 +22,73 @@ definitions: type: string value: {} type: object + dto.ChangeViewPetRequest: + properties: + visible: + type: boolean + required: + - visible + type: object + dto.ChangeViewPetResponse: + properties: + success: + type: boolean + required: + - success + type: object + dto.CreatePetRequest: + properties: + address: + type: string + adopt_by: + type: string + background: + type: string + birthdate: + type: string + caption: + type: string + contact: + type: string + gender: + example: 1 + type: integer + habit: + type: string + images: + items: + type: string + type: array + is_club_pet: + type: boolean + is_sterile: + type: boolean + is_vaccinated: + type: boolean + is_visible: + type: boolean + name: + type: string + species: + type: string + status: + example: 1 + type: integer + type: + type: string + required: + - birthdate + - gender + - habit + - is_club_pet + - is_sterile + - is_vaccinated + - is_visible + - name + - species + - status + - type + type: object dto.Credential: properties: access_token: @@ -19,6 +101,61 @@ definitions: example: e7e84d54-7518-4... type: string type: object + dto.DeleteResponse: + properties: + success: + type: boolean + required: + - success + type: object + dto.ImageResponse: + properties: + id: + type: string + url: + type: string + type: object + dto.PetResponse: + properties: + address: + type: string + adopt_by: + type: string + background: + type: string + birthdate: + type: string + caption: + type: string + contact: + type: string + gender: + type: integer + habit: + type: string + id: + type: string + images: + items: + $ref: '#/definitions/dto.ImageResponse' + type: array + is_club_pet: + type: boolean + is_sterile: + type: boolean + is_vaccinated: + type: boolean + is_visible: + type: boolean + name: + type: string + species: + type: string + status: + type: integer + type: + type: string + type: object dto.RefreshTokenRequest: properties: refresh_token: @@ -26,8 +163,6 @@ definitions: required: - refresh_token type: object - dto.PetDto: - type: object dto.ResponseBadRequestErr: properties: data: @@ -137,6 +272,45 @@ definitions: lastname: type: string type: object + dto.UpdatePetRequest: + properties: + address: + type: string + adopt_by: + type: string + background: + type: string + birthdate: + type: string + caption: + type: string + contact: + type: string + gender: + type: integer + habit: + type: string + images: + items: + type: string + type: array + is_club_pet: + type: boolean + is_sterile: + type: boolean + is_vaccinated: + type: boolean + is_visible: + type: boolean + name: + type: string + species: + type: string + status: + type: integer + type: + type: string + type: object info: contact: email: sd.team.sgcu@gmail.com @@ -287,33 +461,162 @@ paths: summary: Signup user tags: - auth - /v1/pet/: + /v1/pets/: + delete: + consumes: + - application/json + description: Returns successful status if pet is successfully deleted + parameters: + - description: pet id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dto.DeleteResponse' + "400": + description: Invalid request body + schema: + $ref: '#/definitions/dto.ResponseBadRequestErr' + "500": + description: Internal service error + schema: + $ref: '#/definitions/dto.ResponseInternalErr' + "503": + description: Service is down + schema: + $ref: '#/definitions/dto.ResponseServiceDownErr' + summary: deletes pet + tags: + - pet get: consumes: - application/json - description: Return the data of pets if successfully + description: Returns the data of pets if successful + produces: + - application/json + responses: + "200": + description: OK + schema: + items: + $ref: '#/definitions/dto.PetResponse' + type: array + "500": + description: Internal service error + schema: + $ref: '#/definitions/dto.ResponseInternalErr' + "503": + description: Service is down + schema: + $ref: '#/definitions/dto.ResponseServiceDownErr' + summary: finds all pets + tags: + - pet + /v1/pets/{id}: + get: + consumes: + - application/json + description: Returns the data of a pet if successful parameters: - - description: pet dto + - description: pet id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.PetResponse' + "400": + description: Invalid request body + schema: + $ref: '#/definitions/dto.ResponseBadRequestErr' + "500": + description: Internal service error + schema: + $ref: '#/definitions/dto.ResponseInternalErr' + "503": + description: Service is down + schema: + $ref: '#/definitions/dto.ResponseServiceDownErr' + summary: finds one pet + tags: + - pet + put: + consumes: + - application/json + description: Returns the data of pet if successfully + parameters: + - description: update pet dto in: body - name: signup + name: update required: true schema: - $ref: '#/definitions/dto.PetDto' + $ref: '#/definitions/dto.UpdatePetRequest' + - description: pet id + in: path + name: id + required: true + type: string produces: - application/json responses: "201": description: Created schema: - $ref: '#/definitions/dto.PetDto' + $ref: '#/definitions/dto.PetResponse' "400": description: Invalid request body schema: $ref: '#/definitions/dto.ResponseBadRequestErr' - "409": - description: Duplicate email + "500": + description: Internal service error schema: - $ref: '#/definitions/dto.ResponseConflictErr' + $ref: '#/definitions/dto.ResponseInternalErr' + "503": + description: Service is down + schema: + $ref: '#/definitions/dto.ResponseServiceDownErr' + summary: updates pet + tags: + - pet + /v1/pets/{id}/adopt: + put: + consumes: + - application/json + description: Return true if the pet is successfully adopted + parameters: + - description: adopt pet dto + in: body + name: adoptDto + required: true + schema: + $ref: '#/definitions/dto.AdoptByRequest' + - description: Pet ID + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dto.AdoptByResponse' + "400": + description: Invalid request body + schema: + $ref: '#/definitions/dto.ResponseBadRequestErr' "500": description: Internal service error schema: @@ -322,9 +625,82 @@ paths: description: Service is down schema: $ref: '#/definitions/dto.ResponseServiceDownErr' - summary: find all pets + summary: Change a pet's adoptBy status tags: - - auth + - pet + /v1/pets/{id}/visible: + put: + consumes: + - application/json + description: Returns successful status if pet's IsVisible is successfully changed + parameters: + - description: changeView pet dto + in: body + name: changeViewDto + required: true + schema: + $ref: '#/definitions/dto.ChangeViewPetRequest' + - description: pet id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dto.ChangeViewPetResponse' + "400": + description: Invalid request body + schema: + $ref: '#/definitions/dto.ResponseBadRequestErr' + "500": + description: Internal service error + schema: + $ref: '#/definitions/dto.ResponseInternalErr' + "503": + description: Service is down + schema: + $ref: '#/definitions/dto.ResponseServiceDownErr' + summary: changes pet's public visiblility + tags: + - pet + /v1/pets/create: + post: + consumes: + - application/json + description: Returns the data of pet if successful + parameters: + - description: pet dto + in: body + name: create + required: true + schema: + $ref: '#/definitions/dto.CreatePetRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dto.PetResponse' + "400": + description: Invalid request body + schema: + $ref: '#/definitions/dto.ResponseBadRequestErr' + "500": + description: Internal service error + schema: + $ref: '#/definitions/dto.ResponseInternalErr' + "503": + description: Service is down + schema: + $ref: '#/definitions/dto.ResponseServiceDownErr' + summary: creates pet + tags: + - pet schemes: - https - http