Files
zeekayandHanzo Dev 1a76145191 Hanzo Marketing: lifecycle email, from one place
The web app for /v1/marketing on api.hanzo.ai (audiences, drip sequences and
their steps, enrollments, campaigns, the send calendar, promos and opt-outs)
and the small Go service beside it. Earlier history is kept privately in
hanzoai/marketing-v1.

Co-authored-by: Hanzo Dev <[email protected]>
2026-09-15 11:36:13 -07:00

59 lines
1.2 KiB
Go

package model
import (
"github.com/hanzoai/commerce/datastore"
"github.com/hanzoai/commerce/models/mixin"
"github.com/hanzoai/commerce/util/json"
"github.com/hanzoai/orm"
)
func init() { orm.Register[Funnel]("funnel") }
type Funnel struct {
mixin.Model[Funnel]
Name string `json:"name"`
Events [][]string `json:"events" datastore:"-"`
Events_ string `json:"-"`
}
func (f *Funnel) Load(ps []datastore.Property) (err error) {
// Ensure we're initialized
f.Defaults()
// Load supported properties
if err = datastore.LoadStruct(f, ps); err != nil {
return err
}
// Deserialize from datastore
if len(f.Events_) > 0 {
err = json.DecodeBytes([]byte(f.Events_), &f.Events)
}
return
}
func (f *Funnel) Save() (ps []datastore.Property, err error) {
// Serialize unsupported properties
f.Events_ = string(json.EncodeBytes(&f.Events))
// Save properties
return datastore.SaveStruct(f)
}
func (f *Funnel) Defaults() {
f.Events = make([][]string, 0)
}
func NewFunnel(db *datastore.Datastore) *Funnel {
f := new(Funnel)
f.Init(db)
f.Defaults()
return f
}
func QueryFunnel(db *datastore.Datastore) datastore.Query {
return db.Query("funnel")
}