Skip to content

Commit 0e23e14

Browse files
committed
[PT-1049] - Fetch project repositories
1 parent fc38a67 commit 0e23e14

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

src/main/scala/com/codacy/client/bitbucket/v2/service/RepositoryServices.scala

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,4 +118,22 @@ class RepositoryServices(client: BitbucketClient) {
118118
val encodedRepo = URLEncoder.encode(repo, "UTF-8")
119119
s"${client.repositoriesBaseUrl}/$encodedOwner/$encodedRepo"
120120
}
121+
122+
def getProjectRepositories(workspaceId: String,
123+
projectKey : String,
124+
pageRequest: Option[PageRequest],
125+
pageLength: Option[Int]) : RequestResponse[Seq[Repository]] = {
126+
val encodedProjectKey = URLEncoder.encode(projectKey, "UTF-8")
127+
128+
val url = s"${client.repositoriesBaseUrl}/$workspaceId?q=project.key=%22$encodedProjectKey%22"
129+
pageRequest match {
130+
case Some(request) =>
131+
client.executeWithCursor[Repository](url, request, pageLength)
132+
case None =>
133+
val length = pageLength.fold("")(pagelen => s"pagelen=$pagelen")
134+
val urlWithPageLength = joinQueryParameters(url, length)
135+
client.executePaginated[Repository](urlWithPageLength)
136+
}
137+
}
138+
121139
}

0 commit comments

Comments
 (0)