diff --git a/data/purchase.go b/data/purchase.go index 43e6427..0028585 100644 --- a/data/purchase.go +++ b/data/purchase.go @@ -8,33 +8,31 @@ import ( // Purchase defines a set of keys for a purchase event. type Purchase struct { - // Type defines a unique key. - // This help allow us to create the create when we only have the json representation of this data - Type events.EventObjectType `bson:"objectType" json:"objectType"` - - App events.App `bson:"app" json:"app"` - Workspace events.Workspace `bson:"workspace" json:"workspace"` - - Pricing OneTimePricing `bson:"pricing" json:"pricing"` - - // BoughtAt defines when the app was purchased - BoughtAt time.Time `bson:"boughtAt" json:"boughtAt"` - - // IsSelfManaged tells us whether the purchase is managed by the user or externally managed - IsSelfManaged bool `bson:"isSelfManaged" json:"isSelfManaged"` - - // IsBundle tells us whether the purchase is a bundle - IsBundle bool `bson:"isBundle" json:"isBundle"` - - // FromBundle defines if the app is inside a bundle and this event was triggered from a bundle - FromBundle bool `bson:"fromBundle" json:"fromBundle"` - - // FromBundleID indicates which bundle id triggered this purchase event for the app - FromBundleID string `bson:"fromBundleId,omitempty" json:"fromBundleId,omitempty"` + // objectType defines a unique key. + // This helps allow us to create the create when we only have the JSON representation of this data. + ObjectType events.EventObjectType `bson:"objectType" json:"objectType"` + App events.App `bson:"app" json:"app"` + Workspace events.Workspace `bson:"workspace" json:"workspace"` + Pricing OneTimePricing `bson:"pricing" json:"pricing"` + BoughtAt time.Time `bson:"boughtAt" json:"boughtAt"` + IsSelfManaged bool `bson:"isSelfManaged" json:"isSelfManaged"` + IsBundle bool `bson:"isBundle" json:"isBundle"` + FromBundle bool `bson:"fromBundle" json:"fromBundle"` + FromBundleID string `bson:"fromBundleID,omitempty" json:"fromBundleID,omitempty"` } -// OneTimePricing defines the pricing and fields for a purchase -// There is no way to have different tiers for an one time purchase +// OneTimePricing defines the pricing and fields for a purchase. +// There is no way to have different tiers for a one-time purchase. type OneTimePricing struct { Price float32 `bson:"price" json:"price"` } + +// SetPurchaseTime sets the BoughtAt field with the specified time in the local timezone. +func (p *Purchase) SetPurchaseTime(t time.Time) { + p.BoughtAt = t +} + +// GetPurchaseTime returns the BoughtAt field as a time.Time value in the local timezone. +func (p *Purchase) GetPurchaseTime() time.Time { + return p.BoughtAt +}