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

Commit 843a187

Browse files
committed
Added displayRarity and setText to /cosmetics/br/search/all and cosmetics
Added refundable and giftable to shop entries Added optional API key
1 parent 231482d commit 843a187

File tree

6 files changed

+49
-3
lines changed

6 files changed

+49
-3
lines changed

com/thoo/api/FortniteAPI.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
11
package com.thoo.api
22

3+
import com.thoo.api.interceptors.DefaultInterceptor
34
import com.thoo.api.match.MatchBuilder
45
import com.thoo.api.model.*
56
import com.thoo.api.service.FortniteAPIService
7+
import okhttp3.OkHttpClient
68
import retrofit2.Retrofit
79
import retrofit2.converter.gson.GsonConverterFactory
810
import java.lang.reflect.Field
911
import java.util.*
1012

11-
class FortniteAPI {
13+
class FortniteAPI constructor(val key: String) {
14+
constructor(): this("null")
1215

1316
private var retrofit: Retrofit? = null
1417
private var service: FortniteAPIService? = null
18+
private var httpClient: OkHttpClient? = null
1519

1620
init {
17-
retrofit = Retrofit.Builder().baseUrl("https://fortnite-api.com").addConverterFactory(GsonConverterFactory.create()).build()
21+
httpClient = OkHttpClient.Builder()
22+
.addInterceptor(DefaultInterceptor(key)).build()
23+
24+
retrofit = Retrofit.Builder()
25+
.baseUrl("https://fortnite-api.com")
26+
.addConverterFactory(GsonConverterFactory.create())
27+
.client(httpClient)
28+
.build()
29+
1830
service = retrofit?.create(FortniteAPIService::class.java)
1931
}
2032

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.thoo.api.interceptors
2+
3+
import okhttp3.Interceptor
4+
import okhttp3.Response
5+
6+
class DefaultInterceptor(private val key: String) : Interceptor {
7+
8+
override fun intercept(chain: Interceptor.Chain?): Response? {
9+
val request = chain?.request()
10+
if(key == "null"){
11+
request?.newBuilder()?.build()
12+
} else {
13+
request?.newBuilder()?.addHeader("x-api-key", key)?.build()
14+
}
15+
return chain?.proceed(request)
16+
}
17+
18+
}

com/thoo/api/match/MatchBuilder.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,18 @@ class MatchBuilder {
2121
private var hasVariants: Boolean? = null
2222
private var hasGameplayTags: Boolean? = null
2323
private var gameplayTag: String? = null
24+
private var displayRarity: String? = null
25+
private var setText: String? = null
26+
27+
fun setDisplayRarity(displayRarity: String):MatchBuilder {
28+
this.displayRarity = displayRarity
29+
return this
30+
}
31+
32+
fun setText(setText: String):MatchBuilder {
33+
this.setText = setText
34+
return this
35+
}
2436

2537
fun setType(type: String):MatchBuilder {
2638
this.type = type

com/thoo/api/model/BRCosmeticData.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ class BRCosmeticData {
1212
val name: String = ""
1313
val shortDescription: String = ""
1414
val description: String = ""
15+
val displayRarity: String = ""
16+
val setText: String = ""
1517
val set: String = ""
1618
val series: String = ""
1719
val backendSeries: String = ""

com/thoo/api/model/BRShopEntry.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ class BRShopEntry {
55
val regularPrice: Int = 0
66
val finalPrice: Int = 0
77
val isBundle: Boolean = false
8+
val refundable: Boolean = false
9+
val giftable: Boolean = false
810
val panel: Int = 0
911
val sortPriority: Int = 0
1012
val banner:String = ""

example/Main.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import com.thoo.api.FortniteAPI
44
import com.thoo.api.match.MatchBuilder
55

66
fun main(args : Array<String>){
7-
val api: FortniteAPI = FortniteAPI()
7+
val api: FortniteAPI = FortniteAPI("")
88

99
// Returns an Array<BRCosmeticData> of cosmetics which is an outfit and has a rare rarity
1010
val matchBuilder = MatchBuilder().setRarity("rare").setType("outfit")

0 commit comments

Comments
 (0)