Skip to content

Commit ca38dfb

Browse files
authored
Add Projects::updateProtectedBranch method (#771)
1 parent 41e2bae commit ca38dfb

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

src/Api/AbstractApi.php

+27
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,33 @@ protected function put(string $uri, array $params = [], array $headers = [], arr
163163
return ResponseMediator::getContent($response);
164164
}
165165

166+
/**
167+
* @param string $uri
168+
* @param array<string,mixed> $params
169+
* @param array<string,string> $headers
170+
* @param array<string,string> $files
171+
*
172+
* @return mixed
173+
*/
174+
protected function patch(string $uri, array $params = [], array $headers = [], array $files = [])
175+
{
176+
if (0 < \count($files)) {
177+
$builder = $this->createMultipartStreamBuilder($params, $files);
178+
$body = self::prepareMultipartBody($builder);
179+
$headers = self::addMultipartContentType($headers, $builder);
180+
} else {
181+
$body = self::prepareJsonBody($params);
182+
183+
if (null !== $body) {
184+
$headers = self::addJsonContentType($headers);
185+
}
186+
}
187+
188+
$response = $this->client->getHttpClient()->patch(self::prepareUri($uri), $headers, $body ?? '');
189+
190+
return ResponseMediator::getContent($response);
191+
}
192+
166193
/**
167194
* @param string $uri
168195
* @param string $file

src/Api/Projects.php

+12
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,18 @@ public function deleteProtectedBranch($project_id, string $branch_name)
15461546
return $this->delete($this->getProjectPath($project_id, 'protected_branches/'.self::encodePath($branch_name)));
15471547
}
15481548

1549+
/**
1550+
* @param int|string $project_id
1551+
* @param string $branch_name
1552+
* @param array $parameters
1553+
*
1554+
* @return mixed
1555+
*/
1556+
public function updateProtectedBranch($project_id, string $branch_name, array $parameters = [])
1557+
{
1558+
return $this->patch($this->getProjectPath($project_id, 'protected_branches/'.self::encodePath($branch_name)), $parameters);
1559+
}
1560+
15491561
/**
15501562
* @param int|string $project_id
15511563
*

0 commit comments

Comments
 (0)