Documentation ¶
Overview ¶
Package workspace_user provides an example of a core business API. Right now these calls are just wrapping the data/data layer. But at some point you will want auditing or something that isn't specific to the data/store layer.
Index ¶
- Variables
- type Core
- func (c Core) Create(ctx context.Context, workspaceID string, userID string, now time.Time) (WorkspaceUser, error)
- func (c Core) Delete(ctx context.Context, workspaceUserID string) error
- func (c Core) InviteUser(ctx context.Context, workspaceID string, ni InviteUsers, now time.Time) ([]WorkspaceUser, error)
- func (c Core) Query(ctx context.Context, workspaceID string, pageNumber int, rowsPerPage int) ([]WorkspaceUser, error)
- func (c Core) QueryByID(ctx context.Context, workspaceUserID string) (WorkspaceUser, error)
- func (c Core) QueryByuIDwID(ctx context.Context, workspaceID, userID string) (WorkspaceUser, error)
- func (c Core) Update(ctx context.Context, workspaceUserID string, uwu UpdateWorkspaceUser, ...) error
- type InviteUsers
- type UpdateWorkspaceUser
- type WorkspaceUser
Constants ¶
This section is empty.
Variables ¶
var ( ErrNotFound = errors.New("user not found") ErrInvalidID = errors.New("ID is not in its proper form") )
Set of error variables for CRUD operations.
Functions ¶
This section is empty.
Types ¶
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core manages the set of APIs for user access.
func NewCore ¶
func NewCore(log *zap.SugaredLogger, sqlxDB *sqlx.DB) Core
NewCore constructs a core for user api access.
func (Core) Create ¶
func (c Core) Create(ctx context.Context, workspaceID string, userID string, now time.Time) (WorkspaceUser, error)
Create add a user to a workspace.
func (Core) InviteUser ¶
func (c Core) InviteUser(ctx context.Context, workspaceID string, ni InviteUsers, now time.Time) ([]WorkspaceUser, error)
InviteUser invites a user to a workspace.
func (Core) Query ¶
func (c Core) Query(ctx context.Context, workspaceID string, pageNumber int, rowsPerPage int) ([]WorkspaceUser, error)
Query retrieves a list of existing workspace users from the database.
func (Core) QueryByuIDwID ¶
QueryByuIDwID gets the specified workspaceUser from the database.
type InviteUsers ¶
type InviteUsers struct { Emails []string `json:"emails" validate:"required"` InviterID string `json:"inviter_id" validate:"required"` }
InviteUsers contains information to invite users to a workspace.
type UpdateWorkspaceUser ¶
UpdateWorkspaceUser defines what information may be provided to modify an existing client. All fields are optional so clients can send just the fields they want changed. It uses pointer fields ,so we can differentiate between a field that was not provided and a field that was provided as explicitly blank. Normally we do not want to use pointers to basic types ,but we make exceptions around marshalling/unmarshalling.
type WorkspaceUser ¶
type WorkspaceUser struct { ID string `json:"id"` Uid string `json:"uid"` Wid string `json:"wid"` Admin bool `json:"admin"` Active bool `json:"active"` InviteKey string `json:"invite_key"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` }
WorkspaceUser represents a workspace user