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
40 lines
704 B
Go
40 lines
704 B
Go
package mailchimp
|
|
|
|
import (
|
|
"context"
|
|
"net/http"
|
|
"time"
|
|
|
|
"github.com/hanzoai/gochimp3"
|
|
|
|
"github.com/hanzoai/commerce/types/integration"
|
|
)
|
|
|
|
type API struct {
|
|
Context context.Context
|
|
Client *gochimp3.API
|
|
Key string
|
|
}
|
|
|
|
func New(ctx context.Context, settings integration.Mailchimp) *API {
|
|
// Update timeout
|
|
var cancel context.CancelFunc
|
|
ctx, cancel = context.WithTimeout(ctx, time.Second*55)
|
|
defer cancel()
|
|
|
|
apiKey := settings.APIKey
|
|
client := gochimp3.New(apiKey)
|
|
|
|
// Use standard HTTP transport with timeout
|
|
client.Transport = &http.Transport{
|
|
ResponseHeaderTimeout: time.Second * 55,
|
|
}
|
|
client.Debug = true
|
|
|
|
return &API{
|
|
Context: ctx,
|
|
Client: client,
|
|
Key: apiKey,
|
|
}
|
|
}
|