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

Allow to lock (toggle) users. #98

Merged
merged 3 commits into from
Feb 22, 2023
Merged

Conversation

ndeet
Copy link
Collaborator

@ndeet ndeet commented Feb 21, 2023

No description provided.

@ndeet ndeet requested a review from woutersamaey February 21, 2023 14:33
@@ -81,4 +81,26 @@ public function deleteUser(string $userId): bool
throw $this->getExceptionByStatusCode($method, $url, $response);
}
}

public function toggleUser(string $userId, bool $locked): bool
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't like the name of this method. Why not setUserLock() or something like that? It's not really a toggle if you're gonna pass the value. A toggle is off to on or on to off, not setting a value.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Or maybe setIsLocked() ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I basically tried to use what is in the API docs to avoid confusion. But yes we decided to do an opinionated library so it is ok to name things differently I guess. Will change it.

I will do setUserLock as we have User in all the other functions already. In hindsight we might should have left that repeating of the ClassName out on functions. Also the classes maybe should have been called UserClient and UserResult to avoid the need for aliasing classes when both are used. But yeah not too bad either way.

Copy link
Collaborator

Choose a reason for hiding this comment

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

These are all good ideas. We can do this, but would need to release a new major version as they are breaking changes. I am for doing this as existing users can just stay on the current version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tracking here #100

$response = $this->getHttpClient()->request($method, $url, $headers, $body);

if ($response->getStatus() === 200) {
return true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why return true if you're never going to return false? Just return void and let us be happy there was no exception.

Copy link
Collaborator Author

@ndeet ndeet Feb 22, 2023

Choose a reason for hiding this comment

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

If you search the code we have that in many places like this. The benefit over void is that you can rely on it if it was successful? e.g. if (someFunction()) {} ? A void return type would return null and you can't be sure it worked? On the other hand you have it in a try catch block anyway, so yeah not sure. Maybe keep it for now as of consistency with the other places we use it like this and refactor on a major release?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Agreed on sticking with existing code style. Would be better to refactor in next major version.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

tracking it here #99

@ndeet ndeet merged commit c3b1305 into btcpayserver:master Feb 22, 2023
@ndeet ndeet deleted the toggle-user branch February 22, 2023 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants