intercom / intercom-go

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

Bad parameters should be ignored when updating #18

Closed bfontaine closed 9 years ago

bfontaine commented 9 years ago

Hello,

I’m updating the custom attributes of companies with the following code:

    company, err := ic.Companies.FindByCompanyID(...)
    if err != nil {
        return err
    }

    // ... update company.CustomAttributes ...

    _, err = ic.Companies.Save(&company)

Some of them have a non-zero SessionCount attribute. When the company is sent again to the API; I get a 400 response saying “bad 'session_count' parameter”. This parameter is ignored when it’s 0 because of the omitempty here but is sent if non-zero. It shouldn’t be sent to the API ever, even if non-zero.

Note that I can’t just send updates without looking if the company exists before because if it doesn’t it’ll be created:

Companies are looked up via company_id, if not found via company_id, the new company will be created, if found, that company will be updated.

Source: https://doc.intercom.io/api/#create-or-update-company

Thanks.