From d527b06af7f11fd458b5d1187918fd29f631299c Mon Sep 17 00:00:00 2001 From: Michael Gerdemann Date: Sun, 19 Jan 2020 12:40:08 +0100 Subject: [PATCH] feat: Run API call as another user --- Classes/Client.php | 10 ++++++++++ README.md | 7 +++++++ 2 files changed, 17 insertions(+) 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,