mongomanager

package
v0.0.0-...-8cedb3d Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2024 License: BSD-4-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMongoConnectionFiles

func CheckMongoConnectionFiles(log *zap.Logger) error

func ContainsRole

func ContainsRole(seat Seat, requiredRoles []Role) bool

func ValidateStruct

func ValidateStruct(s interface{}) error

Types

type MongoConnection

type MongoConnection struct {
	Client *mongo.Client
	Log    *zap.Logger
}

func InitMongoConnection

func InitMongoConnection(ctx context.Context, log *zap.Logger) (*MongoConnection, error)

func (*MongoConnection) CheckDatabaseAndCollectionExists

func (mongoConnection *MongoConnection) CheckDatabaseAndCollectionExists(ctx context.Context) error

func (*MongoConnection) CheckMongoConnectability

func (mongoConnection *MongoConnection) CheckMongoConnectability(ctx context.Context) error

func (*MongoConnection) CountSeats

func (mongoConnection *MongoConnection) CountSeats(ctx context.Context, subscriptionID string) (int64, error)

func (*MongoConnection) CreateSeat

func (mongoConnection *MongoConnection) CreateSeat(ctx context.Context, seat Seat) error

func (*MongoConnection) CreateTrial

func (mongoConnection *MongoConnection) CreateTrial(ctx context.Context, trial Trial) error

func (*MongoConnection) CreateUser

func (mongoConnection *MongoConnection) CreateUser(ctx context.Context, user User) error

func (*MongoConnection) DeleteSeat

func (mongoConnection *MongoConnection) DeleteSeat(ctx context.Context, seat Seat) error

func (*MongoConnection) DeleteUser

func (mongoConnection *MongoConnection) DeleteUser(ctx context.Context, customerID string) error

func (*MongoConnection) EnsureIndexes

func (mongoConnection *MongoConnection) EnsureIndexes() error

func (*MongoConnection) GetAllSeats

func (mongoConnection *MongoConnection) GetAllSeats(ctx context.Context, subscriptionID string) ([]Seat, error)

func (*MongoConnection) GetOwnerSeat

func (mongoConnection *MongoConnection) GetOwnerSeat(ctx context.Context, subscriptionID string) (Seat, error)

func (*MongoConnection) GetSeat

func (mongoConnection *MongoConnection) GetSeat(ctx context.Context, subscriptionID, uid string) (Seat, error)

func (*MongoConnection) GetSeats

func (mongoConnection *MongoConnection) GetSeats(ctx context.Context, subscriptionID string, pageIndex int, pageSize int) ([]Seat, error)

func (*MongoConnection) GetTrial

func (mongoConnection *MongoConnection) GetTrial(ctx context.Context, trialFilter TrialFilter) (Trial, error)

func (*MongoConnection) GetUser

func (mongoConnection *MongoConnection) GetUser(ctx context.Context, userFilter User) (User, error)

func (*MongoConnection) HasPermission

func (mongoConnection *MongoConnection) HasPermission(ctx context.Context, tokenDetails firebasemanager.TokenDetails, subscriptionID string, requiredRoles []Role) error

func (*MongoConnection) UpdateSeat

func (mongoConnection *MongoConnection) UpdateSeat(ctx context.Context, seat Seat) error

func (*MongoConnection) UpdateUser

func (mongoConnection *MongoConnection) UpdateUser(ctx context.Context, user User) error

type Role

type Role string
const (
	RoleOwner         Role = "Owner"
	RoleAdministrator Role = "Administrator"
	RoleUser          Role = "User"
	RoleBilling       Role = "Billing"
)

type Seat

type Seat struct {
	SubscriptionID string `bson:"subscriptionID" json:"subscriptionID" validate:"required"`
	UID            string `bson:"uid" json:"uid" validate:"required"`
	EMail          string `bson:"email" json:"email" validate:"required"`
	EMailVerified  *bool  `bson:"emailVerified" json:"emailVerified" validate:"required"`
	Roles          []Role `bson:"roles" json:"roles" validate:"required"`
}

type Trial

type Trial struct {
	SubscriptionID         string `bson:"subscriptionID" validate:"required" index:"unique"`
	ProductType            string `bson:"productType" validate:"required"`
	CustomerID             string `bson:"customerID,omitempty" index:"unique" validate:"required"`
	PaymentCardFingerprint string `bson:"paymentCardFingerprint,omitempty" index:"unique"`
	PaymentPayPalEMail     string `bson:"paymentPayPalEMail,omitempty" index:"unique"`
	PaymentSEPAFingerprint string `bson:"paymentSEPAFingerprint,omitempty" index:"unique"`
}

type TrialFilter

type TrialFilter struct {
	ProductType            string `bson:"productType" validate:"required"`
	CustomerID             string `bson:"customerID,omitempty" index:"unique" validate:"required"`
	PaymentCardFingerprint string `bson:"paymentCardFingerprint,omitempty" index:"unique"`
	PaymentPayPalEMail     string `bson:"paymentPayPalEMail,omitempty" index:"unique"`
	PaymentSEPAFingerprint string `bson:"paymentSEPAFingerprint,omitempty" index:"unique"`
}

type User

type User struct {
	UID        string `bson:"uid" validate:"required"`
	CustomerID string `bson:"customerID" validate:"required"`
}

Jump to

Keyboard shortcuts

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