Enable Dynamic URL Generation for #pageable_get via Proc Objects#955
Merged
Enable Dynamic URL Generation for #pageable_get via Proc Objects#955
#pageable_get via Proc Objects#955Conversation
|
Code Climate has analyzed commit 4756005 and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 98.6% (90% is the threshold). This pull request will bring the total coverage in the repository to 99.1% (0.0% change). View more on Code Climate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This Pull Request introduces an enhancement to the
#pageable_getmethod in our Ruby library. It enables the use of aProcobject for thepagingoption, allowing more dynamic and flexible generation of request URLs based on the response body.Background
Previously, the
pagingoption in the#pageable_getmethod was limited to specifying URLs using JSONPath. This approach was effective but had a limitation: it could not handle cases where the URL provided in the response body was not a full path. This limitation could hinder the method's utility in scenarios where the API responses include relative URLs or require more complex URL construction based on the response.Changes
The proposed change allows the
pagingoption to accept aProcobject. This enhancement provides the following benefits:Proc, users gain finer control over the URL generation process, allowing for more complex scenarios and efficient handling of API responses.Implementation Details
With this update, when a
Procis provided as thepagingoption, it will be called with theSawyer::Responseobject as its argument. This allows theProcto access the entire response body and headers, enabling it to generate the next URL based on any aspect of the response.Example Usage
Conclusion
This enhancement to the
#pageable_getmethod significantly increases its versatility and applicability to a broader range of API interactions. By allowing dynamic URL generation through aProc, we can accommodate a wider variety of API response patterns, making our library more robust and flexible for users.