Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrorForbidden = Response{Code: http.StatusForbidden, Message: "Forbidden"} ErrorRequiredField = Response{Code: http.StatusBadRequest, Message: "Required field"} ErrorInternal = Response{Code: http.StatusInternalServerError, Message: "Internal Server Error"} ErrorBadRequest = Response{Code: http.StatusBadRequest, Message: "Bad Request"} ErrorNoRecords = Response{Code: http.StatusOK, Message: "No records found"} ErrorNotFound = Response{Code: http.StatusNotFound, Message: "No records found"} ErrFriendAlreadyExists = Response{Code: http.StatusBadRequest, Message: "Friend had already been added"} ErrFriendNotExists = Response{Code: http.StatusNotFound, Message: "Friend is not found"} ErrCannotAddSelf = Response{Code: http.StatusBadRequest, Message: "Cannot add self as friend"} ErrCannotDeleteSelf = Response{Code: http.StatusBadRequest, Message: "Cannot delete self as friend"} ErrNotFriend = Response{Code: http.StatusBadRequest, Message: "Cannot delete non friend"} )
View Source
var ( SuccessCreateResponse = Response{Code: 200, Message: "Friend added successfully"} SuccessDeleteResponse = Response{Code: 200, Message: "Friend deleted successfully"} )
Functions ¶
This section is empty.
Types ¶
type CreateUserFriendPayload ¶
func (CreateUserFriendPayload) Validate ¶
func (p CreateUserFriendPayload) Validate() error
type DeleteUserFriendPayload ¶
func (DeleteUserFriendPayload) Validate ¶
func (p DeleteUserFriendPayload) Validate() error
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
func NewHandler ¶
func (*Handler) CreateUserFriends ¶
func (h *Handler) CreateUserFriends(w http.ResponseWriter, r *http.Request)
func (*Handler) DeleteUserFriends ¶
func (h *Handler) DeleteUserFriends(w http.ResponseWriter, r *http.Request)
type Repository ¶
type Repository interface { AddFriend(ctx context.Context, userFriend *UserFriends) error RemoveFriend(ctx context.Context, userID string, friendID string) error GetByFriendID(ctx context.Context, userID string, friendID string) (*UserFriends, error) ListByUserID(ctx context.Context, userID string) ([]*UserFriends, error) }
func NewRepository ¶
func NewRepository(db *db.DB) Repository
type Service ¶
type Service interface { Create(ctx context.Context, req CreateUserFriendPayload) Response Delete(ctx context.Context, req DeleteUserFriendPayload) Response }
func NewService ¶
func NewService(repository Repository, userRepository user.Repository) Service
Click to show internal directories.
Click to hide internal directories.