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

Get results one page at a time #46

Closed
spartan001 opened this issue Nov 4, 2014 · 3 comments
Closed

Get results one page at a time #46

spartan001 opened this issue Nov 4, 2014 · 3 comments

Comments

@spartan001
Copy link

I would prefer to not have paging handled by this library. Is there a way to expose that so I can get results one page at a time?

@nnabuuu
Copy link
Collaborator

nnabuuu commented Nov 6, 2014

I don't think there is a way to achieve this now. But I believe we can have this feature in the future. (Introduce extra parameter for requestAll may be helpful)

@nnabuuu
Copy link
Collaborator

nnabuuu commented Nov 18, 2014

Hi @blakmatrix ,
I am thinking about the way to support user handle page of their own.

in zendesk's develop site, it is already offered that if we pass 2 parameters per_page and page, then list method will return corresponding result. And, I have tried your request method, calling it like this.request('GET', ['categories'], {per_page: 10, page: 2}, cb) will return exactly want he expects.

So, I am thinking of the following:

Way 1. We make another option like extraOptions.autoPageHandling: false, and if that happen, requestAll = request, then we use ways like Array.prototype.concat.call(['GET', ['categories']], Array.prototype.slice.call(arguments)); to create the arguments this.request('GET', ['categories'], {per_page: 10, page: 2}, cb)

Way 2. We dynamically judge by arguments, if the last 1st or 2nd object is {per_page: ?? , page: ??}, then we call request, otherwise we call requestAll.

However, both way need to change code a lot : (

Any comment?

@blakmatrix
Copy link
Owner

I for a while have wanted to refactor this library, that being said though, I feel we should expose an option to disable autopaging, If I were to go back, the option would have been reverse, that auto-paging would have been a feature rather than a default.

I almost feel like the most straightforward approach might be to just increment the major form here, enforce options object to be sent (or assumed empty -- unless we expose methods to change default options) and a option to turn auto-paging on with the default being off. I agree, I think anyway we cut it it's going to be a major change, and if that's the case I'd like to also adress some of the other open issues here and considerations on how Zendesks API has been changing as well and refactor accordingly. I wanted to move away from nconf as it is no longer maintained adressing the concerns in #36 .

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

3 participants