customer

package
v0.0.0-...-f242e82 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VerificationURLPath            = "/v1/customerapp/customers/verify"
	ChangeEmailVerificationURLPath = "/v1/customerapp/customers/verify-change-email"

	VerficationStatusVerified    = "VERIFIED"
	VerificationStatusUnverified = "UNVERIFIED"

	MemberStatusActive   = "ACTIVE"
	MemberStatusInactive = "INACTIVE"
)

Variables

This section is empty.

Functions

func InitHTTPHandler

func InitHTTPHandler(router *mux.Router, customerSession *middleware.CustomerSession, validate *validator.Validate, customerUseCase CustomerUseCase)

Types

type ChangeEmailEvent

type ChangeEmailEvent struct {
	ID              int64  `json:"id"`
	Name            string `json:"name"`
	ExistingEmail   string `json:"existing_email"`
	NewEmail        string `json:"new_email"`
	VerficationLink string `json:"verification_link"`
}

type ChangeEmailRequest

type ChangeEmailRequest struct {
	Email string `json:"email" validate:"email"`
}

type ChangeEmailResponse

type ChangeEmailResponse struct {
	VerificationExpiresAt time.Time `json:"verification_expires_at"`
}

type ChangeEmailVerificationRequest

type ChangeEmailVerificationRequest struct {
	Token string
}

type ChangePasswordRequest

type ChangePasswordRequest struct {
	ExistingPassword string `json:"existing_password" validate:"required"`
	NewPassword      string `json:"new_password" validate:"required"`
}

type Customer

type Customer struct {
	ID                 int64
	Name               string
	Email              string
	Password           string
	PasswordSalt       string
	VerificationStatus string
	MemberStatus       string
	CreatedAt          time.Time
	UpdatedAt          time.Time
}

type CustomerRepository

type CustomerRepository interface {
	Save(ctx context.Context, c Customer, tx *sql.Tx) (int64, error)
	FindByID(ctx context.Context, ID int64, tx *sql.Tx) (Customer, error)
	FindByEmail(ctx context.Context, email string, tx *sql.Tx) (Customer, error)
	Update(ctx context.Context, ID int64, update Customer, tx *sql.Tx) error
}

func NewCustomerRepository

func NewCustomerRepository(logger *logrus.Logger, db *sql.DB) CustomerRepository

type CustomerUseCase

type CustomerUseCase interface {
	SignUp(ctx context.Context, req SignUpRequest) (SignUpResponse, error)
	SignIn(ctx context.Context, req SignInRequest) (SignInResponse, error)
	SignOut(ctx context.Context) error
	GetProfile(ctx context.Context) (GetProfileResponse, error)
	UpdateProfile(ctx context.Context, req UpdateProfileRequest) error
	ChangeEmail(ctx context.Context, req ChangeEmailRequest) (ChangeEmailResponse, error)
	ChangePassword(ctx context.Context, req ChangePasswordRequest) error
	Verify(ctx context.Context, req VerifyRequest) error
	VerifyChangeEmail(ctx context.Context, req ChangeEmailVerificationRequest) error
}

func NewCustomerUseCase

func NewCustomerUseCase(props CustomerUseCaseProperty) CustomerUseCase

type CustomerUseCaseProperty

type CustomerUseCaseProperty struct {
	AppName            string
	Logger             *logrus.Logger
	Timeout            time.Duration
	TMUserBaseURL      string
	CryptoSecret       string
	JSONWebToken       *jwt.JSONWebToken
	Session            session.Session
	Cache              redis.UniversalClient
	Publisher          pubsub.Publisher
	CustomerRepository CustomerRepository
}

type GetProfileResponse

type GetProfileResponse struct {
	ID                 int64     `json:"id"`
	Name               string    `json:"name"`
	Email              string    `json:"email"`
	VerificationStatus string    `json:"verification_status"`
	MemberStatus       string    `json:"member_status"`
	CreatedAt          time.Time `json:"created_at"`
	UpdatedAt          time.Time `json:"updated_at"`
}

type HTTPHandler

type HTTPHandler struct {
	SessionMiddleware *middleware.AdminSession
	Validate          *validator.Validate
	CustomerUseCase   CustomerUseCase
}

func (HTTPHandler) ChangeEmail

func (handler HTTPHandler) ChangeEmail(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) ChangePassword

func (handler HTTPHandler) ChangePassword(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) GetProfile

func (handler HTTPHandler) GetProfile(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) SignIn

func (handler HTTPHandler) SignIn(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) SignOut

func (handler HTTPHandler) SignOut(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) SignUp

func (handler HTTPHandler) SignUp(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) UpdateProfile

func (handler HTTPHandler) UpdateProfile(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) Verify

func (handler HTTPHandler) Verify(w http.ResponseWriter, r *http.Request)

func (HTTPHandler) VerifyChangeEmail

func (handler HTTPHandler) VerifyChangeEmail(w http.ResponseWriter, r *http.Request)

type SignInRequest

type SignInRequest struct {
	Email    string `json:"email" validate:"required"`
	Password string `json:"password" validate:"required"`
}

type SignInResponse

type SignInResponse struct {
	Token     string    `json:"token"`
	ExpiresAt time.Time `json:"expires_at"`
}

type SignUpEvent

type SignUpEvent struct {
	ID                 int64     `json:"id"`
	Name               string    `json:"name"`
	Email              string    `json:"email"`
	VerificationStatus string    `json:"verification_status"`
	MemberStatus       string    `json:"member_status"`
	VerificationLink   string    `json:"verification_link"`
	CreatedAt          time.Time `json:"created_at"`
}

type SignUpRequest

type SignUpRequest struct {
	Name     string `json:"name" validate:"required"`
	Email    string `json:"email" validate:"email"`
	Password string `json:"password" validate:"required"`
}

type SignUpResponse

type SignUpResponse struct {
	VerificationExpiresAt time.Time `json:"verification_expires_at"`
}

type UpdateProfileRequest

type UpdateProfileRequest struct {
	Name string `json:"name"`
}

type VerifyRequest

type VerifyRequest struct {
	Token string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL