diff --git a/src/app/dto/auth.dto.go b/src/app/dto/auth.dto.go index fe33c9b..4a68f91 100644 --- a/src/app/dto/auth.dto.go +++ b/src/app/dto/auth.dto.go @@ -31,3 +31,11 @@ type SignOutResponse struct { type RefreshTokenRequest struct { RefreshToken string `json:"refresh_token" validate:"required"` } + +type ForgotPasswordRequest struct { + Email string `json:"email" validate:"required,email"` +} + +type ForgotPasswordResponse struct { + IsSuccess bool `json:"is_success"` +} diff --git a/src/app/handler/auth/auth.handler.go b/src/app/handler/auth/auth.handler.go index 9eade02..249b05d 100644 --- a/src/app/handler/auth/auth.handler.go +++ b/src/app/handler/auth/auth.handler.go @@ -184,3 +184,49 @@ func (h *Handler) RefreshToken(c router.IContext) { c.JSON(http.StatusOK, response) } + +// ForgotPassword is a function to send email to reset password when you forgot password +// @Summary Forgot Password +// @Description Return isSuccess +// @Param request body dto.ForgotPasswordRequest true "forgotPassword request dto" +// @Tags auth +// @Accept json +// @Produce json +// @Success 200 {object} dto.ForgotPasswordResponse +// @Failure 400 {object} dto.ResponseBadRequestErr "Invalid email" +// @Failure 500 {object} dto.ResponseInternalErr "Internal service error" +// @Failure 503 {object} dto.ResponseServiceDownErr "Service is down" +// @Router /v1/auth/forgot-password [post] +func (h *Handler) ForgotPassword(c router.IContext) { + request := &dto.ForgotPasswordRequest{} + err := c.Bind(request) + if err != nil { + c.JSON(http.StatusBadRequest, dto.ResponseErr{ + StatusCode: http.StatusBadRequest, + Message: constant.BindingRequestErrorMessage + err.Error(), + Data: nil, + }) + return + } + + if err := h.validate.Validate(request); err != nil { + var errorMessage []string + for _, reqErr := range err { + errorMessage = append(errorMessage, reqErr.Message) + } + c.JSON(http.StatusBadRequest, dto.ResponseErr{ + StatusCode: http.StatusBadRequest, + Message: constant.InvalidRequestBodyMessage + strings.Join(errorMessage, ", "), + Data: nil, + }) + return + } + + response, respErr := h.service.ForgotPassword(request) + if respErr != nil { + c.JSON(respErr.StatusCode, respErr) + return + } + + c.JSON(http.StatusOK, response) +} diff --git a/src/app/handler/auth/auth.handler_test.go b/src/app/handler/auth/auth.handler_test.go index 3a73e40..b4555a3 100644 --- a/src/app/handler/auth/auth.handler_test.go +++ b/src/app/handler/auth/auth.handler_test.go @@ -18,11 +18,12 @@ import ( type AuthHandlerTest struct { suite.Suite - signupRequest *dto.SignupRequest - signInRequest *dto.SignInRequest - refreshTokenRequest *dto.RefreshTokenRequest - bindErr error - validateErr []*dto.BadReqErrResponse + signupRequest *dto.SignupRequest + signInRequest *dto.SignInRequest + refreshTokenRequest *dto.RefreshTokenRequest + forgotPasswordRequest *dto.ForgotPasswordRequest + bindErr error + validateErr []*dto.BadReqErrResponse } func TestAuthHandler(t *testing.T) { @@ -33,6 +34,7 @@ func (t *AuthHandlerTest) SetupTest() { signupRequest := &dto.SignupRequest{} signInRequest := &dto.SignInRequest{} refreshTokenRequest := &dto.RefreshTokenRequest{} + forgotPasswordRequest := &dto.ForgotPasswordRequest{} bindErr := errors.New("Binding request failed") validateErr := []*dto.BadReqErrResponse{ { @@ -50,6 +52,7 @@ func (t *AuthHandlerTest) SetupTest() { t.signupRequest = signupRequest t.signInRequest = signInRequest t.refreshTokenRequest = refreshTokenRequest + t.forgotPasswordRequest = forgotPasswordRequest t.bindErr = bindErr t.validateErr = validateErr } @@ -378,3 +381,93 @@ func (t *AuthHandlerTest) TestRefreshTokenServiceError() { handler.RefreshToken(context) } + +func (t *AuthHandlerTest) TestForgotPasswordSuccess() { + forgotPasswordResponse := &dto.ForgotPasswordResponse{ + IsSuccess: true, + } + + controller := gomock.NewController(t.T()) + + authSvc := authMock.NewMockService(controller) + userSvc := userMock.NewMockService(controller) + validator := validatorMock.NewMockIDtoValidator(controller) + context := routerMock.NewMockIContext(controller) + + handler := NewHandler(authSvc, userSvc, validator) + + context.EXPECT().Bind(t.forgotPasswordRequest).Return(nil) + validator.EXPECT().Validate(t.forgotPasswordRequest).Return(nil) + authSvc.EXPECT().ForgotPassword(t.forgotPasswordRequest).Return(forgotPasswordResponse, nil) + context.EXPECT().JSON(http.StatusOK, forgotPasswordResponse) + + handler.ForgotPassword(context) +} + +func (t *AuthHandlerTest) TestForgotPasswordBindFailed() { + errResponse := dto.ResponseErr{ + StatusCode: http.StatusBadRequest, + Message: constant.BindingRequestErrorMessage + t.bindErr.Error(), + Data: nil, + } + + controller := gomock.NewController(t.T()) + + authSvc := authMock.NewMockService(controller) + userSvc := userMock.NewMockService(controller) + validator := validatorMock.NewMockIDtoValidator(controller) + context := routerMock.NewMockIContext(controller) + + handler := NewHandler(authSvc, userSvc, validator) + + context.EXPECT().Bind(t.forgotPasswordRequest).Return(t.bindErr) + context.EXPECT().JSON(http.StatusBadRequest, errResponse) + handler.ForgotPassword(context) +} + +func (t *AuthHandlerTest) TestForgotPasswordValidateFailed() { + errResponse := dto.ResponseErr{ + StatusCode: http.StatusBadRequest, + Message: constant.InvalidRequestBodyMessage + "BadRequestError1, BadRequestError2", + Data: nil, + } + + controller := gomock.NewController(t.T()) + + authSvc := authMock.NewMockService(controller) + userSvc := userMock.NewMockService(controller) + validator := validatorMock.NewMockIDtoValidator(controller) + context := routerMock.NewMockIContext(controller) + + handler := NewHandler(authSvc, userSvc, validator) + + context.EXPECT().Bind(t.forgotPasswordRequest).Return(nil) + validator.EXPECT().Validate(t.forgotPasswordRequest).Return(t.validateErr) + context.EXPECT().JSON(http.StatusBadRequest, errResponse) + + handler.ForgotPassword(context) +} + +func (t *AuthHandlerTest) TestForgotPasswordServiceError() { + forgotPasswordErr := &dto.ResponseErr{ + StatusCode: http.StatusInternalServerError, + Message: constant.InternalErrorMessage, + Data: nil, + } + + controller := gomock.NewController(t.T()) + + authSvc := authMock.NewMockService(controller) + userSvc := userMock.NewMockService(controller) + validator := validatorMock.NewMockIDtoValidator(controller) + context := routerMock.NewMockIContext(controller) + + handler := NewHandler(authSvc, userSvc, validator) + + context.EXPECT().Bind(t.forgotPasswordRequest).Return(nil) + validator.EXPECT().Validate(t.forgotPasswordRequest).Return(nil) + authSvc.EXPECT().ForgotPassword(t.forgotPasswordRequest).Return(nil, forgotPasswordErr) + context.EXPECT().JSON(http.StatusInternalServerError, forgotPasswordErr) + + handler.ForgotPassword(context) +} diff --git a/src/app/service/auth/auth.service.go b/src/app/service/auth/auth.service.go index 2f33c62..b42452f 100644 --- a/src/app/service/auth/auth.service.go +++ b/src/app/service/auth/auth.service.go @@ -288,3 +288,56 @@ func (s *Service) RefreshToken(request *dto.RefreshTokenRequest) (*dto.Credentia ExpiresIn: int(response.Credential.ExpiresIn), }, nil } + +func (s *Service) ForgotPassword(request *dto.ForgotPasswordRequest) (*dto.ForgotPasswordResponse, *dto.ResponseErr) { + ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) + defer cancel() + + _, err := s.client.ForgotPassword(ctx, &authProto.ForgotPasswordRequest{ + Email: request.Email, + }) + if err != nil { + st, ok := status.FromError(err) + log.Error(). + Str("service", "auth"). + Str("action", "ForgotPassword"). + Str("email", request.Email). + Msg(st.Message()) + if !ok { + return nil, &dto.ResponseErr{ + StatusCode: http.StatusInternalServerError, + Message: constant.InternalErrorMessage, + Data: nil, + } + } + switch st.Code() { + case codes.NotFound: + return nil, &dto.ResponseErr{ + StatusCode: http.StatusNotFound, + Message: constant.UserNotFoundMessage, + Data: nil, + } + case codes.Internal: + return nil, &dto.ResponseErr{ + StatusCode: http.StatusInternalServerError, + Message: constant.InternalErrorMessage, + Data: nil, + } + default: + return nil, &dto.ResponseErr{ + StatusCode: http.StatusServiceUnavailable, + Message: constant.UnavailableServiceMessage, + Data: nil, + } + } + } + + log.Info(). + Str("service", "auth"). + Str("action", "ForgotPassword"). + Str("email", request.Email). + Msg("Forgot password successfully") + return &dto.ForgotPasswordResponse{ + IsSuccess: true, + }, nil +} diff --git a/src/app/service/auth/auth.service_test.go b/src/app/service/auth/auth.service_test.go index c041928..25b1f0c 100644 --- a/src/app/service/auth/auth.service_test.go +++ b/src/app/service/auth/auth.service_test.go @@ -18,10 +18,11 @@ import ( type AuthServiceTest struct { suite.Suite - signupRequestDto *dto.SignupRequest - signInDto *dto.SignInRequest - token string - refreshTokenRequest *dto.RefreshTokenRequest + signupRequestDto *dto.SignupRequest + signInDto *dto.SignInRequest + token string + refreshTokenRequest *dto.RefreshTokenRequest + forgotPasswordRequest *dto.ForgotPasswordRequest } func TestAuthService(t *testing.T) { @@ -43,11 +44,15 @@ func (t *AuthServiceTest) SetupTest() { refreshTokenRequest := &dto.RefreshTokenRequest{ RefreshToken: faker.UUIDDigit(), } + forgotPasswordRequest := &dto.ForgotPasswordRequest{ + Email: faker.Email(), + } t.signupRequestDto = signupRequestDto t.signInDto = signInDto t.token = token t.refreshTokenRequest = refreshTokenRequest + t.forgotPasswordRequest = forgotPasswordRequest } func (t *AuthServiceTest) TestSignupSuccess() { @@ -601,3 +606,112 @@ func (t *AuthServiceTest) TestRefreshTokenUnknownError() { assert.Nil(t.T(), actual) assert.Equal(t.T(), expected, err) } + +func (t *AuthServiceTest) TestForgotPasswordSuccess() { + protoReq := &authProto.ForgotPasswordRequest{ + Email: t.forgotPasswordRequest.Email, + } + protoResp := &authProto.ForgotPasswordResponse{ + Url: faker.URL(), + } + expected := &dto.ForgotPasswordResponse{ + IsSuccess: true, + } + + client := auth.AuthClientMock{} + client.On("ForgotPassword", protoReq).Return(protoResp, nil) + + svc := NewService(&client) + actual, err := svc.ForgotPassword(t.forgotPasswordRequest) + + assert.Nil(t.T(), err) + assert.Equal(t.T(), expected, actual) +} + +func (t *AuthServiceTest) TestForgotPasswordNotFound() { + protoReq := &authProto.ForgotPasswordRequest{ + Email: t.forgotPasswordRequest.Email, + } + protoErr := status.Error(codes.NotFound, "Not found") + + expected := &dto.ResponseErr{ + StatusCode: http.StatusNotFound, + Message: constant.UserNotFoundMessage, + Data: nil, + } + + client := auth.AuthClientMock{} + client.On("ForgotPassword", protoReq).Return(nil, protoErr) + + svc := NewService(&client) + actual, err := svc.ForgotPassword(t.forgotPasswordRequest) + + assert.Nil(t.T(), actual) + assert.Equal(t.T(), expected, err) +} + +func (t *AuthServiceTest) TestForgotPasswordInternalErr() { + protoReq := &authProto.ForgotPasswordRequest{ + Email: t.forgotPasswordRequest.Email, + } + protoErr := status.Error(codes.Internal, "Internal error") + + expected := &dto.ResponseErr{ + StatusCode: http.StatusInternalServerError, + Message: constant.InternalErrorMessage, + Data: nil, + } + + client := auth.AuthClientMock{} + client.On("ForgotPassword", protoReq).Return(nil, protoErr) + + svc := NewService(&client) + actual, err := svc.ForgotPassword(t.forgotPasswordRequest) + + assert.Nil(t.T(), actual) + assert.Equal(t.T(), expected, err) +} + +func (t *AuthServiceTest) TestForgotPasswordUnavailableService() { + protoReq := &authProto.ForgotPasswordRequest{ + Email: t.forgotPasswordRequest.Email, + } + protoErr := status.Error(codes.Unavailable, "Connection lost") + + expected := &dto.ResponseErr{ + StatusCode: http.StatusServiceUnavailable, + Message: constant.UnavailableServiceMessage, + Data: nil, + } + + client := auth.AuthClientMock{} + client.On("ForgotPassword", protoReq).Return(nil, protoErr) + + svc := NewService(&client) + actual, err := svc.ForgotPassword(t.forgotPasswordRequest) + + assert.Nil(t.T(), actual) + assert.Equal(t.T(), expected, err) +} + +func (t *AuthServiceTest) TestForgotPasswordUnknownErr() { + protoReq := &authProto.ForgotPasswordRequest{ + Email: t.forgotPasswordRequest.Email, + } + protoErr := errors.New("Unknown Error") + + expected := &dto.ResponseErr{ + StatusCode: http.StatusInternalServerError, + Message: constant.InternalErrorMessage, + Data: nil, + } + + client := auth.AuthClientMock{} + client.On("ForgotPassword", protoReq).Return(nil, protoErr) + + svc := NewService(&client) + actual, err := svc.ForgotPassword(t.forgotPasswordRequest) + + assert.Nil(t.T(), actual) + assert.Equal(t.T(), expected, err) +} diff --git a/src/constant/auth/auth.constant.go b/src/constant/auth/auth.constant.go index 281fc8c..3394890 100644 --- a/src/constant/auth/auth.constant.go +++ b/src/constant/auth/auth.constant.go @@ -1,12 +1,13 @@ package auth var ExcludePath = map[string]struct{}{ - "POST /auth/signup": {}, - "POST /auth/signin": {}, - "POST /auth/verify": {}, - "GET /user/:id": {}, - "GET /pets": {}, - "GET /adopt": {}, + "POST /auth/signup": {}, + "POST /auth/signin": {}, + "POST /auth/verify": {}, + "POST /auth/forgot-password": {}, + "GET /user/:id": {}, + "GET /pets": {}, + "GET /adopt": {}, } var AdminPath = map[string]struct{}{ diff --git a/src/docs/docs.go b/src/docs/docs.go index ee19d5a..14841e5 100644 --- a/src/docs/docs.go +++ b/src/docs/docs.go @@ -18,6 +18,58 @@ const docTemplate = `{ "host": "{{.Host}}", "basePath": "{{.BasePath}}", "paths": { + "/v1/auth/forgot-password": { + "post": { + "description": "Return isSuccess", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Forgot Password", + "parameters": [ + { + "description": "forgotPassword request dto", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.ForgotPasswordRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.ForgotPasswordResponse" + } + }, + "400": { + "description": "Invalid email", + "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/auth/refreshToken": { "post": { "description": "Return the credential", @@ -595,6 +647,156 @@ const docTemplate = `{ } } } + }, + "/v1/users": { + "put": { + "description": "Returns the data of user if successfully", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "updates user", + "parameters": [ + { + "description": "update user dto", + "name": "update", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdateUserRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.User" + } + }, + "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/users/{id}": { + "get": { + "description": "Returns the data of user if successful", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "finds one user", + "parameters": [ + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.User" + } + }, + "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" + } + } + } + }, + "delete": { + "description": "Returns successful status if user is successfully deleted", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "deletes user", + "parameters": [ + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.DeleteUserResponse" + } + }, + "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" + } + } + } + } } }, "definitions": { @@ -646,9 +848,6 @@ const docTemplate = `{ }, "dto.ChangeViewPetResponse": { "type": "object", - "required": [ - "success" - ], "properties": { "success": { "type": "boolean" @@ -659,14 +858,15 @@ const docTemplate = `{ "type": "object", "required": [ "birthdate", + "color", "gender", "habit", - "is_club_pet", "is_sterile", "is_vaccinated", "is_visible", "name", - "species", + "origin", + "pattern", "status", "type" ], @@ -677,21 +877,25 @@ const docTemplate = `{ "adopt_by": { "type": "string" }, - "background": { - "type": "string" - }, "birthdate": { "type": "string" }, "caption": { "type": "string" }, + "color": { + "type": "string" + }, "contact": { "type": "string" }, "gender": { - "type": "integer", - "example": 1 + "allOf": [ + { + "$ref": "#/definitions/pet.Gender" + } + ], + "example": "male" }, "habit": { "type": "string" @@ -702,9 +906,6 @@ const docTemplate = `{ "type": "string" } }, - "is_club_pet": { - "type": "boolean" - }, "is_sterile": { "type": "boolean" }, @@ -717,12 +918,19 @@ const docTemplate = `{ "name": { "type": "string" }, - "species": { + "origin": { + "type": "string" + }, + "pattern": { "type": "string" }, "status": { - "type": "integer", - "example": 1 + "allOf": [ + { + "$ref": "#/definitions/pet.Status" + } + ], + "example": "findhome" }, "type": { "type": "string" @@ -747,12 +955,36 @@ const docTemplate = `{ } }, "dto.DeleteResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + }, + "dto.DeleteUserResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + }, + "dto.ForgotPasswordRequest": { "type": "object", "required": [ - "success" + "email" ], "properties": { - "success": { + "email": { + "type": "string" + } + } + }, + "dto.ForgotPasswordResponse": { + "type": "object", + "properties": { + "is_success": { "type": "boolean" } } @@ -763,6 +995,9 @@ const docTemplate = `{ "id": { "type": "string" }, + "object_key": { + "type": "string" + }, "url": { "type": "string" } @@ -777,20 +1012,20 @@ const docTemplate = `{ "adopt_by": { "type": "string" }, - "background": { - "type": "string" - }, "birthdate": { "type": "string" }, "caption": { "type": "string" }, + "color": { + "type": "string" + }, "contact": { "type": "string" }, "gender": { - "type": "integer" + "$ref": "#/definitions/pet.Gender" }, "habit": { "type": "string" @@ -804,9 +1039,6 @@ const docTemplate = `{ "$ref": "#/definitions/dto.ImageResponse" } }, - "is_club_pet": { - "type": "boolean" - }, "is_sterile": { "type": "boolean" }, @@ -819,11 +1051,14 @@ const docTemplate = `{ "name": { "type": "string" }, - "species": { + "origin": { + "type": "string" + }, + "pattern": { "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/pet.Status" }, "type": { "type": "string" @@ -1006,20 +1241,20 @@ const docTemplate = `{ "adopt_by": { "type": "string" }, - "background": { - "type": "string" - }, "birthdate": { "type": "string" }, "caption": { "type": "string" }, + "color": { + "type": "string" + }, "contact": { "type": "string" }, "gender": { - "type": "integer" + "$ref": "#/definitions/pet.Gender" }, "habit": { "type": "string" @@ -1030,9 +1265,6 @@ const docTemplate = `{ "type": "string" } }, - "is_club_pet": { - "type": "boolean" - }, "is_sterile": { "type": "boolean" }, @@ -1045,16 +1277,83 @@ const docTemplate = `{ "name": { "type": "string" }, - "species": { + "origin": { + "type": "string" + }, + "pattern": { "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/pet.Status" }, "type": { "type": "string" } } + }, + "dto.UpdateUserRequest": { + "type": "object", + "required": [ + "email", + "firstname", + "lastname", + "password" + ], + "properties": { + "email": { + "type": "string" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "password": { + "type": "string", + "maxLength": 30, + "minLength": 6 + } + } + }, + "dto.User": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstname": { + "type": "string" + }, + "id": { + "type": "string" + }, + "lastname": { + "type": "string" + } + } + }, + "pet.Gender": { + "type": "string", + "enum": [ + "male", + "female" + ], + "x-enum-varnames": [ + "MALE", + "FEMALE" + ] + }, + "pet.Status": { + "type": "string", + "enum": [ + "adopted", + "findhome" + ], + "x-enum-varnames": [ + "ADOPTED", + "FINDHOME" + ] } }, "securityDefinitions": { diff --git a/src/docs/swagger.json b/src/docs/swagger.json index deaf951..bffd226 100644 --- a/src/docs/swagger.json +++ b/src/docs/swagger.json @@ -14,6 +14,58 @@ "version": "1.0" }, "paths": { + "/v1/auth/forgot-password": { + "post": { + "description": "Return isSuccess", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "Forgot Password", + "parameters": [ + { + "description": "forgotPassword request dto", + "name": "request", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.ForgotPasswordRequest" + } + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.ForgotPasswordResponse" + } + }, + "400": { + "description": "Invalid email", + "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/auth/refreshToken": { "post": { "description": "Return the credential", @@ -591,6 +643,156 @@ } } } + }, + "/v1/users": { + "put": { + "description": "Returns the data of user if successfully", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "auth" + ], + "summary": "updates user", + "parameters": [ + { + "description": "update user dto", + "name": "update", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/dto.UpdateUserRequest" + } + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.User" + } + }, + "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/users/{id}": { + "get": { + "description": "Returns the data of user if successful", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "finds one user", + "parameters": [ + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "200": { + "description": "OK", + "schema": { + "$ref": "#/definitions/dto.User" + } + }, + "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" + } + } + } + }, + "delete": { + "description": "Returns successful status if user is successfully deleted", + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "tags": [ + "user" + ], + "summary": "deletes user", + "parameters": [ + { + "type": "string", + "description": "user id", + "name": "id", + "in": "path", + "required": true + } + ], + "responses": { + "201": { + "description": "Created", + "schema": { + "$ref": "#/definitions/dto.DeleteUserResponse" + } + }, + "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" + } + } + } + } } }, "definitions": { @@ -642,9 +844,6 @@ }, "dto.ChangeViewPetResponse": { "type": "object", - "required": [ - "success" - ], "properties": { "success": { "type": "boolean" @@ -655,14 +854,15 @@ "type": "object", "required": [ "birthdate", + "color", "gender", "habit", - "is_club_pet", "is_sterile", "is_vaccinated", "is_visible", "name", - "species", + "origin", + "pattern", "status", "type" ], @@ -673,21 +873,25 @@ "adopt_by": { "type": "string" }, - "background": { - "type": "string" - }, "birthdate": { "type": "string" }, "caption": { "type": "string" }, + "color": { + "type": "string" + }, "contact": { "type": "string" }, "gender": { - "type": "integer", - "example": 1 + "allOf": [ + { + "$ref": "#/definitions/pet.Gender" + } + ], + "example": "male" }, "habit": { "type": "string" @@ -698,9 +902,6 @@ "type": "string" } }, - "is_club_pet": { - "type": "boolean" - }, "is_sterile": { "type": "boolean" }, @@ -713,12 +914,19 @@ "name": { "type": "string" }, - "species": { + "origin": { + "type": "string" + }, + "pattern": { "type": "string" }, "status": { - "type": "integer", - "example": 1 + "allOf": [ + { + "$ref": "#/definitions/pet.Status" + } + ], + "example": "findhome" }, "type": { "type": "string" @@ -743,12 +951,36 @@ } }, "dto.DeleteResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + }, + "dto.DeleteUserResponse": { + "type": "object", + "properties": { + "success": { + "type": "boolean" + } + } + }, + "dto.ForgotPasswordRequest": { "type": "object", "required": [ - "success" + "email" ], "properties": { - "success": { + "email": { + "type": "string" + } + } + }, + "dto.ForgotPasswordResponse": { + "type": "object", + "properties": { + "is_success": { "type": "boolean" } } @@ -759,6 +991,9 @@ "id": { "type": "string" }, + "object_key": { + "type": "string" + }, "url": { "type": "string" } @@ -773,20 +1008,20 @@ "adopt_by": { "type": "string" }, - "background": { - "type": "string" - }, "birthdate": { "type": "string" }, "caption": { "type": "string" }, + "color": { + "type": "string" + }, "contact": { "type": "string" }, "gender": { - "type": "integer" + "$ref": "#/definitions/pet.Gender" }, "habit": { "type": "string" @@ -800,9 +1035,6 @@ "$ref": "#/definitions/dto.ImageResponse" } }, - "is_club_pet": { - "type": "boolean" - }, "is_sterile": { "type": "boolean" }, @@ -815,11 +1047,14 @@ "name": { "type": "string" }, - "species": { + "origin": { + "type": "string" + }, + "pattern": { "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/pet.Status" }, "type": { "type": "string" @@ -1002,20 +1237,20 @@ "adopt_by": { "type": "string" }, - "background": { - "type": "string" - }, "birthdate": { "type": "string" }, "caption": { "type": "string" }, + "color": { + "type": "string" + }, "contact": { "type": "string" }, "gender": { - "type": "integer" + "$ref": "#/definitions/pet.Gender" }, "habit": { "type": "string" @@ -1026,9 +1261,6 @@ "type": "string" } }, - "is_club_pet": { - "type": "boolean" - }, "is_sterile": { "type": "boolean" }, @@ -1041,16 +1273,83 @@ "name": { "type": "string" }, - "species": { + "origin": { + "type": "string" + }, + "pattern": { "type": "string" }, "status": { - "type": "integer" + "$ref": "#/definitions/pet.Status" }, "type": { "type": "string" } } + }, + "dto.UpdateUserRequest": { + "type": "object", + "required": [ + "email", + "firstname", + "lastname", + "password" + ], + "properties": { + "email": { + "type": "string" + }, + "firstname": { + "type": "string" + }, + "lastname": { + "type": "string" + }, + "password": { + "type": "string", + "maxLength": 30, + "minLength": 6 + } + } + }, + "dto.User": { + "type": "object", + "properties": { + "email": { + "type": "string" + }, + "firstname": { + "type": "string" + }, + "id": { + "type": "string" + }, + "lastname": { + "type": "string" + } + } + }, + "pet.Gender": { + "type": "string", + "enum": [ + "male", + "female" + ], + "x-enum-varnames": [ + "MALE", + "FEMALE" + ] + }, + "pet.Status": { + "type": "string", + "enum": [ + "adopted", + "findhome" + ], + "x-enum-varnames": [ + "ADOPTED", + "FINDHOME" + ] } }, "securityDefinitions": { diff --git a/src/docs/swagger.yaml b/src/docs/swagger.yaml index e585f99..363cd54 100644 --- a/src/docs/swagger.yaml +++ b/src/docs/swagger.yaml @@ -33,8 +33,6 @@ definitions: properties: success: type: boolean - required: - - success type: object dto.CreatePetRequest: properties: @@ -42,25 +40,24 @@ definitions: type: string adopt_by: type: string - background: - type: string birthdate: type: string caption: type: string + color: + type: string contact: type: string gender: - example: 1 - type: integer + allOf: + - $ref: '#/definitions/pet.Gender' + example: male habit: type: string images: items: type: string type: array - is_club_pet: - type: boolean is_sterile: type: boolean is_vaccinated: @@ -69,23 +66,27 @@ definitions: type: boolean name: type: string - species: + origin: + type: string + pattern: type: string status: - example: 1 - type: integer + allOf: + - $ref: '#/definitions/pet.Status' + example: findhome type: type: string required: - birthdate + - color - gender - habit - - is_club_pet - is_sterile - is_vaccinated - is_visible - name - - species + - origin + - pattern - status - type type: object @@ -105,13 +106,30 @@ definitions: properties: success: type: boolean + type: object + dto.DeleteUserResponse: + properties: + success: + type: boolean + type: object + dto.ForgotPasswordRequest: + properties: + email: + type: string required: - - success + - email + type: object + dto.ForgotPasswordResponse: + properties: + is_success: + type: boolean type: object dto.ImageResponse: properties: id: type: string + object_key: + type: string url: type: string type: object @@ -121,16 +139,16 @@ definitions: type: string adopt_by: type: string - background: - type: string birthdate: type: string caption: type: string + color: + type: string contact: type: string gender: - type: integer + $ref: '#/definitions/pet.Gender' habit: type: string id: @@ -139,8 +157,6 @@ definitions: items: $ref: '#/definitions/dto.ImageResponse' type: array - is_club_pet: - type: boolean is_sterile: type: boolean is_vaccinated: @@ -149,10 +165,12 @@ definitions: type: boolean name: type: string - species: + origin: + type: string + pattern: type: string status: - type: integer + $ref: '#/definitions/pet.Status' type: type: string type: object @@ -278,24 +296,22 @@ definitions: type: string adopt_by: type: string - background: - type: string birthdate: type: string caption: type: string + color: + type: string contact: type: string gender: - type: integer + $ref: '#/definitions/pet.Gender' habit: type: string images: items: type: string type: array - is_club_pet: - type: boolean is_sterile: type: boolean is_vaccinated: @@ -304,13 +320,60 @@ definitions: type: boolean name: type: string - species: + origin: + type: string + pattern: type: string status: - type: integer + $ref: '#/definitions/pet.Status' type: type: string type: object + dto.UpdateUserRequest: + properties: + email: + type: string + firstname: + type: string + lastname: + type: string + password: + maxLength: 30 + minLength: 6 + type: string + required: + - email + - firstname + - lastname + - password + type: object + dto.User: + properties: + email: + type: string + firstname: + type: string + id: + type: string + lastname: + type: string + type: object + pet.Gender: + enum: + - male + - female + type: string + x-enum-varnames: + - MALE + - FEMALE + pet.Status: + enum: + - adopted + - findhome + type: string + x-enum-varnames: + - ADOPTED + - FINDHOME info: contact: email: sd.team.sgcu@gmail.com @@ -319,6 +382,40 @@ info: title: JohnJud API version: "1.0" paths: + /v1/auth/forgot-password: + post: + consumes: + - application/json + description: Return isSuccess + parameters: + - description: forgotPassword request dto + in: body + name: request + required: true + schema: + $ref: '#/definitions/dto.ForgotPasswordRequest' + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.ForgotPasswordResponse' + "400": + description: Invalid email + 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: Forgot Password + tags: + - auth /v1/auth/refreshToken: post: consumes: @@ -701,6 +798,105 @@ paths: summary: creates pet tags: - pet + /v1/users: + put: + consumes: + - application/json + description: Returns the data of user if successfully + parameters: + - description: update user dto + in: body + name: update + required: true + schema: + $ref: '#/definitions/dto.UpdateUserRequest' + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dto.User' + "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: updates user + tags: + - auth + /v1/users/{id}: + delete: + consumes: + - application/json + description: Returns successful status if user is successfully deleted + parameters: + - description: user id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "201": + description: Created + schema: + $ref: '#/definitions/dto.DeleteUserResponse' + "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 user + tags: + - user + get: + consumes: + - application/json + description: Returns the data of user if successful + parameters: + - description: user id + in: path + name: id + required: true + type: string + produces: + - application/json + responses: + "200": + description: OK + schema: + $ref: '#/definitions/dto.User' + "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 user + tags: + - user schemes: - https - http diff --git a/src/main.go b/src/main.go index 8e785da..484d196 100644 --- a/src/main.go +++ b/src/main.go @@ -11,7 +11,7 @@ import ( "time" authHdr "github.com/isd-sgcu/johnjud-gateway/src/app/handler/auth" - healthcheck "github.com/isd-sgcu/johnjud-gateway/src/app/handler/healthcheck" + "github.com/isd-sgcu/johnjud-gateway/src/app/handler/healthcheck" imageHdr "github.com/isd-sgcu/johnjud-gateway/src/app/handler/image" likeHdr "github.com/isd-sgcu/johnjud-gateway/src/app/handler/like" petHdr "github.com/isd-sgcu/johnjud-gateway/src/app/handler/pet" @@ -129,6 +129,7 @@ func main() { r.PostAuth("/signout", authHandler.SignOut) //r.PostAuth("/me", authHandler.Validate) r.PostAuth("/refreshToken", authHandler.RefreshToken) + r.PostAuth("/forgot-password", authHandler.ForgotPassword) r.GetHealthCheck("", hc.HealthCheck) diff --git a/src/mocks/router/context.mock.go b/src/mocks/router/context.mock.go index 9db2501..729beeb 100644 --- a/src/mocks/router/context.mock.go +++ b/src/mocks/router/context.mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ./src/app/router/context.go -// -// Generated by this command: -// -// mockgen -source ./src/app/router/context.go -destination ./src/mocks/router/context.mock.go -// // Package mock_router is a generated GoMock package. package mock_router @@ -39,7 +34,7 @@ func (m *MockIContext) EXPECT() *MockIContextMockRecorder { } // Bind mocks base method. -func (m *MockIContext) Bind(arg0 any) error { +func (m *MockIContext) Bind(arg0 interface{}) error { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "Bind", arg0) ret0, _ := ret[0].(error) @@ -47,7 +42,7 @@ func (m *MockIContext) Bind(arg0 any) error { } // Bind indicates an expected call of Bind. -func (mr *MockIContextMockRecorder) Bind(arg0 any) *gomock.Call { +func (mr *MockIContextMockRecorder) Bind(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Bind", reflect.TypeOf((*MockIContext)(nil).Bind), arg0) } @@ -68,13 +63,13 @@ func (mr *MockIContextMockRecorder) ID() *gomock.Call { } // JSON mocks base method. -func (m *MockIContext) JSON(arg0 int, arg1 any) { +func (m *MockIContext) JSON(arg0 int, arg1 interface{}) { m.ctrl.T.Helper() m.ctrl.Call(m, "JSON", arg0, arg1) } // JSON indicates an expected call of JSON. -func (mr *MockIContextMockRecorder) JSON(arg0, arg1 any) *gomock.Call { +func (mr *MockIContextMockRecorder) JSON(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "JSON", reflect.TypeOf((*MockIContext)(nil).JSON), arg0, arg1) } @@ -117,7 +112,7 @@ func (m *MockIContext) Param(arg0 string) (string, error) { } // Param indicates an expected call of Param. -func (mr *MockIContextMockRecorder) Param(arg0 any) *gomock.Call { +func (mr *MockIContextMockRecorder) Param(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Param", reflect.TypeOf((*MockIContext)(nil).Param), arg0) } @@ -171,7 +166,7 @@ func (m *MockIContext) StoreValue(arg0, arg1 string) { } // StoreValue indicates an expected call of StoreValue. -func (mr *MockIContextMockRecorder) StoreValue(arg0, arg1 any) *gomock.Call { +func (mr *MockIContextMockRecorder) StoreValue(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "StoreValue", reflect.TypeOf((*MockIContext)(nil).StoreValue), arg0, arg1) } diff --git a/src/mocks/service/auth/auth.mock.go b/src/mocks/service/auth/auth.mock.go index df1d4ad..5115774 100644 --- a/src/mocks/service/auth/auth.mock.go +++ b/src/mocks/service/auth/auth.mock.go @@ -34,6 +34,21 @@ func (m *MockService) EXPECT() *MockServiceMockRecorder { return m.recorder } +// ForgotPassword mocks base method. +func (m *MockService) ForgotPassword(request *dto.ForgotPasswordRequest) (*dto.ForgotPasswordResponse, *dto.ResponseErr) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "ForgotPassword", request) + ret0, _ := ret[0].(*dto.ForgotPasswordResponse) + ret1, _ := ret[1].(*dto.ResponseErr) + return ret0, ret1 +} + +// ForgotPassword indicates an expected call of ForgotPassword. +func (mr *MockServiceMockRecorder) ForgotPassword(request interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ForgotPassword", reflect.TypeOf((*MockService)(nil).ForgotPassword), request) +} + // RefreshToken mocks base method. func (m *MockService) RefreshToken(arg0 *dto.RefreshTokenRequest) (*dto.Credential, *dto.ResponseErr) { m.ctrl.T.Helper() diff --git a/src/mocks/service/image/image.mock.go b/src/mocks/service/image/image.mock.go index 6e7fb6b..48da035 100644 --- a/src/mocks/service/image/image.mock.go +++ b/src/mocks/service/image/image.mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ./src/pkg/service/image/image.service.go -// -// Generated by this command: -// -// mockgen -source ./src/pkg/service/image/image.service.go -destination ./src/mocks/service/image/image.mock.go -// // Package mock_image is a generated GoMock package. package mock_image @@ -12,8 +7,8 @@ package mock_image import ( reflect "reflect" - dto "github.com/isd-sgcu/johnjud-gateway/src/app/dto" gomock "github.com/golang/mock/gomock" + dto "github.com/isd-sgcu/johnjud-gateway/src/app/dto" ) // MockService is a mock of Service interface. @@ -49,7 +44,7 @@ func (m *MockService) AssignPet(arg0 *dto.AssignPetRequest) (*dto.AssignPetRespo } // AssignPet indicates an expected call of AssignPet. -func (mr *MockServiceMockRecorder) AssignPet(arg0 any) *gomock.Call { +func (mr *MockServiceMockRecorder) AssignPet(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AssignPet", reflect.TypeOf((*MockService)(nil).AssignPet), arg0) } @@ -64,7 +59,7 @@ func (m *MockService) Delete(arg0 string) (*dto.DeleteImageResponse, *dto.Respon } // Delete indicates an expected call of Delete. -func (mr *MockServiceMockRecorder) Delete(arg0 any) *gomock.Call { +func (mr *MockServiceMockRecorder) Delete(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockService)(nil).Delete), arg0) } @@ -79,7 +74,7 @@ func (m *MockService) FindByPetId(arg0 string) ([]*dto.ImageResponse, *dto.Respo } // FindByPetId indicates an expected call of FindByPetId. -func (mr *MockServiceMockRecorder) FindByPetId(arg0 any) *gomock.Call { +func (mr *MockServiceMockRecorder) FindByPetId(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindByPetId", reflect.TypeOf((*MockService)(nil).FindByPetId), arg0) } @@ -94,7 +89,7 @@ func (m *MockService) Upload(arg0 *dto.UploadImageRequest) (*dto.ImageResponse, } // Upload indicates an expected call of Upload. -func (mr *MockServiceMockRecorder) Upload(arg0 any) *gomock.Call { +func (mr *MockServiceMockRecorder) Upload(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Upload", reflect.TypeOf((*MockService)(nil).Upload), arg0) } diff --git a/src/mocks/service/pet/pet.mock.go b/src/mocks/service/pet/pet.mock.go index 35b82b0..eba3652 100644 --- a/src/mocks/service/pet/pet.mock.go +++ b/src/mocks/service/pet/pet.mock.go @@ -1,10 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. // Source: ./src/pkg/service/pet/pet.service.go -// -// Generated by this command: -// -// mockgen -source ./src/pkg/service/pet/pet.service.go -destination ./src/mocks/service/pet/pet.mock.go -// // Package mock_pet is a generated GoMock package. package mock_pet @@ -12,8 +7,8 @@ package mock_pet import ( reflect "reflect" - dto "github.com/isd-sgcu/johnjud-gateway/src/app/dto" gomock "github.com/golang/mock/gomock" + dto "github.com/isd-sgcu/johnjud-gateway/src/app/dto" ) // MockService is a mock of Service interface. @@ -49,7 +44,7 @@ func (m *MockService) Adopt(arg0 string, arg1 *dto.AdoptByRequest) (*dto.AdoptBy } // Adopt indicates an expected call of Adopt. -func (mr *MockServiceMockRecorder) Adopt(arg0, arg1 any) *gomock.Call { +func (mr *MockServiceMockRecorder) Adopt(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Adopt", reflect.TypeOf((*MockService)(nil).Adopt), arg0, arg1) } @@ -64,7 +59,7 @@ func (m *MockService) ChangeView(arg0 string, arg1 *dto.ChangeViewPetRequest) (* } // ChangeView indicates an expected call of ChangeView. -func (mr *MockServiceMockRecorder) ChangeView(arg0, arg1 any) *gomock.Call { +func (mr *MockServiceMockRecorder) ChangeView(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "ChangeView", reflect.TypeOf((*MockService)(nil).ChangeView), arg0, arg1) } @@ -79,7 +74,7 @@ func (m *MockService) Create(arg0 *dto.CreatePetRequest) (*dto.PetResponse, *dto } // Create indicates an expected call of Create. -func (mr *MockServiceMockRecorder) Create(arg0 any) *gomock.Call { +func (mr *MockServiceMockRecorder) Create(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Create", reflect.TypeOf((*MockService)(nil).Create), arg0) } @@ -94,7 +89,7 @@ func (m *MockService) Delete(arg0 string) (*dto.DeleteResponse, *dto.ResponseErr } // Delete indicates an expected call of Delete. -func (mr *MockServiceMockRecorder) Delete(arg0 any) *gomock.Call { +func (mr *MockServiceMockRecorder) Delete(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Delete", reflect.TypeOf((*MockService)(nil).Delete), arg0) } @@ -109,7 +104,7 @@ func (m *MockService) FindAll(arg0 *dto.FindAllPetRequest) (*dto.FindAllPetRespo } // FindAll indicates an expected call of FindAll. -func (mr *MockServiceMockRecorder) FindAll(arg0 any) *gomock.Call { +func (mr *MockServiceMockRecorder) FindAll(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindAll", reflect.TypeOf((*MockService)(nil).FindAll), arg0) } @@ -124,7 +119,7 @@ func (m *MockService) FindOne(arg0 string) (*dto.PetResponse, *dto.ResponseErr) } // FindOne indicates an expected call of FindOne. -func (mr *MockServiceMockRecorder) FindOne(arg0 any) *gomock.Call { +func (mr *MockServiceMockRecorder) FindOne(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "FindOne", reflect.TypeOf((*MockService)(nil).FindOne), arg0) } @@ -139,7 +134,7 @@ func (m *MockService) Update(arg0 string, arg1 *dto.UpdatePetRequest) (*dto.PetR } // Update indicates an expected call of Update. -func (mr *MockServiceMockRecorder) Update(arg0, arg1 any) *gomock.Call { +func (mr *MockServiceMockRecorder) Update(arg0, arg1 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Update", reflect.TypeOf((*MockService)(nil).Update), arg0, arg1) } diff --git a/src/pkg/service/auth/auth.service.go b/src/pkg/service/auth/auth.service.go index cc003a1..c527153 100644 --- a/src/pkg/service/auth/auth.service.go +++ b/src/pkg/service/auth/auth.service.go @@ -10,4 +10,5 @@ type Service interface { SignOut(string) (*dto.SignOutResponse, *dto.ResponseErr) Validate(string) (*dto.TokenPayloadAuth, *dto.ResponseErr) RefreshToken(*dto.RefreshTokenRequest) (*dto.Credential, *dto.ResponseErr) + ForgotPassword(request *dto.ForgotPasswordRequest) (*dto.ForgotPasswordResponse, *dto.ResponseErr) }