File tree Expand file tree Collapse file tree
src/main/kotlin/com/wikia/tibia/v2 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package com.wikia.tibia.v2.adapters.item
22
33import com.github.benmanes.caffeine.cache.AsyncLoadingCache
44import com.github.benmanes.caffeine.cache.Caffeine
5+ import com.wikia.tibia.jackson.Parser
56import com.wikia.tibia.objects.TibiaObject
67import com.wikia.tibia.v2.adapters.tibiawiki.TibiaWikiApiClientFactory
78import 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()
Original file line number Diff line number Diff 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 >>
Original file line number Diff line number Diff 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()
You can’t perform that action at this time.
0 commit comments