Merged
Conversation
044893d to
54e20d2
Compare
teddyhwang
reviewed
Feb 16, 2022
Comment on lines
+66
to
+67
| if (strpos($path, "/admin") !== 0) { | ||
| $path = "/admin/api/$apiVersion$path"; |
Collaborator
There was a problem hiding this comment.
instead of assuming $path has a / with the getRequestPath helper, can we instead:
Suggested change
| if (strpos($path, "/admin") !== 0) { | |
| $path = "/admin/api/$apiVersion$path"; | |
| if ($path[0] != '/') { | |
| $path = "/admin/api/$apiVersion/$path"; |
Contributor
Author
There was a problem hiding this comment.
parent::getRequestPath is set up to always ensure the path has a / at position 0, which of course we could change here, but I wasn't too keen on using just the slash as a marker for a full path because I felt it would be too error prone.
My main concern was that folks would try things like /product.json, which I think should just be prefixed with the default.
54e20d2 to
b07692d
Compare
b07692d to
5b42cee
Compare
teddyhwang
approved these changes
Feb 17, 2022
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.
WHY are these changes introduced?
Currently, we can't handle requests like access scopes (
/admin/oauth/access_scopes.json) or token access (/admin/api_permissions/current.json), because these resources use custom paths instead of the default/admin/api/{version}/....This means we can't easily reach those endpoints unless the code uses the base HTTP client that the REST one is built upon, which makes things unnecessarily complicated.
WHAT is this pull request doing?
This PR solves that problem by allowing REST calls in the Admin API client to be made using a full path. Therefore, requests like
work just like any regular request would.
Type of change
Checklist