mirror of
https://github.com/hanzoai/commerce.git
synced 2026-10-30 15:08:42 +00:00
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans, usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0. Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
48 lines
1.1 KiB
Go
48 lines
1.1 KiB
Go
package quote
|
|
|
|
import (
|
|
"github.com/hanzoai/commerce/datastore"
|
|
"github.com/hanzoai/commerce/models/mixin"
|
|
"github.com/hanzoai/orm"
|
|
)
|
|
|
|
func init() { orm.Register[QuoteMessage]("quote-message") }
|
|
|
|
// Author types on a quote thread.
|
|
const (
|
|
AuthorCustomer = "customer"
|
|
AuthorMerchant = "merchant"
|
|
)
|
|
|
|
// QuoteMessage is a single message on a quote's negotiation thread. ItemId
|
|
// optionally scopes the message to a specific line of the underlying order.
|
|
type QuoteMessage struct {
|
|
mixin.Model[QuoteMessage]
|
|
|
|
QuoteId string `json:"quoteId"`
|
|
AuthorId string `json:"authorId"`
|
|
AuthorType string `json:"authorType"`
|
|
Text string `json:"text"`
|
|
|
|
// ItemId optionally references the order line this message is about.
|
|
ItemId string `json:"itemId,omitempty"`
|
|
}
|
|
|
|
func (m *QuoteMessage) Load(ps []datastore.Property) error {
|
|
return datastore.LoadStruct(m, ps)
|
|
}
|
|
|
|
func (m *QuoteMessage) Save() ([]datastore.Property, error) {
|
|
return datastore.SaveStruct(m)
|
|
}
|
|
|
|
func NewMessage(db *datastore.Datastore) *QuoteMessage {
|
|
m := new(QuoteMessage)
|
|
m.Init(db)
|
|
return m
|
|
}
|
|
|
|
func QueryMessages(db *datastore.Datastore) datastore.Query {
|
|
return db.Query("quote-message")
|
|
}
|