Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resource instances don't hit API? #96

Closed
excid3 opened this issue May 24, 2017 · 5 comments
Closed

Resource instances don't hit API? #96

excid3 opened this issue May 24, 2017 · 5 comments

Comments

@excid3
Copy link

excid3 commented May 24, 2017

Was doing some debugging today and noticed that resource instance methods like update_attributes don't hit the API. Since instance methods don't call the change_resource_path like the class methods do, they don't get the correct endpoint, version, and so on.

# class method, correctly hits API
c = Mailjet::Contactdata.find("name@address.com") 

# instance method, immediately returns true without hitting the API
c.update_attributes("data"=>[{"Name"=>"plan", "Value"=>"monthly"}])

Should these methods be updated in Resource to call that? For example, modifying the method like this works:

    def update_attributes(attribute_hash = {}, options = {})
      self.attributes = attribute_hash
      opts = self.class.change_resource_path(options) # this was added to get the default config
      save(opts)
    end
@Zhivko-Mailjet
Copy link
Contributor

Hi @excid3

Thanks for spotting and reporting the problem. We will investigate further on our end.

In the meantime, we will be more than happy to review your contribution

@Lorel
Copy link
Contributor

Lorel commented May 26, 2017

Hi @excid3

Indeed, nice catch!
2fc4bcc should fix that

@arnaudbreton
Copy link
Contributor

Hi @excid3, I've just published v1.5.1 which contains the fix @Lorel mentioned just above. It's available on Rubygems.

Hope it works for you, please let us know.
Anyway, many thanks for reporting it and for having chosen Mailjet to power your emails.

@excid3
Copy link
Author

excid3 commented May 30, 2017

Fantastic, thanks guys! Will update to that and let you know if I run into any issues.

@arnaudbreton
Copy link
Contributor

Awesome, thanks @excid3 for your feedback and time. Looking forward to hear back!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants