data

package
v0.0.0-...-89c1cf6 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddPlan

func AddPlan(plan BillingPlan)

func NewID

func NewID(accountID, userID int64) string

NewID returns a per second unique string based on account and user ids.

Types

type AdminServices

type AdminServices interface {
	LogRequests(reqs []model.APIRequest) error
}

AdminServices TODO: investigate this...

type BillingFlags

type BillingFlags int

BillingFlags is used to set which integrations a plan is authorize to use

type BillingPlan

type BillingPlan struct {
	ID          string                 `json:"id"`
	StripeID    string                 `json:"stripeId"`
	Name        string                 `json:"name"`
	Version     string                 `json:"version"`
	Price       float32                `json:"price"`
	YearlyPrice float32                `json:"yearly"`
	Params      map[string]interface{} `json:"params"`
}

BillingPlan defines what one plan to have access to and set limitations

func GetPlan

func GetPlan(id string) (BillingPlan, bool)

GetPlan returns a specific plan by ID

func GetPlans

func GetPlans(v string) []BillingPlan

GetPlans returns a slice of the desired version plans

func GetPlansVersion

func GetPlansVersion(plan string, defaultVersion string) []BillingPlan

GetPlansVersion returns a slice of the plans matching a current plan

type DB

type DB struct {
	// DatabaseName is the name of the database used.
	DatabaseName string
	// Connection is the reference to the database connection.
	Connection *sql.DB

	// Users contains the data access functions related to account, user and billing.
	Users UserServices
	// Webhooks contains the data access functions related to managing Webhooks.
	Webhooks WebhookServices
}

DB is a database agnostic abstraction that contains a reference to the database connection.

At this moment Postgres and an in-memory data provider are supported.

func (*DB) Close

func (db *DB) Close()

func (*DB) Open

func (db *DB) Open(driverName, dataSource string) error

Open creates the database connection and initialize the postgres services.

type UserServices

type UserServices interface {
	SignUp(email, password string) (*model.Account, error)
	ChangePassword(id, accountID int64, passwd string) error
	AddToken(accountID, userID int64, name string) (*model.AccessToken, error)
	RemoveToken(accountID, userID, tokenID int64) error
	Auth(accountID int64, token string, pat bool) (*model.Account, *model.User, error)
	GetUserByEmail(email string) (*model.User, error)
	GetDetail(id int64) (*model.Account, error)
	GetByStripe(stripeID string) (*model.Account, error)
	SetSeats(id int64, seats int) error
	ConvertToPaid(id int64, stripeID, subID, plan string, yearly bool, seats int) error
	ChangePlan(id int64, plan string, yearly bool) error
	Cancel(id int64) error
}

UserServices is an interface that contians all functions related to account, user and billing.

type WebhookServices

type WebhookServices interface {
	Add(accountID int64, events, url string) error
	List(accountID int64) ([]model.Webhook, error)
	Delete(accountID int64, event, url string) error
	AllSubscriptions(event string) ([]model.Webhook, error)
}

WebhookServices is an interface that contains all functions to manage webhook.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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