rewards

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2019 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Invalid is a default value for offers that don't have correct type associated with it
	Invalid = OfferType(0)
	// FreeCredit is a type of offers used for Free Credit Program
	FreeCredit = OfferType(1)
	// Referral is a type of offers used for Referral Program
	Referral = OfferType(2)
)
View Source
const (

	// Done is the status of an offer that is no longer in use.
	Done = OfferStatus(iota)

	// Active is the status of an offer that is currently in use.
	Active

	// Default is the status of an offer when there is no active offer.
	Default
)

Variables

View Source
var MaxRedemptionErr = "This offer redemption has reached its capacity"

MaxRedemptionErr is the error message used when an offer has reached its redemption capacity

Functions

This section is empty.

Types

type DB

type DB interface {
	ListAll(ctx context.Context) (Offers, error)
	GetCurrentByType(ctx context.Context, offerType OfferType) (*Offer, error)
	Create(ctx context.Context, offer *NewOffer) (*Offer, error)
	Finish(ctx context.Context, offerID int) error
}

DB holds information about offer

type NewOffer

type NewOffer struct {
	Name        string
	Description string

	AwardCredit   currency.USD
	InviteeCredit currency.USD

	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

	AwardCredit   currency.USD
	InviteeCredit currency.USD

	AwardCreditDurationDays   int
	InviteeCreditDurationDays int

	RedeemableCap int

	ExpiresAt time.Time
	CreatedAt time.Time

	Status OfferStatus
	Type   OfferType
}

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

func (Offer) IsEmpty

func (o Offer) IsEmpty() bool

IsEmpty evaluates whether or not an on offer is empty

type OfferSet

type OfferSet struct {
	ReferralOffers OrganizedOffers
	FreeCredits    OrganizedOffers
}

OfferSet provides a separation of marketing offers by type.

type OfferStatus

type OfferStatus int

OfferStatus represents the different stage an offer can have in its life-cycle.

type OfferType

type OfferType int

OfferType indicates the type of an offer

type Offers

type Offers []Offer

Offers contains a slice of offers.

func (Offers) OrganizeOffersByStatus

func (offers Offers) OrganizeOffersByStatus() OrganizedOffers

OrganizeOffersByStatus organizes offers by OfferStatus.

func (Offers) OrganizeOffersByType

func (offers Offers) OrganizeOffersByType() OfferSet

OrganizeOffersByType organizes offers by OfferType.

type OrganizedOffers

type OrganizedOffers struct {
	Active  Offer
	Default Offer
	Done    Offers
}

OrganizedOffers contains a list of offers organized by status.

type UpdateOffer

type UpdateOffer struct {
	ID        int
	Status    OfferStatus
	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