scrumbus

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package scrumbus provides business access to scrum domain.

Index

Constants

View Source
const (
	OrderByID = "scrum_id"
)

Set of fields that the results can be ordered by.

Variables

View Source
var (
	ErrNotFound     = errors.New("scrum not found")
	ErrUserDisabled = errors.New("user disabled")
)

Set of error variables for CRUD operations.

View Source
var DefaultOrderBy = order.NewBy(OrderByID, order.ASC)

DefaultOrderBy represents the default way we sort.

Functions

This section is empty.

Types

type Address

type Address struct {
	Address1 string // We should create types for these fields.
	Address2 string
	ZipCode  string
	City     string
	State    string
	Country  string
}

Address represents an individual address.

type Business

type Business struct {
	// contains filtered or unexported fields
}

Business manages the set of APIs for scrum api access.

func NewBusiness

func NewBusiness(log *logger.Logger, userBus *userbus.Business, delegate *delegate.Delegate, storer Storer) *Business

NewBusiness constructs a scrum business API for use.

func (*Business) Count

func (b *Business) Count(ctx context.Context, filter QueryFilter) (int, error)

Count returns the total number of scrums.

func (*Business) Create

func (b *Business) Create(ctx context.Context, ns NewScrum) (Scrum, error)

Create adds a new scrum to the system.

func (*Business) Delete

func (b *Business) Delete(ctx context.Context, scrum Scrum) error

Delete removes the specified scrum.

func (*Business) NewWithTx

func (b *Business) NewWithTx(tx sqldb.CommitRollbacker) (*Business, error)

NewWithTx constructs a new domain value that will use the specified transaction in any store related calls.

func (*Business) Query

func (b *Business) Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Scrum, error)

Query retrieves a list of existing scrums.

func (*Business) QueryByID

func (b *Business) QueryByID(ctx context.Context, scrumID uuid.UUID) (Scrum, error)

QueryByID finds the scrum by the specified ID.

func (*Business) QueryByUserID

func (b *Business) QueryByUserID(ctx context.Context, userID uuid.UUID) ([]Scrum, error)

QueryByUserID finds the scrums by a specified User ID.

func (*Business) Update

func (b *Business) Update(ctx context.Context, scrum Scrum, uh UpdateScrum) (Scrum, error)

Update modifies information about a scrum.

type NewScrum

type NewScrum struct {
	UserID uuid.UUID

	Name      string
	Time      int
	Color     string
	Attendees []string
}

NewScrum is what we require from clients when adding a Scrum.

func TestGenerateNewScrums

func TestGenerateNewScrums(n int, userID uuid.UUID) []NewScrum

TestGenerateNewScrums is a helper method for testing.

type QueryFilter

type QueryFilter struct {
	ID               *uuid.UUID
	UserID           *uuid.UUID
	Name             *string
	StartCreatedDate *time.Time
	EndCreatedDate   *time.Time
}

QueryFilter holds the available fields a query can be filtered on. We are using pointer semantics because the With API mutates the value.

type Scrum

type Scrum struct {
	ID          uuid.UUID
	Name        string
	Time        int
	Color       string
	Attendees   []string
	UserID      uuid.UUID
	DateCreated time.Time
	DateUpdated time.Time
}

Scrum represents an individual scrum.

func TestGenerateSeedScrums

func TestGenerateSeedScrums(ctx context.Context, n int, api *Business, userID uuid.UUID) ([]Scrum, error)

TestGenerateSeedScrums is a helper method for testing.

type Storer

type Storer interface {
	NewWithTx(tx sqldb.CommitRollbacker) (Storer, error)
	Create(ctx context.Context, scrum Scrum) error
	Update(ctx context.Context, scrum Scrum) error
	Delete(ctx context.Context, scrum Scrum) error
	Query(ctx context.Context, filter QueryFilter, orderBy order.By, page page.Page) ([]Scrum, error)
	Count(ctx context.Context, filter QueryFilter) (int, error)
	QueryByID(ctx context.Context, scrumID uuid.UUID) (Scrum, error)
	QueryByUserID(ctx context.Context, userID uuid.UUID) ([]Scrum, error)
}

Storer interface declares the behaviour this package needs to persist and retrieve data.

type UpdateScrum

type UpdateScrum struct {
	UserID    *string
	Name      *string
	Time      *int
	Color     *string
	Attendees []string
}

UpdateScrum defines what information may be provided to modify an existing Scrum. All fields are optional so clients can send only 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 exception around marshalling/unmarshalling.

Directories

Path Synopsis
stores
scrumdb
Package scrumdb contains scrum related CRUD functionality.
Package scrumdb contains scrum related CRUD functionality.

Jump to

Keyboard shortcuts

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