List followers of a user
abteilung6 opened this issue · 3 comments
abteilung6 commented
Users.scala
/**
* Lists the people following the specified user.
*
* @param username of the user to retrieve
* @param pagination Limit and Offset for pagination
* @param headers optional user headers to include in the request
* @return GHResponse[List[User]\] User details
*/
def getFollowers(
username: String,
pagination: Option[Pagination] = None,
headers: Map[String, String] = Map()
): F[GHResponse[List[User]]]
UsersInterpreter.scala
override def getFollowers(
username: String,
pagination: Option[Pagination],
headers: Map[String, String]
): F[GHResponse[List[User]]] =
client
.get[List[User]](s"users/$username/followers", headers, pagination = pagination)
UsersSpec.scala
"Users >> GetFollowers" should "return the expected followers list for a valid username" taggedAs Integration in {
val response = clientResource
.use { client =>
Github[IO](client, accessToken).users
.getFollowers(validUsername, None, headerUserAgent)
}
.unsafeRunSync()
testIsRight[List[User]](response, r => r.nonEmpty shouldBe true)
response.statusCode shouldBe okStatusCode
}
it should "return error on Left for invalid username" taggedAs Integration in {
val response = clientResource
.use { client =>
Github[IO](client, accessToken).users
.getFollowers(invalidUsername, None, headerUserAgent)
}
.unsafeRunSync()
testIsLeft[GHError.NotFoundError, List[User]](response)
response.statusCode shouldBe notFoundStatusCode
}
fedefernandez commented
@abteilung6, thanks for the suggestions. I can help you with the missing pieces if you want to create the PR. It would be nice to give you the proper credits for the contribution.
abteilung6 commented
@fedefernandez I think i didn't had the permission for an upstream branch in order to create a draft PR.
But I will retry it the next days!
fedefernandez commented
@abteilung6 yeah, I think the only way would be through a fork