本文整理汇总了Golang中github.com/SparkPost/gosparkpost.Client.SuppressionInsertOrUpdate方法的典型用法代码示例。如果您正苦于以下问题:Golang Client.SuppressionInsertOrUpdate方法的具体用法?Golang Client.SuppressionInsertOrUpdate怎么用?Golang Client.SuppressionInsertOrUpdate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/SparkPost/gosparkpost.Client
的用法示例。
在下文中一共展示了Client.SuppressionInsertOrUpdate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: main
//.........这里部分代码省略.........
}
if record[MANDRILL_EMAIL_COL] == "email" {
// Skip over header row
continue
}
if record[MANDRILL_REASON_COL] != "hard-bounce" {
// Ignore soft-bounce
continue
}
if strings.Count(record[MANDRILL_EMAIL_COL], "@") != 1 {
fmt.Printf("WARN: Ignoring '%s'. It is not a valid email address.\n", record[MANDRILL_EMAIL_COL])
continue
}
entry := sp.SuppressionEntry{}
if record[MANDRILL_EMAIL_COL] == "" {
// Must have email as it is suppression list primary key
continue
}
entry.Email = record[MANDRILL_EMAIL_COL]
entry.Transactional = false
entry.NonTransactional = true
entry.Description = fmt.Sprintf("MBL: %s", record[MANDRILL_DETAIL_COL])
entries = append(entries, entry)
if len(entries) > (1024 * 100) {
fmt.Printf("Uploading batch %d\n", batchCount)
err = client.SuppressionInsertOrUpdate(entries)
if err != nil {
log.Fatalf("ERROR: %s\n\nFor additional information try using `--verbose true`\n\n\n", err)
return
}
entries = []sp.SuppressionEntry{}
batchCount++
}
}
if len(entries) > 0 {
fmt.Printf("Uploading batch %d\n", batchCount)
err = client.SuppressionInsertOrUpdate(entries)
if err != nil {
log.Fatalf("ERROR: %s\n\nFor additional information try using `--verbose true`\n\n\n", err)
return
}
}
fmt.Println("DONE")
case "sendgrid":
file := c.String("file")
if file == "" {
log.Fatalf("ERROR: The `sendgrid` command requires a CSV file.")
return
}
f, err := os.Open(file)
check(err)
var entries = []sp.SuppressionEntry{}