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
37 lines
838 B
Go
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)
|
|
}
|