Add support for Nextcloud 14, also compatible with Nextcloud 15
Background and grounds for PR
Since Nextcloud are adding features without updating the API version, I believe it makes sense to introduce the tracking of Nextcloud versions in this library. If only API version would be tracked, it will be hard for users of this library to know whether the version of the library will be compatible with the version of Nextcloud.
For instance Nextcloud 14 has added a few parameters to the user provisioning endpoint.
The API version is not bumped though (which is of course totally fine).
If these new parameters would have been added to the current UsersClient, then all of a sudden it would not have been backwards compatible. And I'm reluctant to introduce versioning inside the class.
What was done instead is that a new namespace, NextCloudVersion14, was introduced in the library.
In that way no current users are affected, and those who are upgrading to Nextcloud 14, 15 and so on can easily switch.
Current users bootstrap the library like this (as stated in README - nothing has changed):
$wrapper = \NextcloudApiWrapper\Wrapper::build(...);
For users of Nextcloud 14 it would instead be like this:
$wrapper = \NextcloudApiWrapper\NextCloudVersion14\Wrapper::build(...);
Code wise there are very few changes, as the classes I've created in the NextCloudVersion14 namespace inherits all functionality from the original classes, copying their exact behaviour.
The only class which actually extends functionality is the UsersClient which now accepts more parameters.
Two small changes in the original wrapper
- Change the constructor to be public.
- In
build(), callnew staticinstead of hard codednew Wrapperto let the current namespace decide which version of theWrapperwhich is instantiated.
Looks good to me, thanks a lot for your work! I'm not so sure about defining API version in separate class, wouldn't it look better to have a global provider like $wrapper::build(... $version), providing API version in the build method and automatically getting the correct objects?
Sure - I was thinking the same, but wanted as few changes to the original code as possible. You wan't me to look into it?
@kler if possible that would be awesome, I dont really have the time currently sorry, thanks a lot for your help anyway!