Giter Club home page Giter Club logo

Comments (9)

swooop avatar swooop commented on August 16, 2024

I'll have a look at the filters and check it's not API related, thanks for bringing this up

from mailjet-gem.

Electron-libre avatar Electron-libre commented on August 16, 2024

I've done few tests with curl against the contact resource.
Using filters works with query string but not with json payload. Maybe this could explain the issue.
The API documentation is not really explicit around this.

from mailjet-gem.

swooop avatar swooop commented on August 16, 2024

Awesome - thanks for that, we'll look into it.

Much appreciated.

from mailjet-gem.

swooop avatar swooop commented on August 16, 2024

Ah, ok, I see what's happening here - when you use:

Mailjet::Contact.all('ContactsList' => remote_list.id)
#or
Mailjet::Contact.all(:contactslist => remote_list.id)

The filters passed in are formatted into a query string by the gem.
When the filters are correctly formatted:

https://api.mailjet.com/v3/REST/contact?contactslist=1

You get the required response.

When the filters are incorrect, the API ignores them, for instance if a raw API call is something like:

# A GET to:
https://api.mailjet.com/v3/REST/contact?contcatlis=1

It then defaults to what is effectively:

Mailjet::Contact.all

And you get the 'all' call for the resource.

I think implementing filter checking could be quite challenging as there are so many over so many resources, so it might be best to add a note to the readme.

You are correct, the API does not support filtering by JSON payload.

Hope that helps, all the best,

Toby

from mailjet-gem.

Electron-libre avatar Electron-libre commented on August 16, 2024

What lead to confusion is this : https://github.com/mailjet/mailjet-gem#naming-conventions

When I use :contact_list as a filter I expect it to be sent as ContactList and the query should succeed.
The issue I think is that filters are not converted to camelcase.

from mailjet-gem.

swooop avatar swooop commented on August 16, 2024

You're quite right - I'll have a look through previous commits and see what changed.

from mailjet-gem.

WeshGuillaume avatar WeshGuillaume commented on August 16, 2024

Hi !

Sorry for the delay, and thanks for that relevant issue. You might take a look at the filters branch, which we are soon going to release into master. It automatically convert :snake_case_symbols into 'CamelCaseString' so both of your examples would work !
You may need to consider a few days before the merge, but you can already use the feature.

Regards,
Guillaume

from mailjet-gem.

WeshGuillaume avatar WeshGuillaume commented on August 16, 2024

Hi @Electron-libre !

If you have any other suggestion, i would be happy to help ! Otherwise, please consider closing the issue :)

Regards,
Guillaume

from mailjet-gem.

Electron-libre avatar Electron-libre commented on August 16, 2024

Hi,
Sounds great. Thanks for your feedback and fixes.

Kind Regards

from mailjet-gem.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.