model

package
v0.0.0-...-7941b6a Latest Latest
Warning

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

Go to latest
Published: May 21, 2020 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RolePublic for publicly accessible routes.
	RolePublic Roles = 0
	// RoleFree for free user.
	RoleFree = 10
	// RoleUser for standard user.
	RoleUser = 20
	// RoleAdmin for admins.
	RoleAdmin = 99
)

Variables

This section is empty.

Functions

func NewFriendlyID

func NewFriendlyID(id int64, key string) string

NewFriendlyID returns a ~somewhat unique friendly id.

func NewToken

func NewToken(id int64) string

NewToken returns a token combining an id with a unique identifier.

func ParseToken

func ParseToken(token string) (int64, string)

ParseToken returns the id and uuid for a given token.

func StringToKey

func StringToKey(s string) int64

StringToKey converts a string to an int64

Types

type APIRequest

type APIRequest struct {
	ID         int64     ` json:"id"`
	AccountID  int64     ` json:"accountId"`
	UserID     int64     ` json:"userId"`
	URL        string    `json:"url"`
	Requested  time.Time ` json:"requested"`
	StatusCode int       ` json:"statusCode"`
	RequestID  string    ` json:"reqId"`
}

APIRequest represents a single API call.

type AccessToken

type AccessToken struct {
	ID     int64  ` json:"id"`
	UserID int64  ` json:"userId"`
	Name   string ` json:"name"`
	Token  string ` json:"token"`
}

AccessToken represents access tokens.

type Account

type Account struct {
	ID             int64     `json:"id"`
	Email          string    `json:"email"`
	StripeID       string    `json:"stripeId"`
	SubscriptionID string    `json:"subscriptionId"`
	Plan           string    ` json:"plan"`
	IsYearly       bool      `json:"isYearly"`
	SubscribedOn   time.Time `json:"subscribed"`
	Seats          int       ` json:"seats"`
	TrialInfo      Trial     ` json:"trial"`
	IsActive       bool      ` json:"active"`

	Users []User ` json:"users"`
}

Account represents the basic information for an account.

func (*Account) IsPaid

func (a *Account) IsPaid() bool

IsPaid returns if this account is a paying customer.

type Roles

type Roles int

Roles are used with user access control and authorization. You may add custom roles in-between the default ones.

type Trial

type Trial struct {
	IsTrial  bool      ` json:"trial"`
	Plan     string    ` json:"plan"`
	Start    time.Time ` json:"start"`
	Extended int       ` json:"extended"`
}

Trial represents the trial information for an account.

type User

type User struct {
	ID           int64         `json:"id"`
	AccountID    int64         ` json:"accountId"`
	First        string        `json:"first"`
	Last         string        `json:"last"`
	Email        string        `json:"email"`
	Password     string        ` json:"-"`
	Token        string        ` json:"token"`
	Role         Roles         ` json:"role"`
	AccessTokens []AccessToken ` json:"accessTokens"`
}

User represents a user.

type Webhook

type Webhook struct {
	ID        int64     `json:"id"`
	AccountID int64     `json:"accountId"`
	EventName string    `json:"event"`
	TargetURL string    `json:"url"`
	IsActive  bool      `json:"active"`
	Created   time.Time `json:"created"`
}

Webhook represents a webhook subscription.

Jump to

Keyboard shortcuts

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