• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang simplehttp.NewUrlEncodedPayload函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/mbanzon/simplehttp.NewUrlEncodedPayload函数的典型用法代码示例。如果您正苦于以下问题:Golang NewUrlEncodedPayload函数的具体用法?Golang NewUrlEncodedPayload怎么用?Golang NewUrlEncodedPayload使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewUrlEncodedPayload函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetLists

// GetLists returns the specified set of mailing lists administered by your account.
func (mg *MailgunImpl) GetLists(limit, skip int, filter string) (int, []List, error) {
	r := simplehttp.NewHTTPRequest(generatePublicApiUrl(listsEndpoint))
	r.SetClient(mg.Client())
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	if limit != DefaultLimit {
		p.AddValue("limit", strconv.Itoa(limit))
	}
	if skip != DefaultSkip {
		p.AddValue("skip", strconv.Itoa(skip))
	}
	if filter != "" {
		p.AddValue("address", filter)
	}
	var envelope struct {
		Items      []List `json:"items"`
		TotalCount int    `json:"total_count"`
	}
	response, err := makeRequest(r, "GET", p)
	if err != nil {
		return -1, nil, err
	}
	err = response.ParseFromJSON(&envelope)
	return envelope.TotalCount, envelope.Items, err
}
开发者ID:d4l3k,项目名称:mailgun-go,代码行数:26,代码来源:mailing_lists.go


示例2: CreateList

// CreateList creates a new mailing list under your Mailgun account.
// You need specify only the Address and Name members of the prototype;
// Description, and AccessLevel are optional.
// If unspecified, Description remains blank,
// while AccessLevel defaults to Everyone.
func (mg *MailgunImpl) CreateList(prototype List) (List, error) {
	r := simplehttp.NewHTTPRequest(generatePublicApiUrl(listsEndpoint))
	r.SetClient(mg.Client())
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	if prototype.Address != "" {
		p.AddValue("address", prototype.Address)
	}
	if prototype.Name != "" {
		p.AddValue("name", prototype.Name)
	}
	if prototype.Description != "" {
		p.AddValue("description", prototype.Description)
	}
	if prototype.AccessLevel != "" {
		p.AddValue("access_level", prototype.AccessLevel)
	}
	response, err := makePostRequest(r, p)
	if err != nil {
		return List{}, err
	}
	var l List
	err = response.ParseFromJSON(&l)
	return l, err
}
开发者ID:d4l3k,项目名称:mailgun-go,代码行数:30,代码来源:mailing_lists.go


示例3: GetMembers

// GetMembers returns the list of members belonging to the indicated mailing list.
// The s parameter can be set to one of three settings to help narrow the returned data set:
// All indicates that you want both Members and unsubscribed members alike, while
// Subscribed and Unsubscribed indicate you want only those eponymous subsets.
func (mg *MailgunImpl) GetMembers(limit, skip int, s *bool, addr string) (int, []Member, error) {
	r := simplehttp.NewHTTPRequest(generateMemberApiUrl(listsEndpoint, addr))
	r.SetClient(mg.Client())
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	if limit != DefaultLimit {
		p.AddValue("limit", strconv.Itoa(limit))
	}
	if skip != DefaultSkip {
		p.AddValue("skip", strconv.Itoa(skip))
	}
	if s != nil {
		p.AddValue("subscribed", yesNo(*s))
	}
	var envelope struct {
		TotalCount int      `json:"total_count"`
		Items      []Member `json:"items"`
	}
	response, err := makeRequest(r, "GET", p)
	if err != nil {
		return -1, nil, err
	}
	err = response.ParseFromJSON(&envelope)
	return envelope.TotalCount, envelope.Items, err
}
开发者ID:d4l3k,项目名称:mailgun-go,代码行数:29,代码来源:mailing_lists.go


示例4: UpdateRoute

// UpdateRoute provides an "in-place" update of the specified route.
// Only those route fields which are non-zero or non-empty are updated.
// All other fields remain as-is.
func (mg *MailgunImpl) UpdateRoute(id string, route Route) (Route, error) {
	r := simplehttp.NewHTTPRequest(generatePublicApiUrl(routesEndpoint) + "/" + id)
	r.SetClient(mg.Client())
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	if route.Priority != 0 {
		p.AddValue("priority", strconv.Itoa(route.Priority))
	}
	if route.Description != "" {
		p.AddValue("description", route.Description)
	}
	if route.Expression != "" {
		p.AddValue("expression", route.Expression)
	}
	if route.Actions != nil {
		for _, action := range route.Actions {
			p.AddValue("action", action)
		}
	}
	// For some reason, this API function just returns a bare Route on success.
	// Unsure why this is the case; it seems like it ought to be a bug.
	var envelope Route
	err := putResponseFromJSON(r, p, &envelope)
	return envelope, err
}
开发者ID:d4l3k,项目名称:mailgun-go,代码行数:28,代码来源:routes.go


