This repository was archived by the owner on Apr 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +49
-3
lines changed Expand file tree Collapse file tree 6 files changed +49
-3
lines changed Original file line number Diff line number Diff line change 11package com.thoo.api
22
3+ import com.thoo.api.interceptors.DefaultInterceptor
34import com.thoo.api.match.MatchBuilder
45import com.thoo.api.model.*
56import com.thoo.api.service.FortniteAPIService
7+ import okhttp3.OkHttpClient
68import retrofit2.Retrofit
79import retrofit2.converter.gson.GsonConverterFactory
810import java.lang.reflect.Field
911import 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
Original file line number Diff line number Diff line change 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+ }
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 = " "
Original file line number Diff line number Diff 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 = " "
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import com.thoo.api.FortniteAPI
44import com.thoo.api.match.MatchBuilder
55
66fun 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" )
You can’t perform that action at this time.
0 commit comments