Skip to content

Commit

Permalink
Allow for updating EmailBlacklisted field
Browse files Browse the repository at this point in the history
This is a dirty workaround for the problem with Golang empty values
and marshaling to JSON. The problem was described here:

https://willnorris.com/2014/05/go-rest-apis-and-pointers/

In this library all struct's fields should be pointers, not simple types
like `bool` or `string` because we can't say whether a value is empty
and we should omit it (`omitempty` field tag) or not.

This library is auto-generated by swagger codegen, and developers created
an issue for this problem:
swagger-api/swagger-codegen#7391

In this pull request we dirty fix our problem with only one field we want
to update (set value to false)
  • Loading branch information
y3ti committed Nov 9, 2021
1 parent aae3a06 commit 06a5830
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/sendinblue/APIv3-go-library
module github.com/ghostery/APIv3-go-library

go 1.16

Expand Down
4 changes: 2 additions & 2 deletions lib/model_update_contact.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* SendinBlue API
*
* SendinBlue provide a RESTFul API that can be used with any languages. With this API, you will be able to : - Manage your campaigns and get the statistics - Manage your contacts - Send transactional Emails and SMS - and much more... You can download our wrappers at https://github.com/orgs/sendinblue **Possible responses** | Code | Message | | :-------------: | ------------- | | 200 | OK. Successful Request | | 201 | OK. Successful Creation | | 202 | OK. Request accepted | | 204 | OK. Successful Update/Deletion | | 400 | Error. Bad Request | | 401 | Error. Authentication Needed | | 402 | Error. Not enough credit, plan upgrade needed | | 403 | Error. Permission denied | | 404 | Error. Object does not exist | | 405 | Error. Method not allowed | | 406 | Error. Not Acceptable |
* SendinBlue provide a RESTFul API that can be used with any languages. With this API, you will be able to : - Manage your campaigns and get the statistics - Manage your contacts - Send transactional Emails and SMS - and much more... You can download our wrappers at https://github.com/orgs/sendinblue **Possible responses** | Code | Message | | :-------------: | ------------- | | 200 | OK. Successful Request | | 201 | OK. Successful Creation | | 202 | OK. Request accepted | | 204 | OK. Successful Update/Deletion | | 400 | Error. Bad Request | | 401 | Error. Authentication Needed | | 402 | Error. Not enough credit, plan upgrade needed | | 403 | Error. Permission denied | | 404 | Error. Object does not exist | | 405 | Error. Method not allowed | | 406 | Error. Not Acceptable |
*
* API version: 3.0.0
* Contact: [email protected]
Expand All @@ -13,7 +13,7 @@ type UpdateContact struct {
// Pass the set of attributes to be updated. These attributes must be present in your account. To update existing email address of a contact with the new one please pass EMAIL in attribtes. For example, `{ \"EMAIL\":\"[email protected]\", \"FNAME\":\"Ellie\", \"LNAME\":\"Roger\"}`. Keep in mind transactional attributes can be updated the same way as normal attributes. Mobile Number in \"SMS\" field should be passed with proper country code. For example {\"SMS\":\"+91xxxxxxxxxx\"} or {\"SMS\":\"0091xxxxxxxxxx\"}
Attributes *interface{} `json:"attributes,omitempty"`
// Set/unset this field to blacklist/allow the contact for emails (emailBlacklisted = true)
EmailBlacklisted bool `json:"emailBlacklisted,omitempty"`
EmailBlacklisted bool `json:"emailBlacklisted"`
// Set/unset this field to blacklist/allow the contact for SMS (smsBlacklisted = true)
SmsBlacklisted bool `json:"smsBlacklisted,omitempty"`
// Ids of the lists to add the contact to
Expand Down

0 comments on commit 06a5830

Please sign in to comment.