marketing

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2019 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FreeCredit is a type of offers used for Free Credit Program
	FreeCredit = OfferType(iota)
	// Referral is a type of offers used for Referral Program
	Referral
)
View Source
const (
	// Done is a default offer status when an offer is not being used currently
	Done = OfferStatus(iota)
	// Default is a offer status when an offer is used as a default offer
	Default
	// Active is a offer status when an offer is currently being used
	Active
)

Variables

View Source
var (
	// Error the default offers errs class
	Error = errs.Class("marketing error")
)
View Source
var OffersErr = errs.Class("offers error")

OffersErr creates offer error class

Functions

This section is empty.

Types

type DB

type DB interface {
	Offers() Offers
}

DB contains access to all marketing related databases

type NewOffer

type NewOffer struct {
	Name        string
	Description string

	AwardCreditInCents   int
	InviteeCreditInCents int

	RedeemableCap int

	AwardCreditDurationDays   int
	InviteeCreditDurationDays int

	ExpiresAt time.Time

	Status OfferStatus
	Type   OfferType
}

NewOffer holds information that's needed for creating a new offer

type Offer

type Offer struct {
	ID          int
	Name        string
	Description string

	AwardCreditInCents   int
	InviteeCreditInCents int

	AwardCreditDurationDays   int
	InviteeCreditDurationDays int

	RedeemableCap int
	NumRedeemed   int

	ExpiresAt time.Time
	CreatedAt time.Time

	Status OfferStatus
	Type   OfferType
}

Offer contains info needed for giving users free credits through different offer programs

type OfferStatus

type OfferStatus int

OfferStatus indicates the status of an offer

type OfferType

type OfferType int

OfferType indicates the type of an offer

type Offers

type Offers interface {
	ListAll(ctx context.Context) ([]Offer, error)
	GetCurrentByType(ctx context.Context, offerType OfferType) (*Offer, error)
	Create(ctx context.Context, offer *NewOffer) (*Offer, error)
	Update(ctx context.Context, offer *UpdateOffer) error
}

Offers holds information about offer

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service allows access to offers info in the db

func NewService

func NewService(log *zap.Logger, db DB) (*Service, error)

NewService creates a new offers db

func (*Service) GetCurrentOfferByType

func (s *Service) GetCurrentOfferByType(ctx context.Context, offerType OfferType) (offer *Offer, err error)

GetCurrentOfferByType returns current active offer

func (*Service) InsertNewOffer

func (s *Service) InsertNewOffer(ctx context.Context, offer *NewOffer) (o *Offer, err error)

InsertNewOffer inserts a new offer into the db

func (*Service) ListAllOffers

func (s *Service) ListAllOffers(ctx context.Context) (offers []Offer, err error)

ListAllOffers returns all available offers in the db

func (*Service) UpdateOffer

func (s *Service) UpdateOffer(ctx context.Context, offer *UpdateOffer) (err error)

UpdateOffer modifies an existing offer in the db when the offer status is set to NoStatus

type UpdateOffer

type UpdateOffer struct {
	ID          int
	Status      OfferStatus
	NumRedeemed int
	ExpiresAt   time.Time
}

UpdateOffer holds fields needed for update an offer

Jump to

Keyboard shortcuts

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