novuhq / go-novu

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

Outdated de-serialization of topic response #80

Open JonasDoe opened 9 months ago

JonasDoe commented 9 months ago

When I run a request for a topic, the response is not deserialized properly. This is b/c the received JSON looks like this:

{
   "data":{
      "_id":"655b65b487e0d9949d7b4b70",
      "_environmentId":"655353e41bf45431ece3fddd",
      "_organizationId":"655353e31bf45431ece3fdd7",
      "key":"83f89d49-1c47-4217-a10c-26386e701bf4",
      "name":"Topic for 1963bc86-945b-4a9c-9728-4b03e752397c",
      "subscribers":[]
   }
}

, but the struct GetTopicResponse doesn't expect data but the inner item:

type GetTopicResponse struct {
    Id             string   `json:"_id"`
    OrganizationId string   `json:"_organizationId"`
    EnvironmentId  string   `json:"_environmentId"`
    Key            string   `json:"key"`
    Name           string   `json:"name"`
    Subscribers    []string `json:"subscribers"`
}

I can imagine this also applies to other requests I did not stumble upon. I could create a PR for GetTopicResponse, but I'm not sure whether that's the way to go or whether you're generating your SDKs from another place. :)

stonymahony commented 9 months ago

Same problem as with this issue #69 .

JonasDoe commented 9 months ago

Same problem as with this issue #69 .

I got the impression that the whole SDK is heavily outdated. I found more and more situations where it was firing wrong requests. Additionally, it's often enough hiding errors (esp. HTTP errors) and failure reports from responses. I guess one shouldn't really use it atm. I hope they will opt for a solution where they generate the client based on the underlying data modell or API, instead of maintaining it manually. This would not solve the issue with swallowed errors, but at least keep the SKD up to date. :/