feat: Support multiple duplicate queryparams #134
Merged
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.
The SendGrid API documentation states that the user can supply up to ten
categories, but there is no way to supply them using the Java library.
This commit fixes the problem by interpreting any value that has an
ampersand in it as a list of values, which will be inserted as multiple
query params.
For example, the call
request.addQueryParam("categories", "cat1&cat2")
will output
categories=cat1&categories=cat2
into the URL.I also modified the
testbuildUri
test a bit because I would have had writeout too many permutations of the resulting URL string because the order
of the query params is not deterministic in the current implementation.
Another solution would be to store the query params in
Map<String, String[]>
so we wouldn't need to split the string. Then the user could just call
This would, however, change the API of the library, so I didn't go for this route now.
Fixes
A short description of what this PR does.
Checklist
If you have questions, please file a support ticket, or create a GitHub Issue in this repository.