Skip to content

Commit 08e117d

Browse files
Replace snippet usernames with workspaces (#45)
* Replace snippet usernames with workspaces * Fixed filename
1 parent 9c903cc commit 08e117d

File tree

11 files changed

+66
-66
lines changed

11 files changed

+66
-66
lines changed

src/Api/Snippets.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace Bitbucket\Api;
1515

16-
use Bitbucket\Api\Snippets\Users as SnippetsUsers;
16+
use Bitbucket\Api\Snippets\Workspaces as SnippetsUsers;
1717
use Bitbucket\HttpClient\Message\FileResource;
1818
use Http\Message\MultipartStream\MultipartStreamBuilder;
1919

@@ -57,7 +57,7 @@ public function create(FileResource $file)
5757
/**
5858
* @param string $username
5959
*
60-
* @return \Bitbucket\Api\Snippets\Users
60+
* @return \Bitbucket\Api\Snippets\Workspaces
6161
*/
6262
public function users(string $username)
6363
{

src/Api/Snippets/AbstractSnippetsApi.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,21 +24,21 @@
2424
abstract class AbstractSnippetsApi extends AbstractApi
2525
{
2626
/**
27-
* The username.
27+
* The workspace.
2828
*
2929
* @var string
3030
*/
31-
protected $username;
31+
protected $workspace;
3232

3333
/**
3434
* Create a new api instance.
3535
*
3636
* @param \Http\Client\Common\HttpMethodsClientInterface $client
37-
* @param string $username
37+
* @param string $workspace
3838
*/
39-
public function __construct(HttpMethodsClientInterface $client, string $username)
39+
public function __construct(HttpMethodsClientInterface $client, string $workspace)
4040
{
4141
parent::__construct($client);
42-
$this->username = $username;
42+
$this->workspace = $workspace;
4343
}
4444
}

src/Api/Snippets/Users.php renamed to src/Api/Snippets/Workspaces.php

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,22 @@
1313

1414
namespace Bitbucket\Api\Snippets;
1515

16-
use Bitbucket\Api\Snippets\Users\Comments;
17-
use Bitbucket\Api\Snippets\Users\Commits;
18-
use Bitbucket\Api\Snippets\Users\Diffs;
19-
use Bitbucket\Api\Snippets\Users\Files;
20-
use Bitbucket\Api\Snippets\Users\Patches;
21-
use Bitbucket\Api\Snippets\Users\Watchers;
22-
use Bitbucket\Api\Snippets\Users\Watching;
16+
use Bitbucket\Api\Snippets\Workspaces\Comments;
17+
use Bitbucket\Api\Snippets\Workspaces\Commits;
18+
use Bitbucket\Api\Snippets\Workspaces\Diffs;
19+
use Bitbucket\Api\Snippets\Workspaces\Files;
20+
use Bitbucket\Api\Snippets\Workspaces\Patches;
21+
use Bitbucket\Api\Snippets\Workspaces\Watchers;
22+
use Bitbucket\Api\Snippets\Workspaces\Watching;
2323
use Bitbucket\HttpClient\Message\FileResource;
2424
use Http\Message\MultipartStream\MultipartStreamBuilder;
2525

2626
/**
27-
* The users api class.
27+
* The workspaces api class.
2828
*
2929
* @author Graham Campbell <[email protected]>
3030
*/
31-
class Users extends AbstractSnippetsApi
31+
class Workspaces extends AbstractSnippetsApi
3232
{
3333
/**
3434
* @param array $params
@@ -39,7 +39,7 @@ class Users extends AbstractSnippetsApi
3939
*/
4040
public function list(array $params = [])
4141
{
42-
$path = $this->buildUsersPath();
42+
$path = $this->buildWorkspacesPath();
4343

4444
return $this->get($path, $params);
4545
}
@@ -53,7 +53,7 @@ public function list(array $params = [])
5353
*/
5454
public function create(FileResource $file)
5555
{
56-
$path = $this->buildUsersPath();
56+
$path = $this->buildWorkspacesPath();
5757
$builder = (new MultipartStreamBuilder())->addResource($file->getName(), $file->getResource(), $file->getOptions());
5858
$headers = ['Content-Type' => sprintf('multipart/form-data; boundary="%s"', $builder->getBoundary())];
5959

@@ -70,7 +70,7 @@ public function create(FileResource $file)
7070
*/
7171
public function show(string $snippet, array $params = [])
7272
{
73-
$path = $this->buildUsersPath($snippet);
73+
$path = $this->buildWorkspacesPath($snippet);
7474

7575
return $this->get($path, $params);
7676
}
@@ -85,7 +85,7 @@ public function show(string $snippet, array $params = [])
8585
*/
8686
public function update(string $snippet, array $params = [])
8787
{
88-
$path = $this->buildUsersPath($snippet);
88+
$path = $this->buildWorkspacesPath($snippet);
8989

9090
return $this->post($path, $params);
9191
}
@@ -100,7 +100,7 @@ public function update(string $snippet, array $params = [])
100100
*/
101101
public function updateFiles(string $snippet, array $files)
102102
{
103-
$path = $this->buildUsersPath($snippet);
103+
$path = $this->buildWorkspacesPath($snippet);
104104

105105
$builder = new MultipartStreamBuilder();
106106

@@ -123,92 +123,92 @@ public function updateFiles(string $snippet, array $files)
123123
*/
124124
public function remove(string $snippet, array $params = [])
125125
{
126-
$path = $this->buildUsersPath($snippet);
126+
$path = $this->buildWorkspacesPath($snippet);
127127

128128
return $this->delete($path, $params);
129129
}
130130

131131
/**
132132
* @param string $snippet
133133
*
134-
* @return \Bitbucket\Api\Snippets\Users\Comments
134+
* @return \Bitbucket\Api\Snippets\Workspaces\Comments
135135
*/
136136
public function comments(string $snippet)
137137
{
138-
return new Comments($this->getHttpClient(), $this->username, $snippet);
138+
return new Comments($this->getHttpClient(), $this->workspace, $snippet);
139139
}
140140

141141
/**
142142
* @param string $snippet
143143
*
144-
* @return \Bitbucket\Api\Snippets\Users\Commits
144+
* @return \Bitbucket\Api\Snippets\Workspaces\Commits
145145
*/
146146
public function commits(string $snippet)
147147
{
148-
return new Commits($this->getHttpClient(), $this->username, $snippet);
148+
return new Commits($this->getHttpClient(), $this->workspace, $snippet);
149149
}
150150

151151
/**
152152
* @param string $snippet
153153
*
154-
* @return \Bitbucket\Api\Snippets\Users\Diffs
154+
* @return \Bitbucket\Api\Snippets\Workspaces\Diffs
155155
*/
156156
public function diffs(string $snippet)
157157
{
158-
return new Diffs($this->getHttpClient(), $this->username, $snippet);
158+
return new Diffs($this->getHttpClient(), $this->workspace, $snippet);
159159
}
160160

161161
/**
162162
* @param string $snippet
163163
*
164-
* @return \Bitbucket\Api\Snippets\Users\Files
164+
* @return \Bitbucket\Api\Snippets\Workspaces\Files
165165
*/
166166
public function files(string $snippet)
167167
{
168-
return new Files($this->getHttpClient(), $this->username, $snippet);
168+
return new Files($this->getHttpClient(), $this->workspace, $snippet);
169169
}
170170

171171
/**
172172
* @param string $snippet
173173
*
174-
* @return \Bitbucket\Api\Snippets\Users\Patches
174+
* @return \Bitbucket\Api\Snippets\Workspaces\Patches
175175
*/
176176
public function patches(string $snippet)
177177
{
178-
return new Patches($this->getHttpClient(), $this->username, $snippet);
178+
return new Patches($this->getHttpClient(), $this->workspace, $snippet);
179179
}
180180

181181
/**
182182
* @param string $snippet
183183
*
184-
* @return \Bitbucket\Api\Snippets\Users\Watchers
184+
* @return \Bitbucket\Api\Snippets\Workspaces\Watchers
185185
*/
186186
public function watchers(string $snippet)
187187
{
188-
return new Watchers($this->getHttpClient(), $this->username, $snippet);
188+
return new Watchers($this->getHttpClient(), $this->workspace, $snippet);
189189
}
190190

191191
/**
192192
* @param string $snippet
193193
*
194-
* @return \Bitbucket\Api\Snippets\Users\Watching
194+
* @return \Bitbucket\Api\Snippets\Workspaces\Watching
195195
*/
196196
public function watching(string $snippet)
197197
{
198-
return new Watching($this->getHttpClient(), $this->username, $snippet);
198+
return new Watching($this->getHttpClient(), $this->workspace, $snippet);
199199
}
200200

201201
/**
202-
* Build the users path from the given parts.
202+
* Build the workspaces path from the given parts.
203203
*
204204
* @param string[] $parts
205205
*
206206
* @throws \Bitbucket\Exception\InvalidArgumentException
207207
*
208208
* @return string
209209
*/
210-
protected function buildUsersPath(string ...$parts)
210+
protected function buildWorkspacesPath(string ...$parts)
211211
{
212-
return static::buildPath('snippets', $this->username, ...$parts);
212+
return static::buildPath('snippets', $this->workspace, ...$parts);
213213
}
214214
}

src/Api/Snippets/Users/AbstractUsersApi.php renamed to src/Api/Snippets/Workspaces/AbstractWorkspacesApi.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Bitbucket\Api\Snippets\Users;
14+
namespace Bitbucket\Api\Snippets\Workspaces;
1515

1616
use Bitbucket\Api\Snippets\AbstractSnippetsApi;
1717
use Http\Client\Common\HttpMethodsClientInterface;
1818

1919
/**
20-
* The abstract users api class.
20+
* The abstract workspaces api class.
2121
*
2222
* @author Graham Campbell <[email protected]>
2323
*/
24-
abstract class AbstractUsersApi extends AbstractSnippetsApi
24+
abstract class AbstractWorkspacesApi extends AbstractSnippetsApi
2525
{
2626
/**
2727
* The snippet.
@@ -34,12 +34,12 @@ abstract class AbstractUsersApi extends AbstractSnippetsApi
3434
* Create a new api instance.
3535
*
3636
* @param \Http\Client\Common\HttpMethodsClientInterface $client
37-
* @param string $username
37+
* @param string $workspace
3838
* @param string $snippet
3939
*/
40-
public function __construct(HttpMethodsClientInterface $client, string $username, string $snippet)
40+
public function __construct(HttpMethodsClientInterface $client, string $workspace, string $snippet)
4141
{
42-
parent::__construct($client, $username);
42+
parent::__construct($client, $workspace);
4343
$this->snippet = $snippet;
4444
}
4545
}

src/Api/Snippets/Users/Comments.php renamed to src/Api/Snippets/Workspaces/Comments.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Bitbucket\Api\Snippets\Users;
14+
namespace Bitbucket\Api\Snippets\Workspaces;
1515

1616
/**
1717
* The comments api class.
1818
*
1919
* @author Graham Campbell <[email protected]>
2020
*/
21-
class Comments extends AbstractUsersApi
21+
class Comments extends AbstractWorkspacesApi
2222
{
2323
/**
2424
* @param array $params
@@ -104,6 +104,6 @@ public function remove(string $comment, array $params = [])
104104
*/
105105
protected function buildCommentsPath(string ...$parts)
106106
{
107-
return static::buildPath('snippets', $this->username, $this->snippet, 'comments', ...$parts);
107+
return static::buildPath('snippets', $this->workspace, $this->snippet, 'comments', ...$parts);
108108
}
109109
}

src/Api/Snippets/Users/Commits.php renamed to src/Api/Snippets/Workspaces/Commits.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Bitbucket\Api\Snippets\Users;
14+
namespace Bitbucket\Api\Snippets\Workspaces;
1515

1616
/**
1717
* The commits api class.
1818
*
1919
* @author Graham Campbell <[email protected]>
2020
*/
21-
class Commits extends AbstractUsersApi
21+
class Commits extends AbstractWorkspacesApi
2222
{
2323
/**
2424
* @param array $params
@@ -60,6 +60,6 @@ public function show(string $commit, array $params = [])
6060
*/
6161
protected function buildCommitsPath(string ...$parts)
6262
{
63-
return static::buildPath('snippets', $this->username, $this->snippet, 'commits', ...$parts);
63+
return static::buildPath('snippets', $this->workspace, $this->snippet, 'commits', ...$parts);
6464
}
6565
}

src/Api/Snippets/Users/Diffs.php renamed to src/Api/Snippets/Workspaces/Diffs.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Bitbucket\Api\Snippets\Users;
14+
namespace Bitbucket\Api\Snippets\Workspaces;
1515

1616
/**
1717
* The diffs api class.
1818
*
1919
* @author Graham Campbell <[email protected]>
2020
*/
21-
class Diffs extends AbstractUsersApi
21+
class Diffs extends AbstractWorkspacesApi
2222
{
2323
/**
2424
* @param string $commit
@@ -46,6 +46,6 @@ public function download(string $commit, array $params = [])
4646
*/
4747
protected function buildDiffsPath(string ...$parts)
4848
{
49-
return static::buildPath('snippets', $this->username, $this->snippet, ...$parts);
49+
return static::buildPath('snippets', $this->workspace, $this->snippet, ...$parts);
5050
}
5151
}

src/Api/Snippets/Users/Files.php renamed to src/Api/Snippets/Workspaces/Files.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Bitbucket\Api\Snippets\Users;
14+
namespace Bitbucket\Api\Snippets\Workspaces;
1515

1616
use Http\Message\MultipartStream\MultipartStreamBuilder;
1717

@@ -20,7 +20,7 @@
2020
*
2121
* @author Graham Campbell <[email protected]>
2222
*/
23-
class Files extends AbstractUsersApi
23+
class Files extends AbstractWorkspacesApi
2424
{
2525
/**
2626
* @param string $commit
@@ -117,6 +117,6 @@ public function remove(string $commit, array $params = [])
117117
*/
118118
protected function buildFilesPath(string ...$parts)
119119
{
120-
return static::buildPath('snippets', $this->username, $this->snippet, ...$parts);
120+
return static::buildPath('snippets', $this->workspace, $this->snippet, ...$parts);
121121
}
122122
}

src/Api/Snippets/Users/Patches.php renamed to src/Api/Snippets/Workspaces/Patches.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111
* file that was distributed with this source code.
1212
*/
1313

14-
namespace Bitbucket\Api\Snippets\Users;
14+
namespace Bitbucket\Api\Snippets\Workspaces;
1515

1616
/**
1717
* The patches api class.
1818
*
1919
* @author Graham Campbell <[email protected]>
2020
*/
21-
class Patches extends AbstractUsersApi
21+
class Patches extends AbstractWorkspacesApi
2222
{
2323
/**
2424
* @param string $commit
@@ -46,6 +46,6 @@ public function download(string $commit, array $params = [])
4646
*/
4747
protected function buildPatchesPath(string ...$parts)
4848
{
49-
return static::buildPath('snippets', $this->username, $this->snippet, ...$parts);
49+
return static::buildPath('snippets', $this->workspace, $this->snippet, ...$parts);
5050
}
5151
}

0 commit comments

Comments
 (0)