data

package
v0.0.0-...-6098784 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2016 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// TokenTypeMaintenace defines maintenance tokens
	TokenTypeMaintenace = 1
	// TokenTypeAccess defines access tokens
	TokenTypeAccess = 2
)

Variables

This section is empty.

Functions

func Database

func Database(use *sqlx.DB)

Database configures the db driver

func Setup

func Setup()

Setup creates the database structure

Types

type Account

type Account struct {
	ID       int       `db:"id"`
	Address  string    `db:"address"`
	Created  time.Time `db:"created"`
	Verified bool      `db:"verified"`
}

Account implements AccountInterface

func AccountByAddress

func AccountByAddress(address string) (*Account, error)

AccountByAddress retrieves Account by address

func AccountByID

func AccountByID(id int) (*Account, error)

AccountByID retrieves Account by id

func AccountNew

func AccountNew(address string) *Account

AccountNew creates a new account

func (Account) GetSubscription

func (a Account) GetSubscription() *Subscription

GetSubscription retrieves Account Subscription

func (Account) GetToken

func (a Account) GetToken(t string, tokenType int) (*Token, error)

GetToken retrieves Token for Account

func (Account) GetTokenList

func (a Account) GetTokenList(tokenType int) []*Token

GetTokenList retrieves all Token for Account

func (Account) HasSubscription

func (a Account) HasSubscription() bool

HasSubscription checks if Account has a Subscription

func (Account) IsStored

func (a Account) IsStored() bool

IsStored checks if Account is stored in DB

func (Account) Refresh

func (a Account) Refresh() (*Account, error)

Refresh Account from DB

func (Account) Remove

func (a Account) Remove() error

Remove Account

func (Account) Store

func (a Account) Store() (*Account, error)

Store writes Account to DB

func (Account) Verify

func (a Account) Verify() (*Account, error)

Verify verifies Account and updates the DB

type AccountInterface

type AccountInterface interface {
	GetSubscription() *Subscription
	GetToken(t string, tokenType int) (*Token, error)
	GetTokenList(tokenType int) []*Token
	HasSubscription() bool
	IsStored() bool
	Refresh() (*Account, error)
	Remove() error
	Store() (*Account, error)
	Verify() (*Account, error)
	// contains filtered or unexported methods
}

AccountInterface defines Account

type Note

type Note struct {
	ID      int       `db:"id"`
	Account int       `db:"account"`
	Text    string    `db:"text"`
	Created time.Time `db:"created"`
}

Note implements NoteInterface

func NoteByID

func NoteByID(id int) (*Note, error)

NoteByID retrieves Note by id

func NoteListByAccount

func NoteListByAccount(account int) ([]Note, error)

NoteListByAccount retrieves Note by id

func NoteNew

func NoteNew(account int, text string) *Note

NoteNew creates a new Note

func (Note) IsStored

func (n Note) IsStored() bool

IsStored checks if Note is stored in DB

func (Note) Refresh

func (n Note) Refresh() (*Note, error)

Refresh Note from DB

func (Note) Store

func (n Note) Store() (*Note, error)

Store writes Notes to DB

type NoteInterface

type NoteInterface interface {
	IsStored() bool
	Store() (*Note, error)
	// contains filtered or unexported methods
}

NoteInterface defines Note

type Subscription

type Subscription struct {
	ID       int       `db:"id"`
	Account  int       `db:"account"`
	Created  time.Time `db:"created"`
	StripeID string    `db:"stripeid"`
	Active   bool      `db:"active"`
}

Subscription implements SubscriptionInterface

func SubscriptionByAccountID

func SubscriptionByAccountID(id int) (*Subscription, error)

SubscriptionByAccountID retrieves Subscription by Account id

func SubscriptionByID

func SubscriptionByID(id int) (*Subscription, error)

SubscriptionByID retrieves Subscription by id

func SubscriptionNew

func SubscriptionNew(account int, stripeid string) *Subscription

SubscriptionNew creates a new Subscription

func (Subscription) Activate

func (s Subscription) Activate() (*Subscription, error)

Activate activates Subscripiton and updates the DB

func (Subscription) Deactivate

func (s Subscription) Deactivate() (*Subscription, error)

Deactivate deactivates Subscrition and updates the DB

func (Subscription) IsStored

func (s Subscription) IsStored() bool

IsStored checks if Subscription is stored in DB

func (Subscription) Refresh

func (s Subscription) Refresh() (*Subscription, error)

Refresh Subscription from DB

func (Subscription) Store

func (s Subscription) Store() (*Subscription, error)

Store writes Subscription to DB

type SubscriptionInterface

type SubscriptionInterface interface {
	Activate() (*Subscription, error)
	Deactivate() (*Subscription, error)
	IsStored() bool
	Refresh() (*Subscription, error)
	Store() (*Subscription, error)
	// contains filtered or unexported methods
}

SubscriptionInterface defines Subscription

type Token

type Token struct {
	ID      int       `db:"id"`
	Account int       `db:"account"`
	Text    string    `db:"text"`
	Created time.Time `db:"created"`
	Type    int       `db:"type"`
	Active  bool      `db:"active"`
	// contains filtered or unexported fields
}

Token implements TokenInterface

func TokenByID

func TokenByID(id int) (*Token, error)

TokenByID retrieves Token by id

func TokenListByAccountAndType

func TokenListByAccountAndType(account int, tType int) []*Token

TokenListByAccountAndType retrieves Token list by Account and type

func TokenNew

func TokenNew(account int, tokenType int) *Token

TokenNew creates a new Token

func (Token) Activate

func (t Token) Activate() (*Token, error)

Activate activates Token and updates the DB

func (Token) Deactivate

func (t Token) Deactivate() (*Token, error)

Deactivate activates Token and updates the DB

func (Token) IsSecure

func (t Token) IsSecure() bool

IsSecure checks Token is secure

func (Token) IsStored

func (t Token) IsStored() bool

IsStored check if Token is stored in DB

func (Token) Matches

func (t Token) Matches(raw string) bool

Matches checks if text matches Token

func (Token) Raw

func (t Token) Raw() string

Raw returns Token raw

func (Token) Remove

func (t Token) Remove() error

Remove Token

func (Token) Store

func (t Token) Store() (*Token, error)

Store writes Token to DB

type TokenInterface

type TokenInterface interface {
	Activate() (Token, error)
	Deactivate() (Token, error)
	IsSecure() bool
	Matches(raw string) bool
	Raw() string
	Remove() error
	Store() (Token, error)
}

TokenInterface defines Token

Jump to

Keyboard shortcuts

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