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

Adding pagination, tests, + docs to Client Grants; minor test suite refactor #271

Merged
merged 1 commit into from
Jul 3, 2018

Conversation

joshcanhelp
Copy link
Contributor

@joshcanhelp joshcanhelp commented Jul 2, 2018

  • Add public getAll method with pagination parameters
  • Add public getByAudience method to filter by audience
  • Add public getByClientId method to filter by client ID
  • Add CoreException throws to create if required params are empty or invalid
  • Add comment to deprecate get method (cannot get a Client Grant by ID so the method is useless)
  • Add test coverage
  • Minor changes to code quality scanning
  • Add test helper getApiStatic (will propagate throughout testing code base in different PR)

@joshcanhelp joshcanhelp added this to the v5-Next milestone Jul 2, 2018
*/
public function get($id, $audience = null)
public function getAll(array $params = [], $page = null, $per_page = null)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like I'm changing the method name here but I'm not. The get method still exists (in a semi-broken state), moved to the bottom of the class with a TODO to deprecate.

@joshcanhelp joshcanhelp force-pushed the add-pagination-client-grants branch from 2013966 to 34e5d12 Compare July 2, 2018 17:36
Copy link
Member

@cocojoe cocojoe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback

*/
public function getByAudience($audience, $page = null, $per_page = null)
{
if (empty($audience) || ! is_string($audience)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that exclamation mark

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the rest of the code follows this, although I think it's ugly. If it's consistent with the rest of the code base, then I'm fine with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Ugly" as in you don't like the error checking here? @lbalmaceda and I talked about failing early in methods to avoid API errors. For this one, an empty $audience would not fail but it also would not filter so the method would be useless.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't like the space between a ! and the context. But don't have any strong feelings as all the others are like this in the PR so presume it's inline with coding style of the SDK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was on the fence about the space. This is all whitespace-corrected now so I can enforce no space.

*
* @link https://auth0.com/docs/api/management/v2#!/Client_Grants/get_client_grants
*/
public function getByClientId($client_id, $page = null, $per_page = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this convenience method also in other SDKs?
/cc @lbalmaceda

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I know of but I don't think that's a good reason not to add it here. Make the developer's life easier!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, it's always good to create more convenience for the end user, balanced with maintainability.

*
* @link https://auth0.com/docs/api/management/v2#!/Client_Grants/get_client_grants
*/
public function getByAudience($audience, $page = null, $per_page = null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this convenience method also in other SDKs?
/cc @lbalmaceda

* @return mixed
*
* @throws \Exception Thrown by the Guzzle HTTP client when there is a problem with the API call.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although we use Guzzle I would not mention it by name, goes for all mentions in this PR.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We use it in the variable name for the API. It will also appear in the error name. I think it's helpful here in case someone is getting a fatal error and want to know where to start troubleshooting.

*/
public function create($client_id, $audience, $scope)
public function delete($id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So presume audience is no longer required? What happens in PHP if a developer makes a call to a method that has a change in signature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bad diff for this one ... you can see this is a different method.

To answer your question though ... it wouldn't fail, it just wouldn't use that param.

@cocojoe
Copy link
Member

cocojoe commented Jul 3, 2018

@joshcanhelp in the description please list the Public API changes, list of method/signatures added, changed etc

*/
public function create($client_id, $audience, $scope)
public function delete($id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, the one I saw was delete($id) vs delete($id, $audience = null)

@joshcanhelp joshcanhelp merged commit 1ab236f into master Jul 3, 2018
@joshcanhelp joshcanhelp deleted the add-pagination-client-grants branch July 3, 2018 19:07
@github-actions
Copy link
Contributor

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 24, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants