Documentation ¶
Overview ¶
Package workspace 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, nw NewWorkspace, now time.Time) (Workspace, error)
- func (c Core) Query(ctx context.Context, userID string, pageNumber int, rowsPerPage int) ([]Workspace, error)
- func (c Core) QueryByID(ctx context.Context, workspaceID string) (Workspace, error)
- func (c Core) Update(ctx context.Context, workspaceID string, uw UpdateWorkspace, now time.Time) error
- func (c Core) UpdateLogo(ctx context.Context, workspaceID string, uw UpdateWorkspace, now time.Time) error
- type NewWorkspace
- type UpdateWorkspace
- type Workspace
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) Query ¶
func (c Core) Query(ctx context.Context, userID string, pageNumber int, rowsPerPage int) ([]Workspace, error)
Query retrieves a list of existing workspace from the database.
func (Core) Update ¶
func (c Core) Update(ctx context.Context, workspaceID string, uw UpdateWorkspace, now time.Time) error
Update replaces a workspace document in the database.
func (Core) UpdateLogo ¶
func (c Core) UpdateLogo(ctx context.Context, workspaceID string, uw UpdateWorkspace, now time.Time) error
UpdateLogo replaces a user document in the database.
type NewWorkspace ¶
type NewWorkspace struct { Name string `json:"name" validate:"required"` Uid string `json:"uid" validate:"required"` }
NewWorkspace contains information needed to create a new Group.
type UpdateWorkspace ¶
type UpdateWorkspace struct { Name *string `json:"name"` DefaultHourlyRate *float32 `json:"default_hourly_rate"` DefaultCurrency *string `json:"default_currency"` OnlyAdminMayCreateProjects *bool `json:"only_admin_may_create_projects"` OnlyAdminSeeBillableRates *bool `json:"only_admin_see_billable_rates"` OnlyAdminSeeTeamDashboard *bool `json:"only_admin_see_team_dashboard"` Rounding *int `json:"rounding" validate:"omitempty,eq=0|eq=1|eq=-1"` RoundingMinutes *int `json:"rounding_minutes"` LogoURL string `json:"logo_url"` }
UpdateWorkspace defines what information may be provided to modify an existing group. All fields are optional so group 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 Workspace ¶
type Workspace struct { ID string `json:"id"` Name string `json:"name"` Uid string `json:"uid"` DefaultHourlyRate float32 `json:"default_hourly_rate"` DefaultCurrency string `json:"default_currency"` OnlyAdminMayCreateProjects bool `json:"only_admin_may_create_projects"` OnlyAdminSeeBillableRates bool `json:"only_admin_see_billable_rates"` OnlyAdminSeeTeamDashboard bool `json:"only_admin_see_team_dashboard"` Rounding int `json:"rounding"` RoundingMinutes int `json:"rounding_minutes"` DateCreated time.Time `json:"date_created"` DateUpdated time.Time `json:"date_updated"` LogoURL string `json:"logo_url"` }
Workspace represents an individual Group.