Documentation ¶
Overview ¶
Package home provides a business access to home data in the system.
Index ¶
- Constants
- Variables
- type Address
- type Core
- func (c *Core) Count(ctx context.Context, filter QueryFilter) (int, error)
- func (c *Core) Create(ctx context.Context, nh NewHome) (Home, error)
- func (c *Core) Delete(ctx context.Context, hme Home) error
- func (c *Core) ExecuteUnderTransaction(tx transaction.Transaction) (*Core, error)
- func (c *Core) Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, ...) ([]Home, error)
- func (c *Core) QueryByID(ctx context.Context, homeID uuid.UUID) (Home, error)
- func (c *Core) QueryByUserID(ctx context.Context, userID uuid.UUID) ([]Home, error)
- func (c *Core) Update(ctx context.Context, hme Home, uh UpdateHome) (Home, error)
- type Home
- type NewHome
- type QueryFilter
- func (qf *QueryFilter) Validate() error
- func (qf *QueryFilter) WithEndCreatedDate(endDate time.Time)
- func (qf *QueryFilter) WithHomeID(homeID uuid.UUID)
- func (qf *QueryFilter) WithHomeType(homeType Type)
- func (qf *QueryFilter) WithStartDateCreated(startDate time.Time)
- func (qf *QueryFilter) WithUserID(userID uuid.UUID)
- type Storer
- type Type
- type UpdateAddress
- type UpdateHome
Constants ¶
const ( OrderByID = "home_id" OrderByType = "type" OrderByUserID = "user_id" )
Set of fields that the results can be ordered by.
Variables ¶
var ( ErrNotFound = errors.New("home not found") ErrUserDisabled = errors.New("user disabled") )
Set of error variables for CRUD operations.
var ( TypeSingle = Type{"SINGLE FAMILY"} TypeCondo = Type{"CONDO"} )
Set of possible roles for a housing type.
DefaultOrderBy represents the default way we sort.
Functions ¶
This section is empty.
Types ¶
type Address ¶
type Address struct { Address1 string Address2 string ZipCode string City string State string Country string }
Address represents an individual address.
type Core ¶
type Core struct {
// contains filtered or unexported fields
}
Core manages the set of APIs for home api access.
func NewCore ¶
func NewCore(log *logger.Logger, usrCore *user.Core, delegate *delegate.Delegate, storer Storer) *Core
NewCore constructs a home core API for use.
func (*Core) ExecuteUnderTransaction ¶
func (c *Core) ExecuteUnderTransaction(tx transaction.Transaction) (*Core, error)
ExecuteUnderTransaction constructs a new Core value that will use the specified transaction in any store related calls.
func (*Core) Query ¶
func (c *Core) Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, rowsPerPage int) ([]Home, error)
Query retrieves a list of existing homes.
func (*Core) QueryByUserID ¶
QueryByUserID finds the homes by a specified User ID.
type Home ¶
type Home struct { ID uuid.UUID UserID uuid.UUID Type Type Address Address DateCreated time.Time DateUpdated time.Time }
Home represents an individual home.
type QueryFilter ¶
type QueryFilter struct { ID *uuid.UUID UserID *uuid.UUID Type *Type 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.
func (*QueryFilter) Validate ¶
func (qf *QueryFilter) Validate() error
Validate can perform a check of the data against the validate tags.
func (*QueryFilter) WithEndCreatedDate ¶
func (qf *QueryFilter) WithEndCreatedDate(endDate time.Time)
WithEndCreatedDate sets the EndCreatedDate field of the QueryFilter value.
func (*QueryFilter) WithHomeID ¶
func (qf *QueryFilter) WithHomeID(homeID uuid.UUID)
WithHomeID sets the ID field of the QueryFilter value.
func (*QueryFilter) WithHomeType ¶
func (qf *QueryFilter) WithHomeType(homeType Type)
WithHomeType sets the Type field of the QueryFilter value.
func (*QueryFilter) WithStartDateCreated ¶
func (qf *QueryFilter) WithStartDateCreated(startDate time.Time)
WithStartDateCreated sets the StartCreatedDate field of the QueryFilter value.
func (*QueryFilter) WithUserID ¶
func (qf *QueryFilter) WithUserID(userID uuid.UUID)
WithUserID sets the ID field of the QueryFilter value.
type Storer ¶
type Storer interface { ExecuteUnderTransaction(tx transaction.Transaction) (Storer, error) Create(ctx context.Context, hme Home) error Update(ctx context.Context, hme Home) error Delete(ctx context.Context, hme Home) error Query(ctx context.Context, filter QueryFilter, orderBy order.By, pageNumber int, rowsPerPage int) ([]Home, error) Count(ctx context.Context, filter QueryFilter) (int, error) QueryByID(ctx context.Context, homeID uuid.UUID) (Home, error) QueryByUserID(ctx context.Context, userID uuid.UUID) ([]Home, error) }
Storer interface declares the behaviour this package needs to persist and retrieve data.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type represents a type in the system.
func MustParseType ¶
MustParseType parses the string value and returns a type if one exists. If an error occurs the function panics.
func (Type) MarshalText ¶
MarshalText implement the marshal interface for JSON conversions.
func (*Type) UnmarshalText ¶
UnmarshalText implement the unmarshal interface for JSON conversions.
type UpdateAddress ¶
type UpdateAddress struct { Address1 *string Address2 *string ZipCode *string City *string State *string Country *string }
UpdateAddress is what fields can be updated in the store.
type UpdateHome ¶
type UpdateHome struct { Type *Type Address *UpdateAddress }
UpdateHome defines what informaton may be provided to modify an existing Home. 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 explicity blank. Normally we do not want to use pointers to basic types but we make exepction around marshalling/unmarshalling.