Files
zeekay 1943f1c093 Hanzo Commerce
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
2026-09-23 21:52:16 -07:00

29 lines
629 B
Go

package sendgrid
import (
"github.com/hanzoai/commerce/log"
"github.com/hanzoai/commerce/types/email"
)
// Add subscriber to list
func (api API) Subscribe(list *email.List, sub *email.Subscriber) error {
c := api.Context
// Ensure contact exists
contact, err := api.UpdateContact(sub)
if err != nil {
return err
}
// Add contact to list
res, err := api.Request("POST", "/v3/contactdb/lists/"+list.Id+"/recipients/"+contact.Id, nil, nil)
if err != nil {
return log.Error("Failed to add contact to list: %v", err, c)
}
log.Info(res.StatusCode, c)
log.Info(res.Body, c)
log.Info(res.Headers, c)
return nil
}