data

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Email     string `json:"email"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`

	DateCreated  time.Time `json:"dateCreated"`
	DateModified time.Time `json:"dateModified"`

	Data AccountData `json:"data"`
}

Account represents a single site account.

func NewAccount

func NewAccount(email string, firstName, lastName string) (*Account, error)

NewAccount creates a new site account.

func (*Account) Copy

func (acc *Account) Copy(other *Account, copyData bool) error

Copy copies the data of the given account to this account; if copyData is true, the account data is copied as well.

func (*Account) GetSiteID

func (acc *Account) GetSiteID() key.SiteIdentifier

GetSiteID returns the site ID (generated from the API key) for the given account.

type AccountData

type AccountData struct {
	APIKey     key.APIKey `json:"apiKey"`
	Authorized bool       `json:"authorized"`
}

AccountData holds additional data for a site account.

type Accounts

type Accounts = []*Account

Accounts holds an array of site accounts.

type FileStorage

type FileStorage struct {
	Storage
	// contains filtered or unexported fields
}

FileStorage implements a filePath-based storage.

func NewFileStorage

func NewFileStorage(conf *config.Configuration, log *zerolog.Logger) (*FileStorage, error)

NewFileStorage creates a new filePath storage.

func (*FileStorage) AccountAdded

func (storage *FileStorage) AccountAdded(account *Account)

AccountAdded is called when an account has been added.

func (*FileStorage) AccountRemoved

func (storage *FileStorage) AccountRemoved(account *Account)

AccountRemoved is called when an account has been removed.

func (*FileStorage) AccountUpdated

func (storage *FileStorage) AccountUpdated(account *Account)

AccountUpdated is called when an account has been updated.

func (*FileStorage) ReadAll

func (storage *FileStorage) ReadAll() (*Accounts, error)

ReadAll reads all stored accounts into the given data object.

func (*FileStorage) WriteAll

func (storage *FileStorage) WriteAll(accounts *Accounts) error

WriteAll writes all stored accounts from the given data object.

type Storage

type Storage interface {
	// ReadAll reads all stored accounts into the given data object.
	ReadAll() (*Accounts, error)
	// WriteAll writes all stored accounts from the given data object.
	WriteAll(accounts *Accounts) error

	// AccountAdded is called when an account has been added.
	AccountAdded(account *Account)
	// AccountUpdated is called when an account has been updated.
	AccountUpdated(account *Account)
	// AccountRemoved is called when an account has been removed.
	AccountRemoved(account *Account)
}

Storage defines the interface for accounts storages.

Jump to

Keyboard shortcuts

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