当前位置: 首页>>代码示例>>Golang>>正文


Golang Client.SuppressionInsertOrUpdate方法代码示例

本文整理汇总了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{}
开发者ID:SparkPost,项目名称:sparkpost-cli,代码行数:67,代码来源:sp-suppression-list-cli.go


注:本文中的github.com/SparkPost/gosparkpost.Client.SuppressionInsertOrUpdate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。