Skip to content

Commit

Permalink
feat: #81 Add the method for generating "get user book stats" API URL…
Browse files Browse the repository at this point in the history
… (copy-pasted from "CSV files" branch and moved into Kotlin).
  • Loading branch information
dmitry-weirdo committed Nov 26, 2024
1 parent 5ee1ce9 commit c84b2f5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kgCommon/src/main/kotlin/ru/klavogonki/common/UrlConstructor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,16 @@ object UrlConstructor {
return getLink("/api/profile/get-stats-details?userId=%d&gametype=%s", playerId, validCode)
}

/**
* Возвращает пройденные части заданной книги для заданного игрока.
* @param playerId идентификатор игрока
* @param bookVocabularyId идентификатор книжного словаря, числовая часть, без префикса `voc-`
* @return Информация для экрана «Прогресс» по книге.
*/
@JvmStatic
fun getUserBookProgress(playerId: Int, bookVocabularyId: Int) =
getLink("/api/profile/get-book-parts?userId=%d&vocId=%d", playerId, bookVocabularyId)

/**
* @param playerLogin логин игрока
* @return json вида `{"id":242585}` для корректного логина
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@ internal class UrlConstructorTest {
)
}

@Test
fun testGetUserBookProgress() {
val link = UrlConstructor.getUserBookProgress(NOSFERATUM_PROFILE_ID, BOOK_DICTIONARY_ID)

assertThat(link).isEqualTo("https://klavogonki.ru/api/profile/get-book-parts?userId=242585&vocId=30149")
}

companion object {
const val NOSFERATUM_PROFILE_ID = 242585

Expand All @@ -194,5 +201,7 @@ internal class UrlConstructorTest {
const val NON_STANDARD_DICTIONARY_ID = 5539 // todo: use constant from NonStandardDictionary
const val NON_STANDARD_DICTIONARY_ID_STRING = NON_STANDARD_DICTIONARY_ID.toString()
val NON_STANDARD_DICTIONARY_CODE = DictionaryUtils.getDictionaryCode(NON_STANDARD_DICTIONARY_ID)

const val BOOK_DICTIONARY_ID = 30149; // https://klavogonki.ru/vocs/30149
}
}

0 comments on commit c84b2f5

Please sign in to comment.