Skip to content

Commit c44e8d9

Browse files
Tweaked URI building
1 parent e1b1ff2 commit c44e8d9

7 files changed

+26
-37
lines changed

src/Api/AbstractApi.php

-11
Original file line numberDiff line numberDiff line change
@@ -211,17 +211,6 @@ protected function getProjectPath($id, string $uri)
211211
return 'projects/'.self::encodePath($id).'/'.$uri;
212212
}
213213

214-
/**
215-
* @param int $id
216-
* @param string $uri
217-
*
218-
* @return string
219-
*/
220-
protected function getGroupPath(int $id, string $uri)
221-
{
222-
return 'groups/'.self::encodePath($id).'/'.$uri;
223-
}
224-
225214
/**
226215
* Create a new OptionsResolver with page and per_page options.
227216
*

src/Api/Groups.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ public function variables(int $group_id, array $parameters = [])
343343
{
344344
$resolver = $this->createOptionsResolver();
345345

346-
return $this->get($this->getGroupPath($group_id, 'variables'), $resolver->resolve($parameters));
346+
return $this->get('groups/'.self::encodePath($group_id).'/variables', $resolver->resolve($parameters));
347347
}
348348

349349
/**
@@ -354,7 +354,7 @@ public function variables(int $group_id, array $parameters = [])
354354
*/
355355
public function variable(int $group_id, string $key)
356356
{
357-
return $this->get($this->getGroupPath($group_id, 'variables/'.self::encodePath($key)));
357+
return $this->get('groups/'.self::encodePath($group_id).'/variables/'.self::encodePath($key));
358358
}
359359

360360
/**
@@ -376,7 +376,7 @@ public function addVariable(int $group_id, string $key, string $value, ?bool $pr
376376
$payload['protected'] = $protected;
377377
}
378378

379-
return $this->post($this->getGroupPath($group_id, 'variables'), $payload);
379+
return $this->post('groups/'.self::encodePath($group_id).'/variables', $payload);
380380
}
381381

382382
/**
@@ -397,7 +397,7 @@ public function updateVariable(int $group_id, string $key, string $value, ?bool
397397
$payload['protected'] = $protected;
398398
}
399399

400-
return $this->put($this->getGroupPath($group_id, 'variables/'.self::encodePath($key)), $payload);
400+
return $this->put('groups/'.self::encodePath($group_id).'/variables/'.self::encodePath($key), $payload);
401401
}
402402

403403
/**
@@ -408,7 +408,7 @@ public function updateVariable(int $group_id, string $key, string $value, ?bool
408408
*/
409409
public function removeVariable(int $group_id, string $key)
410410
{
411-
return $this->delete($this->getGroupPath($group_id, 'variables/'.self::encodePath($key)));
411+
return $this->delete('groups/'.self::encodePath($group_id).'/variables/'.self::encodePath($key));
412412
}
413413

414414
/**

src/Api/GroupsBoards.php

+10-10
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function all(?int $group_id = null, array $parameters = [])
1616
{
1717
$resolver = $this->createOptionsResolver();
1818

19-
$path = null === $group_id ? 'boards' : $this->getGroupPath($group_id, 'boards');
19+
$path = null === $group_id ? 'boards' : 'groups/'.self::encodePath($group_id).'/boards';
2020

2121
return $this->get($path, $resolver->resolve($parameters));
2222
}
@@ -29,7 +29,7 @@ public function all(?int $group_id = null, array $parameters = [])
2929
*/
3030
public function show(int $group_id, int $board_id)
3131
{
32-
return $this->get($this->getGroupPath($group_id, 'boards/'.self::encodePath($board_id)));
32+
return $this->get('groups/'.self::encodePath($group_id).'/boards/'.self::encodePath($board_id));
3333
}
3434

3535
/**
@@ -40,7 +40,7 @@ public function show(int $group_id, int $board_id)
4040
*/
4141
public function create(int $group_id, array $params)
4242
{
43-
return $this->post($this->getGroupPath($group_id, 'boards'), $params);
43+
return $this->post('groups/'.self::encodePath($group_id).'/boards', $params);
4444
}
4545

4646
/**
@@ -52,7 +52,7 @@ public function create(int $group_id, array $params)
5252
*/
5353
public function update(int $group_id, int $board_id, array $params)
5454
{
55-
return $this->put($this->getGroupPath($group_id, 'boards/'.self::encodePath($board_id)), $params);
55+
return $this->put('groups/'.self::encodePath($group_id).'/boards/'.self::encodePath($board_id), $params);
5656
}
5757

5858
/**
@@ -63,7 +63,7 @@ public function update(int $group_id, int $board_id, array $params)
6363
*/
6464
public function remove(int $group_id, int $board_id)
6565
{
66-
return $this->delete($this->getGroupPath($group_id, 'boards/'.self::encodePath($board_id)));
66+
return $this->delete('groups/'.self::encodePath($group_id).'/boards/'.self::encodePath($board_id));
6767
}
6868

6969
/**
@@ -74,7 +74,7 @@ public function remove(int $group_id, int $board_id)
7474
*/
7575
public function allLists(int $group_id, int $board_id)
7676
{
77-
return $this->get($this->getGroupPath($group_id, 'boards/'.self::encodePath($board_id).'/lists'));
77+
return $this->get('groups/'.self::encodePath($group_id).'/boards/'.self::encodePath($board_id).'/lists');
7878
}
7979

8080
/**
@@ -86,7 +86,7 @@ public function allLists(int $group_id, int $board_id)
8686
*/
8787
public function showList(int $group_id, int $board_id, int $list_id)
8888
{
89-
return $this->get($this->getGroupPath($group_id, 'boards/'.self::encodePath($board_id).'/lists/'.self::encodePath($list_id)));
89+
return $this->get('groups/'.self::encodePath($group_id).'/boards/'.self::encodePath($board_id).'/lists/'.self::encodePath($list_id));
9090
}
9191

9292
/**
@@ -102,7 +102,7 @@ public function createList(int $group_id, int $board_id, int $label_id)
102102
'label_id' => $label_id,
103103
];
104104

105-
return $this->post($this->getGroupPath($group_id, 'boards/'.self::encodePath($board_id).'/lists'), $params);
105+
return $this->post('groups/'.self::encodePath($group_id).'/boards/'.self::encodePath($board_id).'/lists', $params);
106106
}
107107

108108
/**
@@ -119,7 +119,7 @@ public function updateList(int $group_id, int $board_id, int $list_id, int $posi
119119
'position' => $position,
120120
];
121121

122-
return $this->put($this->getGroupPath($group_id, 'boards/'.self::encodePath($board_id).'/lists/'.self::encodePath($list_id)), $params);
122+
return $this->put('groups/'.self::encodePath($group_id).'/boards/'.self::encodePath($board_id).'/lists/'.self::encodePath($list_id), $params);
123123
}
124124

125125
/**
@@ -131,6 +131,6 @@ public function updateList(int $group_id, int $board_id, int $list_id, int $posi
131131
*/
132132
public function deleteList(int $group_id, int $board_id, int $list_id)
133133
{
134-
return $this->delete($this->getGroupPath($group_id, 'boards/'.self::encodePath($board_id).'/lists/'.self::encodePath($list_id)));
134+
return $this->delete('groups/'.self::encodePath($group_id).'/boards/'.self::encodePath($board_id).'/lists/'.self::encodePath($list_id));
135135
}
136136
}

src/Api/GroupsMilestones.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function all(int $group_id, array $parameters = [])
4141
;
4242
$resolver->setDefined('search');
4343

44-
return $this->get($this->getGroupPath($group_id, 'milestones'), $resolver->resolve($parameters));
44+
return $this->get('groups/'.self::encodePath($group_id).'/milestones', $resolver->resolve($parameters));
4545
}
4646

4747
/**
@@ -52,7 +52,7 @@ public function all(int $group_id, array $parameters = [])
5252
*/
5353
public function show(int $group_id, int $milestone_id)
5454
{
55-
return $this->get($this->getGroupPath($group_id, 'milestones/'.self::encodePath($milestone_id)));
55+
return $this->get('groups/'.self::encodePath($group_id).'/milestones/'.self::encodePath($milestone_id));
5656
}
5757

