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

Filterable attributes #117

Open
ehannes opened this issue Oct 10, 2017 · 1 comment
Open

Filterable attributes #117

ehannes opened this issue Oct 10, 2017 · 1 comment

Comments

@ehannes
Copy link
Member

ehannes commented Oct 10, 2017

From #113

Ok, now I know how this works.

First of all, Fortnox expects the request to look something like this:

https://api.fortnox.se/3/articles?articlenumber=1
Now to the gem. The find method calls find_all_by when you send it a hash.

def find_all_by( hash )
response_hash = get( "#{ self.class::URI }?#{ to_query( hash ) }" )
instantiate_collection_response( response_hash )
end

There are no use of any mappers or anything here (to_query simply turns articlenumber: 1 to &articlenumber=1). Since find_all_by simply turns whatever you give it to query parameters, it not only supports attributes, but filters, sorting, searching, limits & offsets as well as pagination. That is why we need to pass articlenumber and not article_number to the find-method. Whether we should change that or not is open for discussion :)

@d-Pixie
Copy link
Member

d-Pixie commented Oct 19, 2017

We should change it :)

The correct implementation is that the to_query method actually uses the mapper and that we also drop any attributes sent in that are not tagged as "filterable" in the options (see the #121 PR).

@d-Pixie d-Pixie self-assigned this Oct 19, 2017
@d-Pixie d-Pixie changed the title Sortable attributes Filterable attributes Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants