Documentation ¶
Index ¶
- Constants
- Variables
- func GeneratePartnerLink(offerName string) ([]string, error)
- func GetPartnerID(partnerName string) (partnerID string, err error)
- type DB
- type NewOffer
- type Offer
- type OfferSet
- type OfferStatus
- type OfferType
- type Offers
- type OpenSourcePartner
- type OrganizedOffers
- type PartnerInfo
- type PartnerSet
- type Partners
- type RedeemOffer
- type UpdateOffer
Constants ¶
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) // Partner is an OfferType used be the Open Source Partner Program Partner = OfferType(3) )
const ( // Done is the status of an offer that is no longer in use. Done = OfferStatus(iota) // Default is the status of an offer when there is no active offer. Default // Active is the status of an offer that is currently in use. Active )
Variables ¶
var ( // MaxRedemptionErr is the error class used when an offer has reached its redemption capacity MaxRedemptionErr = errs.Class("offer redemption has reached its capacity") // NoCurrentOfferErr is the error class used when no current offer is set NoCurrentOfferErr = errs.Class("no current offer") )
var ( // NoMatchPartnerIDErr is the error class used when an offer has reached its redemption capacity NoMatchPartnerIDErr = errs.Class("partner not exist") )
Functions ¶
func GeneratePartnerLink ¶ added in v0.17.0
GeneratePartnerLink returns base64 encoded partner referral link
func GetPartnerID ¶ added in v0.17.0
GetPartnerID returns partner ID based on partner name
Types ¶
type DB ¶
type DB interface { ListAll(ctx context.Context) (Offers, error) GetActiveOffersByType(ctx context.Context, offerType OfferType) (Offers, 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
type OfferSet ¶
type OfferSet struct { ReferralOffers OrganizedOffers FreeCredits OrganizedOffers PartnerTables PartnerSet }
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.
func (OfferStatus) IsDefault ¶ added in v0.18.0
func (status OfferStatus) IsDefault() bool
IsDefault checks if a offer's status is default
type Offers ¶
type Offers []Offer
Offers contains a slice of offers.
func (Offers) GetActiveOffer ¶ added in v0.17.0
func (offers Offers) GetActiveOffer(offerType OfferType, partnerID string) (offer *Offer, err error)
GetActiveOffer returns an offer that is active based on its type
func (Offers) OrganizeOffersByStatus ¶
func (offers Offers) OrganizeOffersByStatus() OrganizedOffers
OrganizeOffersByStatus organizes offers by OfferStatus.
func (Offers) OrganizeOffersByType ¶
OrganizeOffersByType organizes offers by OfferType.
type OpenSourcePartner ¶ added in v0.16.0
type OpenSourcePartner struct { PartnerInfo PartnerOffers OrganizedOffers }
OpenSourcePartner contains all data for an Open Source Partner.
type OrganizedOffers ¶
OrganizedOffers contains a list of offers organized by status.
type PartnerInfo ¶ added in v0.16.0
type PartnerInfo struct {
ID, Name string
}
PartnerInfo contains the name and ID of an Open Source Partner
type PartnerSet ¶ added in v0.16.0
type PartnerSet []OpenSourcePartner
PartnerSet contains a list of Open Source Partners.
type Partners ¶ added in v0.16.0
type Partners map[string]PartnerInfo
Partners contains a list of partners.
func LoadPartnerInfos ¶ added in v0.16.0
func LoadPartnerInfos() Partners
LoadPartnerInfos returns our current Open Source Partners.
type RedeemOffer ¶ added in v0.18.0
type RedeemOffer struct { RedeemableCap int Status OfferStatus Type OfferType }
RedeemOffer holds field needed for redeem an offer
type UpdateOffer ¶
type UpdateOffer struct { ID int Status OfferStatus ExpiresAt time.Time }
UpdateOffer holds fields needed for update an offer