novuhq / go-novu

GO SDK for Novu - The open-source notification infrastructure for engineers. 🚀
MIT License
57 stars 45 forks source link

SubscriberApi.UpdatePreferences: Broken method #90

Open Catzilla opened 3 weeks ago

Catzilla commented 3 weeks ago

According to API Reference for UpdatePreferences method, channel field should be object, not array

Moreover, this endpoint supports partial update, which means that only enabled or only channel may be set

But if we set only enabled, and set it to false as follow:

opts := &novu.UpdateSubscriberPreferencesOptions{
    Enabled: false,
}

request will fail, because omitempty tag in struct treat false as empty field, and omit it from request

Furthermore, data field in response of this endpoint is a single object, not array, which results in unmarshalling error, making UpdatePreferences method completely useless in current package version