Skip to content

Commit

Permalink
chore: rename sign in request dto
Browse files Browse the repository at this point in the history
  • Loading branch information
Nitiwat-owen committed Dec 27, 2023
1 parent 2538cc0 commit 4d2d048
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/app/dto/auth.dto.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type SignupResponse struct {
Lastname string `json:"lastname"`
}

type SignIn struct {
type SignInRequest struct {
Email string `json:"email" validate:"required,email"`
Password string `json:"password" validate:"required,gte=6,lte=30"`
}
4 changes: 2 additions & 2 deletions src/app/handler/auth/auth.handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ func (h *Handler) Signup(c router.IContext) {
// SignIn is a function that authenticate user with email and password
// @Summary Sign in user
// @Description Return the credential of user including access token and refresh token
// @Param signIn body dto.SignIn true "signIn request dto"
// @Param signIn body dto.SignInRequest true "signIn request dto"
// @Tags auth
// @Accept json
// @Produce json
Expand All @@ -90,7 +90,7 @@ func (h *Handler) Signup(c router.IContext) {
// @Failure 503 {object} dto.ResponseServiceDownErr "Service is down"
// @Router /v1/auth/signin [post]
func (h *Handler) SignIn(c router.IContext) {
request := &dto.SignIn{}
request := &dto.SignInRequest{}
err := c.Bind(request)
if err != nil {
c.JSON(http.StatusBadRequest, dto.ResponseErr{
Expand Down
4 changes: 2 additions & 2 deletions src/app/handler/auth/auth.handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
type AuthHandlerTest struct {
suite.Suite
signupRequest *dto.SignupRequest
signInRequest *dto.SignIn
signInRequest *dto.SignInRequest
bindErr error
validateErr []*dto.BadReqErrResponse
}
Expand All @@ -29,7 +29,7 @@ func TestAuthHandler(t *testing.T) {

func (t *AuthHandlerTest) SetupTest() {
signupRequest := &dto.SignupRequest{}
signInRequest := &dto.SignIn{}
signInRequest := &dto.SignInRequest{}
bindErr := errors.New("Binding request failed")
validateErr := []*dto.BadReqErrResponse{
{
Expand Down
2 changes: 1 addition & 1 deletion src/app/service/auth/auth.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func (s *Service) Signup(request *dto.SignupRequest) (*dto.SignupResponse, *dto.
}, nil
}

func (s *Service) SignIn(signIn *dto.SignIn) (*dto.Credential, *dto.ResponseErr) {
func (s *Service) SignIn(signIn *dto.SignInRequest) (*dto.Credential, *dto.ResponseErr) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

Expand Down
4 changes: 2 additions & 2 deletions src/app/service/auth/auth.service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (
type AuthServiceTest struct {
suite.Suite
signupRequestDto *dto.SignupRequest
signInDto *dto.SignIn
signInDto *dto.SignInRequest
token string
}

Expand All @@ -32,7 +32,7 @@ func (t *AuthServiceTest) SetupTest() {
Firstname: faker.FirstName(),
Lastname: faker.LastName(),
}
signInDto := &dto.SignIn{
signInDto := &dto.SignInRequest{
Email: faker.Email(),
Password: faker.Password(),
}
Expand Down
4 changes: 2 additions & 2 deletions src/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const docTemplate = `{
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.SignIn"
"$ref": "#/definitions/dto.SignInRequest"
}
}
],
Expand Down Expand Up @@ -240,7 +240,7 @@ const docTemplate = `{
}
}
},
"dto.SignIn": {
"dto.SignInRequest": {
"type": "object",
"required": [
"email",
Expand Down
4 changes: 2 additions & 2 deletions src/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.SignIn"
"$ref": "#/definitions/dto.SignInRequest"
}
}
],
Expand Down Expand Up @@ -236,7 +236,7 @@
}
}
},
"dto.SignIn": {
"dto.SignInRequest": {
"type": "object",
"required": [
"email",
Expand Down
4 changes: 2 additions & 2 deletions src/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ definitions:
example: 503
type: integer
type: object
dto.SignIn:
dto.SignInRequest:
properties:
email:
type: string
Expand Down Expand Up @@ -133,7 +133,7 @@ paths:
name: signIn
required: true
schema:
$ref: '#/definitions/dto.SignIn'
$ref: '#/definitions/dto.SignInRequest'
produces:
- application/json
responses:
Expand Down
2 changes: 1 addition & 1 deletion src/mocks/service/auth/auth.mock.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/pkg/service/auth/auth.service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (

type Service interface {
Signup(*dto.SignupRequest) (*dto.SignupResponse, *dto.ResponseErr)
SignIn(*dto.SignIn) (*dto.Credential, *dto.ResponseErr)
SignIn(*dto.SignInRequest) (*dto.Credential, *dto.ResponseErr)
SignOut(string) (bool, *dto.ResponseErr)
Validate(string) (*dto.TokenPayloadAuth, *dto.ResponseErr)
RefreshToken(string) (*auth_proto.Credential, *dto.ResponseErr)
Expand Down

0 comments on commit 4d2d048

Please sign in to comment.