스팀 앱 - 개발 중: 팔로우 개수 구하는 API 연동
스팀 앱 - 개발 중: 팔로우 개수 구하는 API 연동
2023. 12. 05 (화) | Written by @dorian-mobileapp
시작하며....
프로필 화면 개발에 앞서 필요한 것은 condenser_api.get_follow_count API 연동입니다. 관련 클래스와 코드를 이번에 작성했습니다.
작업 내용
- 데이터 클래스 정의
- condenser_api.get_follow_count API 연동
- 테스트 코드 작성
데이터 클래스 정의
- GetFollowCountParamsDTO: condenser_api.get_follow_count API의 파라메터
data class GetFollowCountParamsDTO(
val jsonrpc: String = "2.0",
val method: String = "condenser_api.get_follow_count",
val params: Array<String>,
val id: Int
)
- GetFollowCountResponseDTO: condenser_api.get_follow_count API의 응답 데이터
data class GetFollowCountResponseDTO(
val jsonrpc: String?,
val result: Result,
val id: Int?
) {
data class Result(
val account: String?,
val following_count: Int,
val follower_count: Int
)
fun toFollowCount(): FollowCount = FollowCount(
result.account ?: "",
result.following_count ?: 0,
result.follower_count ?: 0
)
}
- FollowCount: 앱의 view 계층에서 사용할 팔로우 개수
data class FollowCount(
val account: String,
val followingCount: Int,
val followerCount: Int
)
condenser_api.get_follow_count API 연동
condenser_api.get_follow_count API를 실행할 메소드를 SteemService 인터페이스에 추가하였습니다.
suspend fun getFollowCount(
@Body followingParams: GetFollowCountParamsDTO
): Response<GetFollowCountResponseDTO>
테스트 코드 작성
API 연동이 잘 되는지 테스트했습니다. 문제는 없는 것으로 확인했습니다.
fun getFollowCount() = runTest {
val params = GetFollowCountParamsDTO(
params = arrayOf("dorian-lee"),
id = 1
)
val response = SteemClient.apiService.getFollowCount(params)
assertTrue(response.isSuccessful)
response.body()?.result?.let { result ->
assertTrue(result.account == "dorian-lee")
assertTrue(result.following_count > 0)
assertTrue(result.follower_count > 0)
}
}
GitHub Commit
마치며...
앞으로 스팀 앱 개발기는 단위 기능 개발 또는 수정 내용을 정리하는 것으로 방향을 정했습니다. 중간 내용은 오늘처럼 번호를 붙이지 않고 포스트로 작성할 것입니다. 그리고 그렇게 작성한 포스트들의 링크들을 스팀 앱 개발기에 모아 두고자 합니다.
Layout provided by Steemit Enhancer hommage by ayogom
Posted through the ECblog app (https://blog.etain.club)
안녕하세요.
SteemitKorea팀에서 제공하는 'steemit-enhancer'를 사용해 주셔서 감사합니다. 개선 사항이 있으면 언제나 저에게 연락을 주시면 되고, 관심이 있으신 분들은 https://cafe.naver.com/steemitkorea/425 에서 받아보실 수 있습니다. 사용시 @응원해 가 포함이 되며, 악용시에는 모든 서비스에서 제외될 수 있음을 알려드립니다.
[광고] STEEM 개발자 커뮤니티에 참여 하시면, 다양한 혜택을 받을 수 있습니다.
안녕하세요.
이 글은 SteemitKorea팀(@ayogom)님께서 저자이신 @dorian-mobileapp님을 응원하는 글입니다.
소정의 보팅을 해드렸습니다 ^^ 항상 좋은글 부탁드립니다
SteemitKorea팀에서는 보다 즐거운 steemit 생활을 위해 노력하고 있습니다.
이 글은 다음날 다시 한번 포스팅을 통해 소개 될 예정입니다. 감사합니다!
Thank you, friend!


I'm @steem.history, who is steem witness.
Thank you for witnessvoting for me.
please click it!
(Go to https://steemit.com/~witnesses and type fbslo at the bottom of the page)
The weight is reduced because of the lack of Voting Power. If you vote for me as a witness, you can get my little vote.
Upvoted! Thank you for supporting witness @jswit.