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

Ability to retrieve total count of a resource #10

Open
amoe opened this issue Dec 7, 2016 · 3 comments
Open

Ability to retrieve total count of a resource #10

amoe opened this issue Dec 7, 2016 · 3 comments

Comments

@amoe
Copy link

amoe commented Dec 7, 2016

I wanted to retrieve the total count of customers. According to the documentation for the upstream Stripe API,

You can optionally request that the response include the total count of all
customers that match your filters. To do so, specify include[]=total_count in
your request.

However, I couldn't figure out if this is possible using Elephant and the clojurewerkz.elephant.customers/list function. I tried using (ecr/list {"include[]" "total_count"}) but, as the result is always a plain sequence of customer maps, the count was not accessible.

@michaelklishin
Copy link
Member

Elephant returns the JSON objects as they are returned (it does inject a couple of fields for its own use but they are clearly prefixed). I cannot say how to do it without running an experiment.

@amoe
Copy link
Author

amoe commented Dec 7, 2016

Although Elephant does return the untouched JSON for each individual customer, there are additional fields in the JSON at the top-level -- that is, calling .getData() on the CustomerCollection descends one level. .getTotalCount would also be possible directly on the CustomerCollection, but Elephant hides that. Seems quite technically simple to add, but quite disruptive to the interface in general. :/

https://github.com/clojurewerkz/elephant/blob/master/src/clojure/clojurewerkz/elephant/conversion.clj#L300

@michaelklishin
Copy link
Member

It's a pre-1.0 library. @amoe feel free to submit a PR. It's also possible to have data structures in Clojure that look and work like maps but are actually Java classes. I hope we can avoid it here but if we want to make something look like a map for all intents and purposes, we can do that.

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