Skip to content

Commit c419deb

Browse files
committed
Also do this for item repo.
1 parent 13490fb commit c419deb

3 files changed

Lines changed: 5 additions & 10 deletions

File tree

src/main/kotlin/com/wikia/tibia/v2/adapters/item/ItemRepositoryImpl.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package com.wikia.tibia.v2.adapters.item
22

33
import com.github.benmanes.caffeine.cache.AsyncLoadingCache
44
import com.github.benmanes.caffeine.cache.Caffeine
5+
import com.wikia.tibia.jackson.Parser
56
import com.wikia.tibia.objects.TibiaObject
67
import com.wikia.tibia.v2.adapters.tibiawiki.TibiaWikiApiClientFactory
78
import com.wikia.tibia.v2.domain.item.ItemRepository
@@ -70,7 +71,9 @@ class ItemRepositoryImpl : ItemRepository {
7071
logger.info("Getting all items")
7172
val response = client.getItems()
7273
if (response.isSuccessful) {
73-
response.body() ?: emptyList()
74+
response.body()
75+
?.mapNotNull { Parser.mapToType(type = TibiaObject::class.java, json = it) }
76+
?: emptyList()
7477
} else {
7578
logger.error("Could not get list of items for key $key because: ${response.errorBody() ?: response.message()}")
7679
emptyList()

src/main/kotlin/com/wikia/tibia/v2/adapters/tibiawiki/TibiaWikiApiClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface TibiaWikiApiClient {
2626
suspend fun updateCreature(@Header("X-WIKI-Edit-Summary") editSummary: String?, @Body newCreature: Creature): Response<Creature?>
2727

2828
@GET("/api/items")
29-
suspend fun getItems(@Query("expand") expand: Boolean? = true): Response<List<TibiaObject>>
29+
suspend fun getItems(@Query("expand") expand: Boolean? = true): Response<List<Any>>
3030

3131
@GET("/api/items")
3232
suspend fun getItemNames(@Query("expand") expand: Boolean? = false): Response<List<String>>

src/main/kotlin/com/wikia/tibia/v2/domain/CreaturesService.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -106,14 +106,6 @@ class CreaturesService(
106106
}
107107
}
108108

109-
// private suspend fun getSingleItem(itemName: String): TibiaObject? {
110-
// return itemRepository.getItem(itemName)
111-
// ?: run {
112-
// logger.error("Could not find item with name '$itemName' in collection of items.")
113-
// null
114-
// }
115-
// }
116-
117109
private suspend fun getItems(): List<TibiaObject> {
118110
return try {
119111
itemRepository.getItems()

0 commit comments

Comments
 (0)