Skip to content

Commit

Permalink
Uniformize pagination, part 2
Browse files Browse the repository at this point in the history
  • Loading branch information
BenFradet committed Apr 14, 2020
1 parent 20384b1 commit 25e1c1c
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 20 deletions.
1 change: 0 additions & 1 deletion docs/docs/issue.md
Expand Up @@ -340,7 +340,6 @@ You can add existing labels to an issue with the following parameters:
- the repository coordinates (`owner` and `name` of the repository).
- `number`: The issue number.
- `labels`: The existing labels that require adding.
- `pagination`: Limit and Offset for pagination, optional.

To add existing labels to an issue:

Expand Down
3 changes: 0 additions & 3 deletions github4s/src/main/scala/github4s/algebras/Issues.scala
Expand Up @@ -255,7 +255,6 @@ trait Issues[F[_]] {
* @param repo name of the repo
* @param number Issue number
* @param labels the list of labels to add to the issue
* @param pagination Limit and Offset for pagination, optional.
* @param headers optional user headers to include in the request
* @return a GHResponse with the list of labels added to the Issue.
*/
Expand All @@ -264,7 +263,6 @@ trait Issues[F[_]] {
repo: String,
number: Int,
labels: List[String],
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[Label]]]

Expand All @@ -283,7 +281,6 @@ trait Issues[F[_]] {
repo: String,
number: Int,
label: String,
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[Label]]]

Expand Down
Expand Up @@ -33,7 +33,12 @@ class GitDataInterpreter[F[_]](implicit client: HttpClient[F], accessToken: Opti
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[NonEmptyList[Ref]]] =
client.get[NonEmptyList[Ref]](accessToken, s"repos/$owner/$repo/git/refs/$ref", headers)
client.get[NonEmptyList[Ref]](
accessToken,
s"repos/$owner/$repo/git/refs/$ref",
headers,
pagination = pagination
)

override def createReference(
owner: String,
Expand Down
Expand Up @@ -35,7 +35,8 @@ class IssuesInterpreter[F[_]](implicit client: HttpClient[F], accessToken: Optio
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[Issue]]] =
client.get[List[Issue]](accessToken, s"repos/$owner/$repo/issues", headers)
client
.get[List[Issue]](accessToken, s"repos/$owner/$repo/issues", headers, pagination = pagination)

override def getIssue(
owner: String,
Expand Down Expand Up @@ -101,7 +102,12 @@ class IssuesInterpreter[F[_]](implicit client: HttpClient[F], accessToken: Optio
headers: Map[String, String] = Map()
): F[GHResponse[List[Comment]]] =
client
.get[List[Comment]](accessToken, s"repos/$owner/$repo/issues/$number/comments", headers)
.get[List[Comment]](
accessToken,
s"repos/$owner/$repo/issues/$number/comments",
headers,
pagination = pagination
)

override def createComment(
owner: String,
Expand Down Expand Up @@ -160,14 +166,18 @@ class IssuesInterpreter[F[_]](implicit client: HttpClient[F], accessToken: Optio
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[Label]]] =
client.get[List[Label]](accessToken, s"repos/$owner/$repo/issues/$number/labels", headers)
client.get[List[Label]](
accessToken,
s"repos/$owner/$repo/issues/$number/labels",
headers,
pagination = pagination
)

override def addLabels(
owner: String,
repo: String,
number: Int,
labels: List[String],
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[Label]]] =
client.post[List[String], List[Label]](
Expand All @@ -182,7 +192,6 @@ class IssuesInterpreter[F[_]](implicit client: HttpClient[F], accessToken: Optio
repo: String,
number: Int,
label: String,
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[Label]]] =
client.deleteWithResponse[List[Label]](
Expand Down
Expand Up @@ -74,7 +74,8 @@ class RepositoriesInterpreter[F[_]](implicit client: HttpClient[F], accessToken:
accessToken,
s"repos/$owner/$repo/contents/$path",
headers,
ref.fold(Map.empty[String, String])(r => Map("ref" -> r))
ref.fold(Map.empty[String, String])(r => Map("ref" -> r)),
pagination
)

override def createFile(
Expand Down Expand Up @@ -174,7 +175,8 @@ class RepositoriesInterpreter[F[_]](implicit client: HttpClient[F], accessToken:
"protected" -> onlyProtected.map(_.toString)
).collect {
case (key, Some(value)) => key -> value
}
},
pagination
)

override def listContributors(
Expand All @@ -192,7 +194,8 @@ class RepositoriesInterpreter[F[_]](implicit client: HttpClient[F], accessToken:
"anon" -> anon
).collect {
case (key, Some(value)) => key -> value
}
},
pagination
)

override def listCollaborators(
Expand All @@ -210,7 +213,8 @@ class RepositoriesInterpreter[F[_]](implicit client: HttpClient[F], accessToken:
"affiliation" -> affiliation
).collect {
case (key, Some(value)) => key -> value
}
},
pagination
)

override def createRelease(
Expand Down Expand Up @@ -246,7 +250,12 @@ class RepositoriesInterpreter[F[_]](implicit client: HttpClient[F], accessToken:
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[Status]]] =
client.get[List[Status]](accessToken, s"repos/$owner/$repo/commits/$ref/statuses", headers)
client.get[List[Status]](
accessToken,
s"repos/$owner/$repo/commits/$ref/statuses",
headers,
pagination = pagination
)

override def createStatus(
owner: String,
Expand Down
Expand Up @@ -44,5 +44,6 @@ class UsersInterpreter[F[_]](implicit client: HttpClient[F], accessToken: Option
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[User]]] =
client.get[List[User]](accessToken, s"users/$username/following", headers)
client
.get[List[User]](accessToken, s"users/$username/following", headers, pagination = pagination)
}
2 changes: 0 additions & 2 deletions github4s/src/test/scala/github4s/integration/IssuesSpec.scala
Expand Up @@ -161,7 +161,6 @@ trait IssuesSpec extends BaseIntegrationSpec {
validRepoName,
validIssueNumber,
validIssueLabel.head,
None,
headerUserAgent
)
}
Expand All @@ -180,7 +179,6 @@ trait IssuesSpec extends BaseIntegrationSpec {
validRepoName,
validIssueNumber,
validIssueLabel,
None,
headerUserAgent
)
}
Expand Down
2 changes: 0 additions & 2 deletions github4s/src/test/scala/github4s/unit/IssuesSpec.scala
Expand Up @@ -252,7 +252,6 @@ class IssuesSpec extends BaseSpec {
validRepoName,
validIssueNumber,
validIssueLabel,
None,
headerUserAgent
)
}
Expand All @@ -273,7 +272,6 @@ class IssuesSpec extends BaseSpec {
validRepoName,
validIssueNumber,
validIssueLabel.head,
None,
headerUserAgent
)
}
Expand Down

0 comments on commit 25e1c1c

Please sign in to comment.