user

package
v0.0.0-...-7d41a23 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package user contains all code related to the user domain.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend interface {
	ListUsers() (List, error)
	GetUser(id string) (User, error)
	CreateUser(User) error
	UpdateUser(User) error
	AppendUser(User) error
	RemoveUser(User) error
	DeleteUser(id string) error
}

Backend interface.

type Driver

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

Driver is the entry point of the domain that expose methods.

func NewDriver

func NewDriver(backend Backend) Driver

NewDriver create a new domain driver with given driven implementations.

func (Driver) Append

func (d Driver) Append(u User) error

Append attributes to the user with id.

func (Driver) Apply

func (d Driver) Apply(u User) (updated bool, err error)

Apply new attributes to an existing user, or create a new one.

func (Driver) Create

func (d Driver) Create(u User) error

Create a new user.

func (Driver) Delete

func (d Driver) Delete(id string) error

Delete the user with id.

func (Driver) Get

func (d Driver) Get(id string) (User, error)

Get the user with id.

func (Driver) List

func (d Driver) List() (List, error)

List all users.

func (Driver) Remove

func (d Driver) Remove(u User) error

Remove attributes from the user with id.

func (Driver) Update

func (d Driver) Update(u User) error

Update the user with id.

func (Driver) Upsert

func (d Driver) Upsert(u User) (updated bool, err error)

Upsert the user with id (update or create).

type List

type List interface {
	All() []User
	Index(idx uint) User
	Len() uint
	String() string
	MarshalJSON() ([]byte, error)
	MarshalYAML() (interface{}, error)
}

List of user objects.

func NewList

func NewList(slice []User) List

NewList create a new list of users object.

type User

type User interface {
	ID() string
	FirstNames() []string
	LastNames() []string
	Emails() []string
	String() string
	MarshalJSON() ([]byte, error)
	MarshalYAML() (interface{}, error)
}

User object contains informations about a user.

func NewUser

func NewUser(id string, firstNames []string, lastNames []string, emails []string) User

NewUser create a new user object.

Jump to

Keyboard shortcuts

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