├── .gitignore ├── LISENCE.md ├── README.md ├── build.gradle.kts ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── settings.gradle.kts └── src ├── main └── kotlin │ └── com │ └── thoo │ └── api │ ├── FortniteAPI.kt │ ├── endpoints │ ├── AESEndpoints.kt │ ├── BannerEndpoints.kt │ ├── CosmeticEndpoints.kt │ ├── CreatorEndpoints.kt │ ├── EndpointBase.kt │ ├── MapEndpoints.kt │ └── PlaylistEndpoints.kt │ ├── enums │ ├── KeyFormat.kt │ ├── Language.kt │ └── MatchMethod.kt │ ├── exceptions │ └── FortniteApiException.kt │ ├── models │ ├── AesModels.kt │ ├── BannerModels.kt │ ├── BaseModel.kt │ ├── CosmeticModels.kt │ ├── CosmeticSearchProperties.kt │ ├── CreatorModels.kt │ ├── ExceptionModel.kt │ ├── MapModels.kt │ └── PlaylistModels.kt │ ├── services │ ├── AESService.kt │ ├── BannerService.kt │ ├── CosmeticService.kt │ ├── CreatorService.kt │ ├── EndpointService.kt │ ├── MapService.kt │ └── PlaylistService.kt │ └── utils │ └── Utils.kt └── test ├── java └── TestJava.java └── kotlin └── TestKotlin.kt /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | /build/ 3 | /.gradle/ 4 | /src/test/ 5 | -------------------------------------------------------------------------------- /LISENCE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Fortnite-API.com 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Soon, recoding -------------------------------------------------------------------------------- /build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") version "1.4.10" 3 | id("com.github.johnrengelman.shadow") version "6.1.0" 4 | } 5 | 6 | group = "com.thoo.api" 7 | version = "1.0" 8 | 9 | repositories { 10 | mavenCentral() 11 | } 12 | 13 | dependencies { 14 | implementation(kotlin("stdlib")) 15 | implementation("com.squareup.retrofit2:retrofit:2.9.0") 16 | implementation("com.squareup.retrofit2:converter-gson:2.9.0") 17 | } -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Fortnite-API/java-wrapper/509fa9ad476d0f50d411ec5ae5df1cabd8387a58/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "FortniteAPI.com" 2 | -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/FortniteAPI.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api 2 | 3 | import com.thoo.api.endpoints.* 4 | import com.thoo.api.enums.Language 5 | import com.thoo.api.services.* 6 | import okhttp3.OkHttpClient 7 | import org.jetbrains.annotations.NotNull 8 | import retrofit2.Retrofit 9 | import retrofit2.converter.gson.GsonConverterFactory 10 | 11 | @Suppress("unused") 12 | class FortniteAPI private constructor( 13 | private val apiKey: String?, 14 | language: Language, 15 | httpClient: OkHttpClient 16 | ) { 17 | 18 | private val retrofit = Retrofit.Builder() 19 | .baseUrl("https://fortnite-api.com/") 20 | .client(httpClient) 21 | .addConverterFactory(GsonConverterFactory.create()).build() 22 | 23 | @JvmField val aes = AESEndpoints(retrofit, AESService::class.java) 24 | @JvmField val map = MapEndpoints(retrofit, MapService::class.java, language) 25 | @JvmField val playlist = PlaylistEndpoints(retrofit, PlaylistService::class.java, language) 26 | @JvmField val banner = BannerEndpoints(retrofit, BannerService::class.java, language) 27 | @JvmField val creator = CreatorEndpoints(retrofit, CreatorService::class.java) 28 | @JvmField val cosmetic = CosmeticEndpoints(retrofit, CosmeticService::class.java, language, httpClient) 29 | 30 | companion object { 31 | 32 | @JvmOverloads 33 | @JvmStatic 34 | fun create( 35 | apiKey: String? = null, 36 | @NotNull language: Language = Language.EN, 37 | httpClient: OkHttpClient? = null 38 | ): FortniteAPI = FortniteAPI(apiKey, language, 39 | httpClient ?: OkHttpClient.Builder().addInterceptor interceptor@ { 40 | if(apiKey == null) return@interceptor it.proceed(it.request()) 41 | val request = it.request() 42 | val requestBuilder = request.newBuilder() 43 | requestBuilder.header("x-api-key", apiKey) 44 | return@interceptor it.proceed(requestBuilder.build()) 45 | }.build()) 46 | 47 | } 48 | 49 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/endpoints/AESEndpoints.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.endpoints 2 | 3 | import com.thoo.api.enums.KeyFormat 4 | import com.thoo.api.exceptions.FortniteApiException 5 | import com.thoo.api.models.AesModel 6 | import com.thoo.api.models.BaseModel 7 | import com.thoo.api.services.AESService 8 | import com.thoo.api.utils.send 9 | import retrofit2.Retrofit 10 | import kotlin.jvm.Throws 11 | 12 | @SuppressWarnings("unused") 13 | class AESEndpoints( 14 | retrofit: Retrofit, 15 | clazz: Class 16 | ): EndpointBase(retrofit, clazz) { 17 | 18 | @Throws(FortniteApiException::class) 19 | @JvmOverloads fun getAes(keyFormat: KeyFormat = KeyFormat.HEX): BaseModel = 20 | service.getAes(keyFormat.code).send() 21 | 22 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/endpoints/BannerEndpoints.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.endpoints 2 | 3 | import com.thoo.api.enums.Language 4 | import com.thoo.api.exceptions.FortniteApiException 5 | import com.thoo.api.services.BannerService 6 | import com.thoo.api.utils.send 7 | import retrofit2.Retrofit 8 | import kotlin.jvm.Throws 9 | 10 | @SuppressWarnings("unused") 11 | class BannerEndpoints( 12 | retrofit: Retrofit, 13 | clazz: Class, 14 | private val language: Language 15 | ): EndpointBase(retrofit, clazz) { 16 | 17 | @Throws(FortniteApiException::class) 18 | @JvmOverloads fun getBanners(language: Language = this.language) = 19 | service.getBanners(language.code).send() 20 | 21 | @Throws(FortniteApiException::class) 22 | fun getBannerColors() = service.getBannerColors().send() 23 | 24 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/endpoints/CosmeticEndpoints.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.endpoints 2 | 3 | import com.google.gson.Gson 4 | import com.thoo.api.FortniteAPI 5 | import com.thoo.api.enums.Language 6 | import com.thoo.api.exceptions.FortniteApiException 7 | import com.thoo.api.models.BaseModel 8 | import com.thoo.api.models.Cosmetic 9 | import com.thoo.api.models.CosmeticSearchProperties 10 | import com.thoo.api.services.CosmeticService 11 | import com.thoo.api.utils.gson 12 | import com.thoo.api.utils.send 13 | import com.thoo.api.utils.sendOkHttp 14 | import okhttp3.HttpUrl 15 | import okhttp3.OkHttpClient 16 | import okhttp3.Request 17 | import retrofit2.Retrofit 18 | import kotlin.jvm.Throws 19 | 20 | @SuppressWarnings("unused") 21 | class CosmeticEndpoints( 22 | retrofit: Retrofit, 23 | clazz: Class, 24 | private val language: Language, 25 | private val httpClient: OkHttpClient 26 | ): EndpointBase(retrofit, clazz) { 27 | 28 | @Throws(FortniteApiException::class) 29 | @JvmOverloads fun getCosmetics(language: Language = this.language) = 30 | service.getCosmetics(language.code).send() 31 | 32 | @Throws(FortniteApiException::class) 33 | @JvmOverloads fun getNewCosmetics(language: Language = this.language) = 34 | service.getNewCosmetics(language.code).send() 35 | 36 | @Throws(FortniteApiException::class) 37 | @JvmOverloads 38 | fun searchCosmetic(language: Language = this.language, propertiesReceiver: CosmeticSearchProperties.() -> Unit): BaseModel { 39 | val properties = CosmeticSearchProperties() 40 | propertiesReceiver.invoke(properties) 41 | val clazz = properties.javaClass 42 | val queries = hashMapOf() 43 | clazz.declaredFields.forEach { 44 | it.isAccessible = true 45 | val value = it.get(properties) ?: return@forEach 46 | queries[it.name] = value 47 | } 48 | val urlBuilder = HttpUrl.Builder() 49 | .scheme("https") 50 | .host("fortnite-api.com") 51 | .addPathSegments("v2/cosmetics/br/search") 52 | .addEncodedQueryParameter("language", language.code) 53 | queries.forEach { (k, v) -> 54 | urlBuilder.addEncodedQueryParameter(k, v.toString()) 55 | } 56 | val request = Request.Builder() 57 | .url(urlBuilder.build()) 58 | .build() 59 | return request.sendOkHttp(httpClient) 60 | } 61 | 62 | @Throws(FortniteApiException::class) 63 | @JvmOverloads 64 | fun searchCosmetics(language: Language = this.language, propertiesReceiver: CosmeticSearchProperties.() -> Unit): BaseModel> { 65 | val properties = CosmeticSearchProperties() 66 | propertiesReceiver.invoke(properties) 67 | val clazz = properties.javaClass 68 | val queries = hashMapOf() 69 | clazz.declaredFields.forEach { 70 | it.isAccessible = true 71 | val value = it.get(properties) ?: return@forEach 72 | queries[it.name] = value 73 | } 74 | val urlBuilder = HttpUrl.Builder() 75 | .scheme("https") 76 | .host("fortnite-api.com") 77 | .addPathSegments("v2/cosmetics/br/search/all") 78 | .addEncodedQueryParameter("language", language.code) 79 | queries.forEach { (k, v) -> 80 | urlBuilder.addEncodedQueryParameter(k, v.toString()) 81 | } 82 | val request = Request.Builder() 83 | .url(urlBuilder.build()) 84 | .build() 85 | return request.sendOkHttp(httpClient) 86 | } 87 | 88 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/endpoints/CreatorEndpoints.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.endpoints 2 | 3 | import com.thoo.api.exceptions.FortniteApiException 4 | import com.thoo.api.services.CreatorService 5 | import com.thoo.api.utils.send 6 | import retrofit2.Retrofit 7 | import kotlin.jvm.Throws 8 | 9 | @SuppressWarnings("unused") 10 | class CreatorEndpoints( 11 | retrofit: Retrofit, 12 | clazz: Class 13 | ): EndpointBase(retrofit, clazz) { 14 | 15 | 16 | @Throws(FortniteApiException::class) fun getCreator(name: String) = service.getCreator(name).send() 17 | @Throws(FortniteApiException::class) fun searchCreator(name: String) = service.searchCreator(name).send() 18 | @Throws(FortniteApiException::class) fun searchCreators(name: String) = service.searchCreators(name).send() 19 | 20 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/endpoints/EndpointBase.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.endpoints 2 | 3 | import retrofit2.Retrofit 4 | 5 | open class EndpointBase( 6 | retrofit: Retrofit, 7 | clazz: Class, 8 | ) { 9 | 10 | val service: T = retrofit.create(clazz) 11 | 12 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/endpoints/MapEndpoints.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.endpoints 2 | 3 | import com.thoo.api.enums.Language 4 | import com.thoo.api.exceptions.FortniteApiException 5 | import com.thoo.api.services.MapService 6 | import com.thoo.api.utils.download 7 | import com.thoo.api.utils.send 8 | import okhttp3.OkHttpClient 9 | import org.jetbrains.annotations.NotNull 10 | import retrofit2.Retrofit 11 | import java.io.BufferedInputStream 12 | import java.io.File 13 | import kotlin.jvm.Throws 14 | 15 | @SuppressWarnings("unused") 16 | class MapEndpoints( 17 | retrofit: Retrofit, 18 | clazz: Class, 19 | private val language: Language 20 | ): EndpointBase(retrofit, clazz) { 21 | 22 | private val okhttp = OkHttpClient() 23 | 24 | @Throws(FortniteApiException::class) 25 | @JvmOverloads fun getMap(language: Language = this.language) = 26 | service.getMap(language.code).send() 27 | 28 | fun downloadMap(@NotNull file: File) { 29 | if(file.exists()) throw FileAlreadyExistsException(file) 30 | val body = service.downloadMap().execute().body()!! 31 | download(BufferedInputStream(body.byteStream()), file) 32 | } 33 | 34 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/endpoints/PlaylistEndpoints.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.endpoints 2 | 3 | import com.thoo.api.enums.Language 4 | import com.thoo.api.exceptions.FortniteApiException 5 | import com.thoo.api.services.PlaylistService 6 | import com.thoo.api.utils.send 7 | import retrofit2.Retrofit 8 | import kotlin.jvm.Throws 9 | 10 | @SuppressWarnings("unused") 11 | class PlaylistEndpoints( 12 | retrofit: Retrofit, 13 | clazz: Class, 14 | private val language: Language 15 | ): EndpointBase(retrofit, clazz) { 16 | 17 | @Throws(FortniteApiException::class) 18 | @JvmOverloads fun getPlaylists(language: Language = this.language) = 19 | service.getPlaylists(language.code).send() 20 | 21 | @Throws(FortniteApiException::class) 22 | @JvmOverloads fun getPlaylistById(id: String, language: Language = this.language) = 23 | service.getPlaylistById(id, language.code).send() 24 | 25 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/enums/KeyFormat.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.enums 2 | 3 | enum class KeyFormat(val code: String) { 4 | 5 | HEX("hex"), 6 | BASE64("base64") 7 | 8 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/enums/Language.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.enums 2 | 3 | @Suppress("unused") 4 | enum class Language( 5 | val code: String 6 | ) { 7 | 8 | AR("ar"), 9 | DE("de"), 10 | EN("en"), 11 | ES("es"), 12 | `ES-419`("es-419"), 13 | FR("fr"), 14 | IT("it"), 15 | JA("ja"), 16 | KO("ko"), 17 | PL("pl"), 18 | `PT-BR`("pt-BR"), 19 | RU("ru"), 20 | TR("tr"), 21 | `ZH-CN`("zh-CN"), 22 | `ZH-HANT`("zh-Hant"); 23 | 24 | companion object { 25 | 26 | @JvmStatic fun getES419() = getLanguageByName("ES-419") 27 | @JvmStatic fun getPTBR() = getLanguageByName("PT-BR") 28 | @JvmStatic fun getCN() = getLanguageByName("ZH-CN") 29 | @JvmStatic fun getZHHANT() = getLanguageByName("ZH-HANT") 30 | 31 | @JvmStatic 32 | fun getLanguageByName(name: String): Language { 33 | return valueOf(name.toUpperCase()) 34 | } 35 | 36 | } 37 | 38 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/enums/MatchMethod.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.enums 2 | 3 | enum class MatchMethod(val code: String) { 4 | 5 | FULL("full"), 6 | CONTAINS("contains"), 7 | STARTS("starts"), 8 | ENDS("ends") 9 | 10 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/exceptions/FortniteApiException.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.exceptions 2 | 3 | class FortniteApiException( 4 | status: Int, 5 | error: String 6 | ): Exception("$error (${status})") -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/AesModels.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | import com.google.gson.annotations.SerializedName 4 | 5 | class AesModel( 6 | val build: String, 7 | val mainKey: String, 8 | val dynamicKeys: List 9 | ) 10 | 11 | class DynamicKey( 12 | @SerializedName("pakFilename") 13 | val pakFileName: String, 14 | val pakGuid: String, 15 | val key: String 16 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/BannerModels.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | class Banner( 4 | val id: String, 5 | val devName: String, 6 | val name: String, 7 | val description: String, 8 | val category: String, 9 | val fullUsageRights: Boolean, 10 | val images: BannerImages 11 | ) 12 | 13 | class BannerImages( 14 | val smallIcon: String, 15 | val icon: String 16 | ) 17 | 18 | class BannerColor( 19 | val id: String, 20 | val color: String, 21 | val category: String, 22 | val subCategoryGroup: Int 23 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/BaseModel.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | class BaseModel( 4 | val status: Int, 5 | val data: T 6 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/CosmeticModels.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | import java.util.* 4 | import kotlin.collections.HashMap 5 | 6 | class Cosmetic( 7 | val id: String, 8 | val name: String, 9 | val description: String, 10 | val type: BaseValues, 11 | val rarity: BaseValues, 12 | val series: CosmeticSeries, 13 | val set: CosmeticSet, 14 | val introduction: CosmeticIntroduction, 15 | val images: CosmeticImages, 16 | val variants: List, 17 | val gameplayTags: List, 18 | val showcaseVideo: String, 19 | val displayAssetPath: String, 20 | val definitionPath: String, 21 | val path: String, 22 | val added: Date, 23 | val shopHistory: List 24 | ) 25 | 26 | class CosmeticVariant( 27 | val channel: String, 28 | val type: String, 29 | val options: List 30 | ) 31 | 32 | class CosmeticVariantOption( 33 | val tag: String, 34 | val name: String, 35 | val unlockRequirements: String, 36 | val image: String 37 | ) 38 | 39 | class CosmeticImages( 40 | val smallIcon: String, 41 | val icon: String, 42 | val featured: String, 43 | val other: HashMap 44 | ) 45 | 46 | class CosmeticIntroduction( 47 | val chapter: String, 48 | val season: String, 49 | val text: String, 50 | val backendValue: String 51 | ) 52 | 53 | class CosmeticSet( 54 | val value: String, 55 | val text: String, 56 | val backendValue: String 57 | ) 58 | 59 | class CosmeticSeries( 60 | val value: String, 61 | val image: String, 62 | val backendValue: String 63 | ) 64 | 65 | class BaseValues( 66 | val value: String, 67 | val displayValue: String, 68 | val backendValue: String 69 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/CosmeticSearchProperties.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | @Suppress("unused") 4 | class CosmeticSearchProperties { 5 | 6 | @JvmField var id: String? = null 7 | @JvmField var name: String? = null 8 | @JvmField var description: String? = null 9 | @JvmField var type: String? = null 10 | @JvmField var displayType: String? = null 11 | @JvmField var backendType: String? = null 12 | @JvmField var hasSeries: Boolean? = null 13 | @JvmField var series: String? = null 14 | @JvmField var backendSeries: String? = null 15 | @JvmField var hasSet: Boolean? = null 16 | @JvmField var set: String? = null 17 | @JvmField var setText: String? = null 18 | @JvmField var backendSet: String? = null 19 | @JvmField var hasIntroduction: Boolean? = null 20 | @JvmField var introductionSeason: String? = null 21 | @JvmField var introductionChapter: String? = null 22 | @JvmField var hasFeaturedImage: Boolean? = null 23 | @JvmField var hasVariants: Boolean? = null 24 | @JvmField var hasGameplayTags: Boolean? = null 25 | @JvmField var gameplayTag: String? = null 26 | @JvmField var added: Long? = null 27 | @JvmField var addedSince: Long? = null 28 | @JvmField var unseenFor: Int? = null 29 | @JvmField var lastAppearance: Long? = null 30 | 31 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/CreatorModels.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | class Creator( 4 | val code: String, 5 | val account: CreatorAccount, 6 | val status: String, 7 | val verified: Boolean 8 | ) 9 | 10 | class CreatorAccount( 11 | val id: String, 12 | val name: String 13 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/ExceptionModel.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | class ExceptionModel( 4 | val status: Int, 5 | val error: String 6 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/MapModels.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | class FMap( 4 | val images: MapImages, 5 | val pois: List 6 | ) 7 | 8 | class MapImages( 9 | val blank: String, 10 | val pois: String, 11 | ) 12 | 13 | class MapPOI( 14 | val id: String, 15 | val name: String, 16 | val location: MapPOILocation 17 | ) 18 | 19 | class MapPOILocation( 20 | val x: Float, 21 | val y: Float, 22 | val z: Float 23 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/models/PlaylistModels.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.models 2 | 3 | import java.util.* 4 | 5 | class Playlist( 6 | val id: String, 7 | val name: String, 8 | val subName: String, 9 | val description: String, 10 | val gameType: String, 11 | val minPlayers: Int, 12 | val maxPlayers: Int, 13 | val maxTeams: Int, 14 | val maxTeamSize: Int, 15 | val maxSquads: Int, 16 | val maxSquadSize: Int, 17 | val isDefault: Boolean, 18 | val isTournament: Boolean, 19 | val isLimitedTimeMode: Boolean, 20 | val isLargeTeamGame: Boolean, 21 | val accumulateToProfileStats: Boolean, 22 | val images: PlaylistImages, 23 | val gameplayTags: List, 24 | val path: String, 25 | val added: Date 26 | ) 27 | 28 | class PlaylistImages( 29 | val showcase: String, 30 | val missionIcon: String 31 | ) -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/services/AESService.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.services 2 | 3 | import com.thoo.api.models.AesModel 4 | import com.thoo.api.models.BaseModel 5 | import com.thoo.api.utils.FCall 6 | import retrofit2.http.GET 7 | import retrofit2.http.Query 8 | 9 | interface AESService: EndpointService { 10 | 11 | @GET("/v2/aes") 12 | fun getAes( 13 | @Query("keyFormat") code: String 14 | ): FCall 15 | 16 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/services/BannerService.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.services 2 | 3 | import com.thoo.api.models.Banner 4 | import com.thoo.api.models.BannerColor 5 | import com.thoo.api.utils.FCall 6 | import retrofit2.http.GET 7 | import retrofit2.http.Query 8 | 9 | interface BannerService: EndpointService { 10 | 11 | @GET("/v1/banners") 12 | fun getBanners( 13 | @Query("language") language: String 14 | ): FCall> 15 | 16 | @GET("/v1/banners/colors") 17 | fun getBannerColors(): FCall> 18 | 19 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/services/CosmeticService.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.services 2 | 3 | import com.thoo.api.models.Cosmetic 4 | import com.thoo.api.utils.FCall 5 | import retrofit2.http.GET 6 | import retrofit2.http.Query 7 | 8 | interface CosmeticService: EndpointService { 9 | 10 | @GET("/v2/cosmetics/br") 11 | fun getCosmetics( 12 | @Query("language") language: String 13 | ): FCall> 14 | 15 | @GET("/v2/cosmetics/br/new") 16 | fun getNewCosmetics( 17 | @Query("language") language: String 18 | ): FCall> 19 | 20 | @GET("/v2/cosmetics/br/search/all") 21 | fun searchCosmetic( 22 | @Query("language") language: String, 23 | @Query("searchLanguage") searchLanguage: String, 24 | @Query("matchMethod") matchMethod: String, 25 | @Query("id") id: String?, 26 | @Query("name") name: String?, 27 | @Query("description") description: String?, 28 | @Query("type") type: String?, 29 | @Query("displayType") displayType: String?, 30 | @Query("backendType") backendType: String?, 31 | @Query("rarity") rarity: String?, 32 | @Query("displayRarity") displayRarity: String?, 33 | @Query("backendRarity") backendRarity: String?, 34 | @Query("hasSeries") hasSeries: Boolean?, 35 | @Query("hasSet") hasSet: Boolean?, 36 | @Query("set") set: String?, 37 | @Query("setText") setText: String?, 38 | @Query("backendSet") backendSet: String?, 39 | @Query("hasIntroduction") hasIntroduction: Boolean?, 40 | @Query("introductionChapter") introductionChapter: String?, 41 | @Query("introductionSeason") introductionSeason: String?, 42 | @Query("hasFeaturedImage") hasFeaturedImage: Boolean?, 43 | @Query("hasVariants") hasVariants: Boolean?, 44 | @Query("hasGameplayTags") hasGameplayTags: Boolean?, 45 | @Query("gameplayTag") gameplayTag: String?, 46 | @Query("added") added: Long?, 47 | @Query("addedSince") addedSince: Long?, 48 | @Query("unseenFor") unseenFor: Long?, 49 | @Query("lastAppearance") lastAppearance: Long?, 50 | ): FCall 51 | 52 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/services/CreatorService.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.services 2 | 3 | import com.thoo.api.models.Creator 4 | import com.thoo.api.utils.FCall 5 | import retrofit2.http.GET 6 | import retrofit2.http.Query 7 | 8 | interface CreatorService { 9 | 10 | @GET("/v2/creatorcode") 11 | fun getCreator( 12 | @Query("name") name: String 13 | ): FCall 14 | 15 | @GET("/v2/creatorcode") 16 | fun searchCreator( 17 | @Query("name") name: String 18 | ): FCall 19 | 20 | @GET("/v2/creatorcode") 21 | fun searchCreators( 22 | @Query("name") name: String 23 | ): FCall> 24 | 25 | 26 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/services/EndpointService.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.services 2 | 3 | interface EndpointService {} -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/services/MapService.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.services 2 | 3 | import com.thoo.api.models.FMap 4 | import com.thoo.api.utils.FCall 5 | import okhttp3.ResponseBody 6 | import retrofit2.Call 7 | import retrofit2.http.GET 8 | import retrofit2.http.Query 9 | 10 | interface MapService: EndpointService { 11 | 12 | @GET("/v1/map") 13 | fun getMap( 14 | @Query("language") language: String 15 | ): FCall 16 | 17 | @GET("/images/map.png") 18 | fun downloadMap(): Call 19 | 20 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/services/PlaylistService.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.services 2 | 3 | import com.thoo.api.models.Playlist 4 | import com.thoo.api.utils.FCall 5 | import retrofit2.http.GET 6 | import retrofit2.http.Path 7 | import retrofit2.http.Query 8 | 9 | interface PlaylistService: EndpointService { 10 | 11 | @GET("/v1/playlists") 12 | fun getPlaylists( 13 | @Query("language") language: String 14 | ): FCall> 15 | 16 | @GET("/v1/playlists/{id}") 17 | fun getPlaylistById( 18 | @Path("id") id: String, 19 | @Query("language") language: String 20 | ): FCall 21 | 22 | } -------------------------------------------------------------------------------- /src/main/kotlin/com/thoo/api/utils/Utils.kt: -------------------------------------------------------------------------------- 1 | package com.thoo.api.utils 2 | 3 | import com.google.gson.Gson 4 | import com.google.gson.reflect.TypeToken 5 | import com.thoo.api.exceptions.FortniteApiException 6 | import com.thoo.api.models.BaseModel 7 | import com.thoo.api.models.ExceptionModel 8 | import okhttp3.OkHttpClient 9 | import okhttp3.Request 10 | import retrofit2.Call 11 | import retrofit2.Response 12 | import java.io.BufferedInputStream 13 | import java.io.File 14 | import java.io.FileOutputStream 15 | import java.io.InputStream 16 | import kotlin.jvm.Throws 17 | 18 | typealias FCall = Call> 19 | 20 | val gson = Gson() 21 | 22 | @Throws(FortniteApiException::class) 23 | internal inline fun Call>.send(): BaseModel { 24 | val response = this.execute() 25 | if(!response.isSuccessful) throw response.parseApiError() 26 | return response.body()!! 27 | } 28 | 29 | @Throws(FortniteApiException::class) 30 | internal inline fun Request.sendOkHttp(client: OkHttpClient): T { 31 | val response = client.newCall(this).execute() 32 | if(!response.isSuccessful) { 33 | val model = gson.fromJson(response.body()?.string() ?: "{}") 34 | val error = FortniteApiException(model.status, model.error) 35 | throw error 36 | } 37 | return gson.fromJson(response.body()?.string() ?: "{}") 38 | } 39 | 40 | internal inline fun Gson.fromJson(json: String) = 41 | fromJson(json, object: TypeToken() {}.type) 42 | 43 | internal fun Response<*>.parseApiError(): FortniteApiException { 44 | val json = this.errorBody()?.string() ?: "{}" 45 | return gson.fromJson(json, FortniteApiException::class.java) 46 | } 47 | 48 | internal fun download(byteStream: BufferedInputStream, file: File): Int { 49 | val reader = ByteArray(4096) 50 | var fileSizeDownloaded = 0 51 | val output = FileOutputStream(file) 52 | while(true) { 53 | val read = byteStream.read(reader) 54 | if(read == -1) break 55 | output.write(reader, 0, read) 56 | fileSizeDownloaded += read 57 | } 58 | output.flush() 59 | byteStream.close() 60 | output.close() 61 | return fileSizeDownloaded / (1024 * 1024) 62 | } -------------------------------------------------------------------------------- /src/test/java/TestJava.java: -------------------------------------------------------------------------------- 1 | public final class TestJava { 2 | 3 | public static void main(String[] args) { 4 | 5 | } 6 | 7 | } 8 | -------------------------------------------------------------------------------- /src/test/kotlin/TestKotlin.kt: -------------------------------------------------------------------------------- 1 | import com.thoo.api.FortniteAPI 2 | import com.thoo.api.enums.Language 3 | 4 | object TestKotlin { 5 | 6 | @JvmStatic 7 | fun main(args: Array) { 8 | val api = FortniteAPI.create( 9 | language = Language.DE 10 | ) 11 | val cosmetic = api.cosmetic.searchCosmetic { 12 | name = "Aura" 13 | } 14 | println(cosmetic.data.name) 15 | } 16 | 17 | } --------------------------------------------------------------------------------