5858
/**
@@ -63,7 +63,7 @@ public function show(int $group_id, int $milestone_id)
6363
*/
6464
public function create(int $group_id, array $params)
6565
{
66-
return $this->post($this->getGroupPath($group_id, 'milestones'), $params);
66+
return $this->post('groups/'.self::encodePath($group_id).'/milestones', $params);
6767
}
6868

6969
/**
@@ -75,7 +75,7 @@ public function create(int $group_id, array $params)
7575
*/
7676
public function update(int $group_id, int $milestone_id, array $params)
7777
{
78-
return $this->put($this->getGroupPath($group_id, 'milestones/'.self::encodePath($milestone_id)), $params);
78+
return $this->put('groups/'.self::encodePath($group_id).'/milestones/'.self::encodePath($milestone_id), $params);
7979
}
8080

8181
/**
@@ -86,7 +86,7 @@ public function update(int $group_id, int $milestone_id, array $params)
8686
*/
8787
public function remove(int $group_id, int $milestone_id)
8888
{
89-
return $this->delete($this->getGroupPath($group_id, 'milestones/'.self::encodePath($milestone_id)));
89+
return $this->delete('groups/'.self::encodePath($group_id).'/milestones/'.self::encodePath($milestone_id));
9090
}
9191

9292
/**
@@ -97,7 +97,7 @@ public function remove(int $group_id, int $milestone_id)
9797
*/
9898
public function issues(int $group_id, int $milestone_id)
9999
{
100-
return $this->get($this->getGroupPath($group_id, 'milestones/'.self::encodePath($milestone_id).'/issues'));
100+
return $this->get('groups/'.self::encodePath($group_id).'/milestones/'.self::encodePath($milestone_id).'/issues');
101101
}
102102

103103
/**
@@ -108,6 +108,6 @@ public function issues(int $group_id, int $milestone_id)
108108
*/
109109
public function mergeRequests(int $group_id, int $milestone_id)
110110
{
111-
return $this->get($this->getGroupPath($group_id, 'milestones/'.self::encodePath($milestone_id).'/merge_requests'));
111+
return $this->get('groups/'.self::encodePath($group_id).'/milestones/'.self::encodePath($milestone_id).'/merge_requests');
112112
}
113113
}

src/Api/IssueLinks.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function create($project_id, int $issue_iid, $target_project_id, int $tar
3434
$parameters['target_project_id'] = $target_project_id;
3535
$parameters['target_issue_iid'] = $target_issue_iid;
3636

37-
return $this->post($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid).'/links'), $parameters);
37+
return $this->post($this->getProjectPath($project_id, 'issues/'.self::encodePath($issue_iid).'/links'), $parameters);
3838
}
3939

4040
/**
@@ -50,6 +50,6 @@ public function create($project_id, int $issue_iid, $target_project_id, int $tar
5050
*/
5151
public function remove($project_id, int $issue_iid, $issue_link_id, array $parameters = [])
5252
{
53-
return $this->delete($this->getProjectPath($project_id, 'issues/'.$this->encodePath($issue_iid)).'/links/'.$this->encodePath($issue_link_id), $parameters);
53+
return $this->delete($this->getProjectPath($project_id, 'issues/'.self::encodePath($issue_iid)).'/links/'.self::encodePath($issue_link_id), $parameters);
5454
}
5555
}

src/Api/Issues.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function all($project_id = null, array $parameters = [])
5151
public function group(int $group_id, array $parameters = [])
5252
{
5353
return $this->get(
54-
$this->getGroupPath($group_id, 'issues'),
54+
'groups/'.self::encodePath($group_id).'/issues',
5555
$this->createOptionsResolver()->resolve($parameters)
5656
);
5757
}

src/Api/IssuesStatistics.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function project($project_id, array $parameters)
3838
*/
3939
public function group(int $group_id, array $parameters)
4040
{
41-
return $this->get($this->getGroupPath($group_id, 'issues_statistics'), $this->createOptionsResolver()->resolve($parameters));
41+
return $this->get('groups/'.self::encodePath($group_id).'/issues_statistics', $this->createOptionsResolver()->resolve($parameters));
4242
}
4343

4444
/**

0 commit comments

Comments
 (0)