示例5: UpdateWebhook

// UpdateWebhook replaces one webhook setting for another.
func (mg *MailgunImpl) UpdateWebhook(t, u string) error {
	r := simplehttp.NewHTTPRequest(generateDomainApiUrl(mg, webhooksEndpoint) + "/" + t)
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	p.AddValue("url", u)
	_, err := makePutRequest(r, p)
	return err
}
开发者ID:9uuso,项目名称:mailgun-go,代码行数:9,代码来源:webhooks.go


示例6: CreateComplaint

// CreateComplaint registers the specified address as a recipient who has complained of receiving spam
// from your domain.
func (m *MailgunImpl) CreateComplaint(address string) error {
	r := simplehttp.NewHTTPRequest(generateApiUrl(m, complaintsEndpoint))
	r.SetBasicAuth(basicAuthUser, m.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	p.AddValue("address", address)
	_, err := makePostRequest(r, p)
	return err
}
开发者ID:9uuso,项目名称:mailgun-go,代码行数:10,代码来源:spam_complaints.go


示例7: Unsubscribe

// Unsubscribe adds an e-mail address to the domain's unsubscription table.
func (mg *MailgunImpl) Unsubscribe(a, t string) error {
	r := simplehttp.NewHTTPRequest(generateApiUrl(mg, unsubscribesEndpoint))
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	p.AddValue("address", a)
	p.AddValue("tag", t)
	_, err := makePostRequest(r, p)
	return err
}
开发者ID:9uuso,项目名称:mailgun-go,代码行数:10,代码来源:unsubscribes.go


示例8: ChangeCredentialPassword

// ChangeCredentialPassword attempts to alter the indicated credential's password.
func (mg *MailgunImpl) ChangeCredentialPassword(id, password string) error {
	if (id == "") || (password == "") {
		return ErrEmptyParam
	}
	r := simplehttp.NewHTTPRequest(generateCredentialsUrl(mg, id))
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	p.AddValue("password", password)
	_, err := makePutRequest(r, p)
	return err
}
开发者ID:9uuso,项目名称:mailgun-go,代码行数:12,代码来源:credentials.go


示例9: CreateDomain

// CreateDomain instructs Mailgun to create a new domain for your account.
// The name parameter identifies the domain.
// The smtpPassword parameter provides an access credential for the domain.
// The spamAction domain must be one of Delete, Tag, or Disabled.
// The wildcard parameter instructs Mailgun to treat all subdomains of this domain uniformly if true,
// and as different domains if false.
func (m *MailgunImpl) CreateDomain(name string, smtpPassword string, spamAction string, wildcard bool) error {
	r := simplehttp.NewHTTPRequest(generatePublicApiUrl(domainsEndpoint))
	r.SetBasicAuth(basicAuthUser, m.ApiKey())

	payload := simplehttp.NewUrlEncodedPayload()
	payload.AddValue("name", name)
	payload.AddValue("smtp_password", smtpPassword)
	payload.AddValue("spam_action", spamAction)
	payload.AddValue("wildcard", strconv.FormatBool(wildcard))
	_, err := makePostRequest(r, payload)
	return err
}
开发者ID:9uuso,项目名称:mailgun-go,代码行数:18,代码来源:domains.go


示例10: UpdateCampaign

// Campaigns have been deprecated since development work on this SDK commenced.
// Please refer to http://documentation.mailgun.com/api_reference .
func (m *MailgunImpl) UpdateCampaign(oldId, name, newId string) error {
	r := simplehttp.NewHTTPRequest(generateApiUrl(m, campaignsEndpoint) + "/" + oldId)
	r.SetBasicAuth(basicAuthUser, m.ApiKey())

	payload := simplehttp.NewUrlEncodedPayload()
	payload.AddValue("name", name)
	if newId != "" {
		payload.AddValue("id", newId)
	}
	_, err := makePostRequest(r, payload)
	return err
}
开发者ID:9uuso,项目名称:mailgun-go,代码行数:14,代码来源:campaigns.go


示例11: CreateCredential

// CreateCredential attempts to create associate a new principle with your domain.
func (mg *MailgunImpl) CreateCredential(login, password string) error {
	if (login == "") || (password == "") {
		return ErrEmptyParam
	}
	r := simplehttp.NewHTTPRequest(generateCredentialsUrl(mg, ""))
	r.SetClient(mg.Client())
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	p.AddValue("login", login)
	p.AddValue("password", password)
	_, err := makePostRequest(r, p)
	return err
}
开发者ID:d4l3k,项目名称:mailgun-go,代码行数:14,代码来源:credentials.go


示例12: CreateCampaign

// Campaigns have been deprecated since development work on this SDK commenced.
// Please refer to http://documentation.mailgun.com/api_reference .
func (m *MailgunImpl) CreateCampaign(name, id string) error {
	r := simplehttp.NewHTTPRequest(generateApiUrl(m, campaignsEndpoint))
	r.SetClient(m.client)
	r.SetBasicAuth(basicAuthUser, m.ApiKey())

	payload := simplehttp.NewUrlEncodedPayload()
	payload.AddValue("name", name)
	if id != "" {
		payload.AddValue("id", id)
	}
	_, err := makePostRequest(r, payload)
	return err
}
开发者ID:alextsankov-wf,项目名称:mailgun-go,代码行数:15,代码来源:campaigns.go


示例13: AddBounce

// AddBounce files a bounce report.
// Address identifies the intended recipient of the message that bounced.
// Code corresponds to the numeric response given by the e-mail server which rejected the message.
// Error providees the corresponding human readable reason for the problem.
// For example,
// here's how the these two fields relate.
// Suppose the SMTP server responds with an error, as below.
// Then, . . .
//
//      550  Requested action not taken: mailbox unavailable
//     \___/\_______________________________________________/
//       |                         |
//       `-- Code                  `-- Error
//
// Note that both code and error exist as strings, even though
// code will report as a number.
func (m *MailgunImpl) AddBounce(address, code, error string) error {
	r := simplehttp.NewHTTPRequest(generateApiUrl(m, bouncesEndpoint))
	r.SetBasicAuth(basicAuthUser, m.ApiKey())

	payload := simplehttp.NewUrlEncodedPayload()
	payload.AddValue("address", address)
	if code != "" {
		payload.AddValue("code", code)
	}
	if error != "" {
		payload.AddValue("error", error)
	}
	_, err := makePostRequest(r, payload)
	return err
}
开发者ID:adrianlop,项目名称:dex,代码行数:31,代码来源:bounces.go


示例14: CreateRoute

// CreateRoute installs a new route for your domain.
// The route structure you provide serves as a template, and
// only a subset of the fields influence the operation.
// See the Route structure definition for more details.
func (mg *MailgunImpl) CreateRoute(prototype Route) (Route, error) {
	r := simplehttp.NewHTTPRequest(generatePublicApiUrl(routesEndpoint))
	r.SetBasicAuth(basicAuthUser, mg.ApiKey())
	p := simplehttp.NewUrlEncodedPayload()
	p.AddValue("priority", strconv.Itoa(prototype.Priority))
	p.AddValue("description", prototype.Description)
	p.AddValue("expression", prototype.Expression)
	for _, action := range prototype.Actions {
		p.AddValue("action", action)
	}
	var envelope struct {
		Message string `json:"message"`
		*Route  `json:"route"`
	}
	err := postResponseFromJSON(r, p, &envelope)
	return *envelope.Route, err
}
开发者ID:9uuso,项目名称:mailgun-go,代码行数:21,代码来源:routes.go


示例15: GetFirstPage

// GetFirstPage retrieves the first batch of events, according to your criteria.
// See the GetEventsOptions structure for more details on how the fields affect the data returned.
func (ei *EventIterator) GetFirstPage(opts GetEventsOptions) error {
	if opts.ForceAscending && opts.ForceDescending {
		return fmt.Errorf("collation cannot at once be both ascending and descending")
	}

	payload := simplehttp.NewUrlEncodedPayload()
	if opts.Limit != 0 {
		payload.AddValue("limit", fmt.Sprintf("%d", opts.Limit))
	}
	if opts.Compact {
		payload.AddValue("pretty", "no")
	}
	if opts.ForceAscending {
		payload.AddValue("ascending", "yes")
	}
	if opts.ForceDescending {
		payload.AddValue("ascending", "no")
	}
	if opts.Begin != noTime {
		payload.AddValue("begin", formatMailgunTime(&opts.Begin))
	}
	if opts.End != noTime {
		payload.AddValue("end", formatMailgunTime(&opts.End))
	}
	if opts.Filter != nil {
		for k, v := range opts.Filter {
			payload.AddValue(k, v)
		}
	}

	url, err := generateParameterizedUrl(ei.mg, eventsEndpoint, payload)
	if err != nil {
		return err
	}
	return ei.fetch(url)
}
开发者ID:d4l3k,项目名称:mailgun-go,代码行数:38,代码来源:events.go



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang simplehttp.FormDataPayload类代码示例发布时间:2022-05-23
下一篇:
Golang simplehttp.NewHTTPRequest函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap