Skip to content
This repository was archived by the owner on Apr 9, 2024. It is now read-only.

Commit 0b7da3f

Browse files
committed
Added matched cosmetics
1 parent fd925f7 commit 0b7da3f

File tree

3 files changed

+24
-13
lines changed

3 files changed

+24
-13
lines changed

com/thoo/api/FortniteAPI.kt

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
package com.thoo.api
22

3+
import com.thoo.api.match.MatchBuilder
34
import com.thoo.api.model.*
45
import com.thoo.api.service.FortniteAPIService
56
import retrofit2.Retrofit
67
import retrofit2.converter.gson.GsonConverterFactory
8+
import java.lang.reflect.Field
9+
import java.util.*
710

811
class FortniteAPI {
912

@@ -47,18 +50,22 @@ class FortniteAPI {
4750

4851
fun getNewsCreative(language: Language): SepNewsResponse? = service?.getNewsCreative(language.toString().toLowerCase())?.execute()?.body();
4952

50-
/*fun getMatched(matchBuilder: MatchBuilder):BRCosmeticsResponse? {
51-
val fields: Array<Field> = matchBuilder::javaClass.get().declaredFields
52-
val queryMap: HashMap<String, Any> = HashMap()
53+
fun getMatchedCosmetics(matchBuilder: MatchBuilder):BRCosmeticsResponse? {
54+
val fields: Array<Field> = matchBuilder.javaClass.declaredFields
55+
val queryMapString: HashMap<String, String> = HashMap()
56+
val queryMapBool: HashMap<String, Boolean> = HashMap()
5357
fields.forEach {
54-
if(it.isAccessible){
55-
val value: Any? = it.get(matchBuilder)
56-
if(value != null){
57-
queryMap[it.name] = value
58+
it.isAccessible = true
59+
val value: Any? = it.get(matchBuilder)
60+
if (value != null) {
61+
if (value is String) {
62+
queryMapString[it.name] = value
63+
} else if (value is Boolean) {
64+
queryMapBool[it.name] = value
5865
}
5966
}
6067
}
61-
return service?.matchCosmetics(queryMap)?.execute()?.body()
62-
}*/
68+
return service?.matchCosmetics(queryMapString, queryMapBool)?.execute()?.body()
69+
}
6370

6471
}

com/thoo/api/service/FortniteAPIService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ interface FortniteAPIService {
6161
fun getNewsCreative(@Query("language") language: String): Call<SepNewsResponse>;
6262

6363
@GET("/cosmetics/br/search/all")
64-
fun matchCosmetics(@QueryMap map: Map<String, Any>): Call<BRCosmeticsResponse>
64+
fun matchCosmetics(@QueryMap map: Map<String, String>, @QueryMap map2: Map<String, Boolean>): Call<BRCosmeticsResponse>
6565

6666
@GET("/cosmetics/br/search/all")
67-
fun matchCosmetics(@QueryMap map: Map<String, Any>, @Query("language") language: String): Call<BRCosmeticsResponse>
67+
fun matchCosmetics(@QueryMap map: Map<String, String>, @QueryMap map2: Map<String, Boolean>, @Query("language") language: String): Call<BRCosmeticsResponse>
6868
}

example/Main.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
package example
22

33
import com.thoo.api.FortniteAPI
4+
import com.thoo.api.match.MatchBuilder
45

56
fun main(args : Array<String>){
67
val api: FortniteAPI = FortniteAPI()
78

8-
api.getAllCosmetics()?.data?.forEach {
9-
println(it.name)
9+
// Returns an Array<BRCosmeticData> of cosmetics which is an outfit and has a rare rarity
10+
val matchBuilder = MatchBuilder().setRarity("rare").setType("outfit")
11+
api.getMatchedCosmetics(matchBuilder)?.data?.forEach {
12+
println(it.id)
1013
}
14+
1115
}

0 commit comments

Comments
 (0)