|
@@ -1,15 +1,15 @@
|
|
|
package com.example.bomocloud
|
|
|
|
|
|
import com.example.bomocloud.auth.AuthService
|
|
|
+import com.example.bomocloud.auth.OauthService
|
|
|
import com.example.bomocloud.home.HomeService
|
|
|
import com.example.bomocloud.theme.ThemeService
|
|
|
-import okhttp3.Interceptor
|
|
|
import okhttp3.OkHttpClient
|
|
|
import retrofit2.Retrofit
|
|
|
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
|
|
|
import retrofit2.converter.gson.GsonConverterFactory
|
|
|
|
|
|
-class BoMoCloud(val clientId: String, val clientSecret: String) {
|
|
|
+class BoMoCloud(private val clientId: String, private val clientSecret: String) {
|
|
|
|
|
|
companion object {
|
|
|
const val DEBUG_HOST = "https://preparing.bomostory.com/"
|
|
@@ -32,13 +32,20 @@ class BoMoCloud(val clientId: String, val clientSecret: String) {
|
|
|
}
|
|
|
|
|
|
val host = if (BuildConfig.DEBUG) DEBUG_HOST else RELEASE_HOST
|
|
|
+
|
|
|
val authService: AuthService = buildAuthService()
|
|
|
+ val oAuthService: OauthService = buildOAuthService()
|
|
|
val homeService: HomeService = buildHomeService()
|
|
|
val themeService: ThemeService = buildThemeService()
|
|
|
|
|
|
+ var refreshToken: String? = null
|
|
|
+
|
|
|
private fun buildAuthService(): AuthService =
|
|
|
getRetrofit(host + AuthService.BASE_URL).create(AuthService::class.java)
|
|
|
|
|
|
+ private fun buildOAuthService(): OauthService =
|
|
|
+ getRetrofit(host + OauthService.BASE_URL).create(OauthService::class.java)
|
|
|
+
|
|
|
private fun buildHomeService(): HomeService =
|
|
|
getRetrofit(host + HomeService.BASE_URL).create(HomeService::class.java)
|
|
|
|
|
@@ -64,5 +71,6 @@ class BoMoCloud(val clientId: String, val clientSecret: String) {
|
|
|
request = request.newBuilder().url(httpUrl).build()
|
|
|
it.proceed(request)
|
|
|
}
|
|
|
+ .authenticator(TokenAuthenticator(this))
|
|
|
.build()
|
|
|
}
|