-
Notifications
You must be signed in to change notification settings - Fork 37
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
[FEATURE] Adds getAll() method to BaseClient #61
[FEATURE] Adds getAll() method to BaseClient #61
Conversation
…wise gets overriden)
Hi @web-dev-passion, a great method that aims to improve the developer experience. |
Thank you @web-dev-passion i see you update the PR with the latest changes. 🥳 |
@web-dev-passion I'm going to ask you for a little more effort. As you can see, the CICD failed. |
@web-dev-passion i was creating integration tests for your pull request. The integration test I'm using is:
|
@web-dev-passion I'm going to merge your PR and i will fix the code style. |
Pull request type
How to test this PR
This PR uses
get()
inside its method body. It is inspired by thegetAll()
implementation inside the storyblok-js-client.See https://github.com/storyblok/storyblok-js-client
After reading through this info you should have an insight of what functionality the PR provides.
You can test the pagination logic by making a
getAll()
-method-call and compare what effects different api conditions (for example 24 entries, 25 or 26) have.The getAll(() is expected to return an
array
of one - manystdClass
storyblok responses, just likeget()
returns but multiple respones.What is the new behavior?
First of all, the
getAll()
takes the same parameters likeget()
.If
per_page
is provided via the$queryString
parameters it gets used, otherwise a newly created class constantDEFAULT_PER_PAGE
which is set to25
is used.The first
get
request gives us the first response$firstResponse
.With this response we investigate the response headers sent to define our needed amount of requests with the goal in mind to receive all entries at the end.
In general the
getAll()
makes one to manyget()
requests based on totalRecords, that were received through the first response$firstResponse
via the responses' header['Total']
.Other information
To my mind this PR is more than needed. Every time a user of this php-client want to get more entries than what can be controlled via
per_page
which is limited to 1000 by Storyblok's limitations, he/she needs to implement this logic everytime.Moreover, it was included in the js-implementation, so why should not we also implement this in PHP?