-
Notifications
You must be signed in to change notification settings - Fork 75
Description
It is not possible to call Mailjet::Eventcallbackurl.create(...) more than once because the API version set with Mailjet.configure (such as v3) is overwritten by the Version attribute returned by the API call. (This Version attribute is 1 for ungrouped and 2 for grouped callbacks. Since support for this grouped feature is currently missing (see #266), this issue went undetected.)
The version is overwritten here:
mailjet-gem/lib/mailjet/resource.rb
Line 309 in c086506
| self.send("#{attribute_name}=", value) |
And this new value is then used in this weird bit of code to overwrite the API version:
mailjet-gem/lib/mailjet/resource.rb
Line 254 in c086506
| version: version || Mailjet.config.api_version, |
I'm not quite sure how best to fix this. Honestly, the implementation is, well, confusing and lacking isolation. The API settings (handed down to the resource classes) and other such resource state must be separated from the attributes read from the API response – to prevent name conflicts like this one.
As a really ugly workaround, I force reset the version after the API call:
Mailjet::Eventcallbackurl.version = Mailjet.config.api_version
As a side note, maybe the connection should be memoized here:
mailjet-gem/lib/mailjet/resource.rb
Line 31 in c086506
| def self.connection(options = {}) |