package main
import (
"context"
"log"
suprsend "github.com/suprsend/suprsend-go"
)
func main() {
// Initialize SDK
opts := []suprsend.ClientOption{
// suprsend.WithDebug(true),
}
suprClient, err := suprsend.NewClient("_workspace_key_", "_workspace_secret_", opts...)
if err != nil {
log.Println(err)
}
ctx := context.Background()
// ================= broadcast to a list
broadcastIns := &suprsend.SubscriberListBroadcast{
Body: map[string]interface{}{
"list_id": "users-with-prepaid-vouchers-1",
"template": "template slug",
"notification_category": "category",
// broadcast channels.
// if empty: broadcast will be tried on all available channels
// if present: broadcast will be tried on passed channels only
"channels": []string{"email"},
"delay": "1m", // check docs for delay format
// "trigger_at": "", // check below for trigger_at format
"data": map[string]interface{}{
"first_name": "User",
"spend_amount": "$10",
"nested_key_example": map[string]interface{}{
"nested_key1": "some_value_1",
"nested_key2": map[string]interface{}{
"nested_key3": "some_value_3",
},
},
},
},
IdempotencyKey: "",
TenantId: "",
}
res, err := suprClient.SubscriberLists.Broadcast(ctx, broadcastIns)
if err != nil {
log.Fatalln(err)
}
log.Println(res)
}