Skip to content

Commit

Permalink
Add Projects::updateProtectedBranch method (#771)
Browse files Browse the repository at this point in the history
  • Loading branch information
endroid authored Oct 8, 2023
1 parent 41e2bae commit ca38dfb
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/Api/AbstractApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,33 @@ protected function put(string $uri, array $params = [], array $headers = [], arr
return ResponseMediator::getContent($response);
}

/**
* @param string $uri
* @param array<string,mixed> $params
* @param array<string,string> $headers
* @param array<string,string> $files
*
* @return mixed
*/
protected function patch(string $uri, array $params = [], array $headers = [], array $files = [])
{
if (0 < \count($files)) {
$builder = $this->createMultipartStreamBuilder($params, $files);
$body = self::prepareMultipartBody($builder);
$headers = self::addMultipartContentType($headers, $builder);
} else {
$body = self::prepareJsonBody($params);

if (null !== $body) {
$headers = self::addJsonContentType($headers);
}
}

$response = $this->client->getHttpClient()->patch(self::prepareUri($uri), $headers, $body ?? '');

return ResponseMediator::getContent($response);
}

/**
* @param string $uri
* @param string $file
Expand Down
12 changes: 12 additions & 0 deletions src/Api/Projects.php
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,18 @@ public function deleteProtectedBranch($project_id, string $branch_name)
return $this->delete($this->getProjectPath($project_id, 'protected_branches/'.self::encodePath($branch_name)));
}

/**
* @param int|string $project_id
* @param string $branch_name
* @param array $parameters
*
* @return mixed
*/
public function updateProtectedBranch($project_id, string $branch_name, array $parameters = [])
{
return $this->patch($this->getProjectPath($project_id, 'protected_branches/'.self::encodePath($branch_name)), $parameters);
}

/**
* @param int|string $project_id
*
Expand Down

0 comments on commit ca38dfb

Please sign in to comment.