Documentation ¶
Index ¶
- Variables
- type Bookmark
- type FakeRepository
- func (r *FakeRepository) BookmarkAdd(bookmark Bookmark) error
- func (r *FakeRepository) BookmarkDelete(userUUID, uid string) error
- func (r *FakeRepository) BookmarkGetAll(userUUID string) ([]Bookmark, error)
- func (r *FakeRepository) BookmarkGetByTag(userUUID string, tag string) ([]Bookmark, error)
- func (r *FakeRepository) BookmarkGetByUID(userUUID, uid string) (Bookmark, error)
- func (r *FakeRepository) BookmarkGetByURL(userUUID, u string) (Bookmark, error)
- func (r *FakeRepository) BookmarkIsURLRegistered(userUUID, url string) (bool, error)
- func (r *FakeRepository) BookmarkIsURLRegisteredToAnotherUID(userUUID, url, uid string) (bool, error)
- func (r *FakeRepository) BookmarkTagUpdateMany(bookmarks []Bookmark) (int64, error)
- func (r *FakeRepository) BookmarkUpdate(bookmark Bookmark) error
- type Repository
- type Service
- func (s *Service) Add(bookmark Bookmark) error
- func (s *Service) All(userUUID string) ([]Bookmark, error)
- func (s *Service) ByUID(userUUID string, uid string) (Bookmark, error)
- func (s *Service) ByURL(userUUID string, u string) (Bookmark, error)
- func (s *Service) Delete(userUUID, uid string) error
- func (s *Service) DeleteTag(dq TagDeleteQuery) (int64, error)
- func (s *Service) Update(bookmark Bookmark) error
- func (s *Service) UpdateTag(uq TagUpdateQuery) (int64, error)
- type TagDeleteQuery
- type TagUpdateQuery
- type ValidationRepository
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound error = errors.New("not found") ErrTagNameContainsWhitespace error = errors.New("tag name contains whitespace") ErrTagNameRequired error = errors.New("tag name required") ErrTagNewNameEqualsCurrentName error = errors.New("new tag name is the same as current tag name") ErrTitleRequired error = errors.New("title required") ErrUIDInvalid error = errors.New("invalid UID") ErrUIDRequired error = errors.New("UID required") ErrURLAlreadyRegistered error = errors.New("URL already registered") ErrURLInvalid error = errors.New("invalid URL") ErrURLNoHost error = errors.New("URL has no host") ErrURLNoScheme error = errors.New("URL has no scheme") ErrURLRequired error = errors.New("URL required") ErrUserUUIDRequired error = errors.New("user UUID required") )
Functions ¶
This section is empty.
Types ¶
type Bookmark ¶
type Bookmark struct { UID string UserUUID string URL string Title string Description string Private bool Tags []string CreatedAt time.Time UpdatedAt time.Time }
Bookmark represents a Web bookmark.
func NewBookmark ¶
NewBookmark initializes and returns a new Bookmark.
func (*Bookmark) Normalize ¶
func (b *Bookmark) Normalize()
Normalize sanitizes and normalizes all fields.
func (*Bookmark) ValidateForAddition ¶
func (b *Bookmark) ValidateForAddition(r ValidationRepository) error
ValidateForAddition ensures mandatory fields are properly set when adding an new Bookmark.
func (*Bookmark) ValidateForUpdate ¶
func (b *Bookmark) ValidateForUpdate(r Repository) error
ValidateForUpdate ensures mandatory fields are properly set when updating an existing Bookmark.
type FakeRepository ¶
type FakeRepository struct {
Bookmarks []Bookmark
}
func (*FakeRepository) BookmarkAdd ¶
func (r *FakeRepository) BookmarkAdd(bookmark Bookmark) error
func (*FakeRepository) BookmarkDelete ¶
func (r *FakeRepository) BookmarkDelete(userUUID, uid string) error
func (*FakeRepository) BookmarkGetAll ¶
func (r *FakeRepository) BookmarkGetAll(userUUID string) ([]Bookmark, error)
func (*FakeRepository) BookmarkGetByTag ¶
func (r *FakeRepository) BookmarkGetByTag(userUUID string, tag string) ([]Bookmark, error)
func (*FakeRepository) BookmarkGetByUID ¶
func (r *FakeRepository) BookmarkGetByUID(userUUID, uid string) (Bookmark, error)
func (*FakeRepository) BookmarkGetByURL ¶
func (r *FakeRepository) BookmarkGetByURL(userUUID, u string) (Bookmark, error)
func (*FakeRepository) BookmarkIsURLRegistered ¶
func (r *FakeRepository) BookmarkIsURLRegistered(userUUID, url string) (bool, error)
func (*FakeRepository) BookmarkIsURLRegisteredToAnotherUID ¶
func (r *FakeRepository) BookmarkIsURLRegisteredToAnotherUID(userUUID, url, uid string) (bool, error)
func (*FakeRepository) BookmarkTagUpdateMany ¶
func (r *FakeRepository) BookmarkTagUpdateMany(bookmarks []Bookmark) (int64, error)
func (*FakeRepository) BookmarkUpdate ¶
func (r *FakeRepository) BookmarkUpdate(bookmark Bookmark) error
type Repository ¶
type Repository interface { ValidationRepository // BookmarkAdd adds a new bookmark for the logged in user. BookmarkAdd(bookmark Bookmark) error // BookmarkDelete deletes a given bookmark for the logged in user. BookmarkDelete(userUUID, uid string) error // BookmarkGetAll returns all bookmarks for a given user UUID. BookmarkGetAll(userUUID string) ([]Bookmark, error) // BookmarkGetByTag returns all bookmarks for a given user UUID and tag. BookmarkGetByTag(userUUID string, tag string) ([]Bookmark, error) // BookmarkGetByUID returns the bookmark for a given user UUID and UID. BookmarkGetByUID(userUUID, uid string) (Bookmark, error) // BookmarkGetByURL returns the bookmark for a given user UUID and URL. BookmarkGetByURL(userUUID, u string) (Bookmark, error) // BookmarkTagUpdateMany updates a tag for collection of existing bookmarks. BookmarkTagUpdateMany(bookmarks []Bookmark) (int64, error) // BookmarkUpdate updates an existing bookmark for the logged in user. BookmarkUpdate(bookmark Bookmark) error }
Repository provides access to user bookmarks.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service handles operations for the bookmark domain.
func NewService ¶
func NewService(r Repository) *Service
NewService initializes and returns a bookmark Service.
func (*Service) DeleteTag ¶
func (s *Service) DeleteTag(dq TagDeleteQuery) (int64, error)
DeleteTag deletes a given tag from all bookmarks for a given user.
type TagDeleteQuery ¶
TagDeleteQuery represents a tag deletion for all bookmarks of an authenticated user.
type TagUpdateQuery ¶
TagUpdateQuery represents a tag name update for all bookmarks for an authenticated user.
type ValidationRepository ¶
type ValidationRepository interface { // BookmarkIsURLRegistered returns whether a user has already saved a // bookmark with a given URL. BookmarkIsURLRegistered(userUUID, url string) (bool, error) // BookmarkIsURLRegisteredToAnotherUID returns whether a user has already // saved a bookmark with a given URL and a different UID. BookmarkIsURLRegisteredToAnotherUID(userUUID, url, uid string) (bool, error) }
ValidationRepository provides methods for Bookmark validation.