Documentation ¶
Index ¶
- Constants
- Variables
- type DB
- type NewOffer
- type Offer
- type OfferStatus
- type OfferType
- type Offers
- type Service
- func (s *Service) GetCurrentOfferByType(ctx context.Context, offerType OfferType) (offer *Offer, err error)
- func (s *Service) InsertNewOffer(ctx context.Context, offer *NewOffer) (o *Offer, err error)
- func (s *Service) ListAllOffers(ctx context.Context) (offers []Offer, err error)
- func (s *Service) UpdateOffer(ctx context.Context, offer *UpdateOffer) (err error)
- type UpdateOffer
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 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 ¶
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 ¶
InsertNewOffer inserts a new offer into the db
func (*Service) ListAllOffers ¶
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
Click to show internal directories.
Click to hide internal directories.