diff --git a/Classes/Client.php b/Classes/Client.php index 5bd8d0e..44fe0d3 100644 --- a/Classes/Client.php +++ b/Classes/Client.php @@ -88,6 +88,16 @@ class Client return $this->httpClient->request($method, $uri, $options); } + /** + * @param string $username + * @return $this + */ + public function sudo(string $username): self + { + $this->config['query']['sudo'] = $username; + return $this; + } + /** * @param array $authentication * @throws Exception diff --git a/README.md b/README.md index b5deb19..06704fd 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,13 @@ $repository = $giteaClient->repositories()->get('owner', 'repoName'); $repository = $giteaClient->miscellaneous()->version(); ``` +Run an API call as another user: + +``` +// e.g. check subscription status as a user +$status = $giteaClient->sudo('username')->repositories()->checkSubscription(); +``` + ## Versioning We use [SemVer](http://semver.org/) for versioning. For the versions available,