intercom / intercom-go

Go Bindings For Intercom
https://developers.intercom.io/reference
Other
70 stars 78 forks source link

How to reset attributes? #30

Closed bfontaine closed 6 years ago

bfontaine commented 8 years ago

Hello,

If you take a Company for example, its MonthlySpend field is not serialized if it’s 0 because of the omitempty tag:

type Company struct {
    // ...snip...
    MonthlySpend int32 `json:"monthly_spend,omitempty"`
    //                                      ^
    //                                      |
    //                                      here

This means saving Company{ID: "abc", MonthlySpend: 0} and Company{ID: "abc"} is the same. Shouldn’t you use an *int32 (int32 pointer) instead, and the same on all other reset-able fields?

josler commented 8 years ago

Yes, one of the goals I have for v2 is to move to pointer fields for all attributes, in order that this makes sense.

We do this already for some boolean values - with the helper intercom.Bool(true). I'd like to know if there's a better alternative than pointer fields, but that seems to be the norm.

travega commented 8 years ago

V2 is now available in the wild :) Reopen if you're still experiencing this issue :+1:

choran commented 6 years ago

Think this should have been closed before, not sure if it was re-opened by accident. Will close for now but if there is any outstanding issue then please re-open