Files
commerce/email/subscribe.go
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

37 lines
838 B
Go

package email
import (
"context"
"github.com/hanzoai/commerce/email/tasks"
"github.com/hanzoai/commerce/log"
"github.com/hanzoai/commerce/models/form"
"github.com/hanzoai/commerce/models/organization"
"github.com/hanzoai/commerce/models/subscriber"
)
func Subscribe(c context.Context, f *form.Form, s *subscriber.Subscriber, org *organization.Organization) (err error) {
in, err := org.Integrations.EmailMarketingProvider()
if err != nil {
log.Error("Could not get Email Provider from org %v: %v", org.Name, err, c)
return err
} else if in == nil {
return IntegrationShouldNotBeNilError
}
list := List{
Id: f.EmailList.Id,
}
sub := Subscriber{
Email: Email{
Address: s.Email,
},
FirstName: s.FirstName,
LastName: s.LastName,
Tags: s.Tags,
}
return tasks.Subscribe.Call(c, *in, list, sub)
}