feat: add listBranchesByRepository method to BitbucketCloudClient

Signed-off-by: Benjamin Janssens <benji.janssens@gmail.com>
This commit is contained in:
Benjamin Janssens
2024-06-17 14:12:38 +02:00
parent 0fab9c0b3c
commit df955de815
2 changed files with 31 additions and 0 deletions
@@ -95,6 +95,26 @@ export class BitbucketCloudClient {
);
}
listBranchesByRepository(
repository: string,
workspace: string,
options?: FilterAndSortOptions & PartialResponseOptions,
): WithPagination<Models.PaginatedBranches, Models.Branch> {
const workspaceEnc = encodeURIComponent(workspace);
return new WithPagination(
paginationOptions =>
this.createUrl(
`/repositories/${workspaceEnc}/${repository}/refs/branches`,
{
...paginationOptions,
...options,
},
),
url => this.getTypeMapped(url),
);
}
private createUrl(endpoint: string, options?: RequestOptions): URL {
const request = new URL(this.config.apiBaseUrl + endpoint);
for (const key in options) {
@@ -275,6 +275,17 @@ export namespace Models {
values?: Set<Workspace>;
}
/**
* A paginated list of branches.
* @public
*/
export interface PaginatedBranches extends Paginated<Branch> {
/**
* The values of the current page.
*/
values?: Set<Branch>;
}
/**
* Object describing a user's role on resources like commits or pull requests.
* @public