Skip to content

API version overwritten by response #267

@svoop

Description

@svoop

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:

self.send("#{attribute_name}=", value)

And this new value is then used in this weird bit of code to overwrite the API version:

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:

def self.connection(options = {})

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions