This repository has been archived by the owner on Jan 11, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 155
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Convert Retrofit Model Java classes to Kotlin
Convert EndPoints class from Java to Kotlin
- Loading branch information
1 parent
18b7659
commit 091aee4
Showing
26 changed files
with
444 additions
and
489 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
145 changes: 0 additions & 145 deletions
145
app/src/main/java/org/apache/fineract/data/remote/BaseApiManager.java
This file was deleted.
Oops, something went wrong.
87 changes: 87 additions & 0 deletions
87
app/src/main/java/org/apache/fineract/data/remote/BaseApiManager.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
package org.apache.fineract.data.remote | ||
|
||
import android.content.Context | ||
import okhttp3.OkHttpClient | ||
import okhttp3.logging.HttpLoggingInterceptor | ||
import org.apache.fineract.data.services.* | ||
import retrofit2.Retrofit | ||
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory | ||
import retrofit2.converter.gson.GsonConverterFactory | ||
import retrofit2.converter.scalars.ScalarsConverterFactory | ||
|
||
/** | ||
* Created by Ahmad Jawid Muhammadi on 1/6/20 | ||
*/ | ||
|
||
class BaseApiManager(context: Context) { | ||
|
||
companion object { | ||
lateinit var retrofit: Retrofit | ||
} | ||
|
||
lateinit var anonyMousRetrofit: Retrofit | ||
lateinit var authApi: AuthService | ||
lateinit var customerApi: CustomerService | ||
lateinit var depositApi: DepositService | ||
lateinit var loanApi: LoanService | ||
lateinit var individualLendingService: IndividualLendingService | ||
lateinit var anonymousService: AnonymousService | ||
lateinit var rolesService: RolesService | ||
lateinit var accountingService: AccountingService | ||
lateinit var tellerService: TellersService | ||
lateinit var productService: ProductService | ||
lateinit var payrollService: PayrollService | ||
|
||
init { | ||
createService(context) | ||
createAnonymousService() | ||
} | ||
|
||
private fun init() { | ||
authApi = createApi(AuthService::class.java) | ||
customerApi = createApi(CustomerService::class.java) | ||
depositApi = createApi(DepositService::class.java) | ||
loanApi = createApi(LoanService::class.java) | ||
individualLendingService = createApi(IndividualLendingService::class.java) | ||
rolesService = createApi(RolesService::class.java) | ||
accountingService = createApi(AccountingService::class.java) | ||
tellerService = createApi(TellersService::class.java) | ||
productService = createApi(ProductService::class.java) | ||
payrollService = createApi(PayrollService::class.java) | ||
} | ||
|
||
private fun initAnonymous() { | ||
anonymousService = anonyMousRetrofit!!.create(AnonymousService::class.java) | ||
} | ||
|
||
private fun <T> createApi(clazz: Class<T>): T { | ||
return retrofit!!.create(clazz) | ||
} | ||
|
||
private fun createService(context: Context) { | ||
retrofit = Retrofit.Builder() | ||
.baseUrl(BaseUrl.getDefaultBaseUrl()) | ||
.addConverterFactory(NullOnEmptyConverterFactory()) | ||
.addConverterFactory(ScalarsConverterFactory.create()) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | ||
.client(FineractOkHttpClient.getFineractOkHttpClient(context)) | ||
.build() | ||
init() | ||
} | ||
|
||
private fun createAnonymousService() { | ||
val interceptor = HttpLoggingInterceptor() | ||
interceptor.level = HttpLoggingInterceptor.Level.BODY | ||
val okHttpClient = OkHttpClient.Builder() | ||
.addInterceptor(interceptor) | ||
.build() | ||
anonyMousRetrofit = Retrofit.Builder() | ||
.baseUrl(BaseUrl.getDefaultBaseUrl()) | ||
.addConverterFactory(GsonConverterFactory.create()) | ||
.addCallAdapterFactory(RxJava2CallAdapterFactory.create()) | ||
.client(okHttpClient) | ||
.build() | ||
initAnonymous() | ||
} | ||
} |
25 changes: 0 additions & 25 deletions
25
app/src/main/java/org/apache/fineract/data/remote/BaseUrl.java
This file was deleted.
Oops, something went wrong.
22 changes: 22 additions & 0 deletions
22
app/src/main/java/org/apache/fineract/data/remote/BaseUrl.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package org.apache.fineract.data.remote | ||
|
||
/** | ||
* Created by Ahmad Jawid Muhammadi on 1/6/20 | ||
*/ | ||
|
||
object BaseUrl { | ||
private const val PROTOCOL_HTTPS = "https://" | ||
private const val API_ENDPOINT = "pilot.kuelap.io" | ||
val PORT = "80" | ||
// "/" in the last of the base url always | ||
|
||
// "/" in the last of the base url always | ||
fun getName(): String? { | ||
return "fineract" | ||
} | ||
|
||
@JvmStatic | ||
fun getDefaultBaseUrl(): String? { | ||
return PROTOCOL_HTTPS + API_ENDPOINT | ||
} | ||
} |
36 changes: 0 additions & 36 deletions
36
app/src/main/java/org/apache/fineract/data/remote/ConnectivityInterceptor.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.