Skip to content

Commit

Permalink
MIFOSAC-299 applied spotless and detekt on core:network (#2259)
Browse files Browse the repository at this point in the history
  • Loading branch information
itsPronay authored Dec 7, 2024
1 parent 086c5bb commit 54aa6bc
Show file tree
Hide file tree
Showing 67 changed files with 959 additions and 389 deletions.
9 changes: 9 additions & 0 deletions core/network/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
plugins {
alias(libs.plugins.mifos.android.library)
alias(libs.plugins.mifos.android.library.jacoco)
Expand Down
9 changes: 9 additions & 0 deletions core/network/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2024 Mifos Initiative
This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
If a copy of the MPL was not distributed with this file,
You can obtain one at https://mozilla.org/MPL/2.0/.
See https://github.com/openMF/android-client/blob/master/LICENSE.md
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
46 changes: 25 additions & 21 deletions core/network/src/main/java/com/mifos/core/network/BaseApiManager.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.network
Expand Down Expand Up @@ -36,7 +41,6 @@ import javax.inject.Inject
*/
class BaseApiManager @Inject constructor(private val prefManager: com.mifos.core.datastore.PrefManager) {


init {
createService(prefManager)
}
Expand Down Expand Up @@ -98,55 +102,55 @@ class BaseApiManager @Inject constructor(private val prefManager: com.mifos.core

fun init() {
centerApi = createApi(
CenterService::class.java
CenterService::class.java,
)
accountsApi = createApi(
ClientAccountsService::class.java
ClientAccountsService::class.java,
)
clientsApi = createApi(
ClientService::class.java
ClientService::class.java,
)
dataTableApi = createApi(
DataTableService::class.java
DataTableService::class.java,
)
loanApi = createApi(
LoanService::class.java
LoanService::class.java,
)
savingsApi = createApi(
SavingsAccountService::class.java
SavingsAccountService::class.java,
)
searchApi = createApi(
SearchService::class.java
SearchService::class.java,
)
groupApi = createApi(
GroupService::class.java
GroupService::class.java,
)
documentApi = createApi(
DocumentService::class.java
DocumentService::class.java,
)
officeApi = createApi(
OfficeService::class.java
OfficeService::class.java,
)
staffApi = createApi(
StaffService::class.java
StaffService::class.java,
)
surveyApi = createApi(
SurveyService::class.java
SurveyService::class.java,
)
chargeApi = createApi(
ChargeService::class.java
ChargeService::class.java,
)
runReportsService = createApi(
RunReportsService::class.java
RunReportsService::class.java,
)
noteApi = createApi(
NoteService::class.java
NoteService::class.java,
)
collectionSheetApi = createApi(
CollectionSheetService::class.java
CollectionSheetService::class.java,
)
checkerInboxApi = createApi(
CheckerInboxService::class.java
CheckerInboxService::class.java,
)
}

Expand All @@ -162,9 +166,9 @@ class BaseApiManager @Inject constructor(private val prefManager: com.mifos.core
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.client(MifosOkHttpClient(prefManager).mifosOkHttpClient)
.client(MifosOkHttpClient(prefManager).okHttpClient)
.build()
init()
}
}
}
}
23 changes: 13 additions & 10 deletions core/network/src/main/java/com/mifos/core/network/BaseUrl.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.network
Expand All @@ -10,15 +15,13 @@ import com.mifos.core.common.utils.asServerConfig
/**
* @author fomenkoo
*/
class BaseUrl {
object BaseUrl {

// "/" in the last of the base url always
companion object {
private val configs = BuildConfig.DEMO_SERVER_CONFIG.asServerConfig()
private val configs = BuildConfig.DEMO_SERVER_CONFIG.asServerConfig()

val PROTOCOL_HTTPS = configs.protocol
val API_ENDPOINT = configs.endPoint
val API_PATH = configs.apiPath
val PORT = configs.port
}
}
val PROTOCOL_HTTPS = configs.protocol
val API_ENDPOINT = configs.endPoint
val API_PATH = configs.apiPath
val PORT = configs.port
}
43 changes: 30 additions & 13 deletions core/network/src/main/java/com/mifos/core/network/DataManager.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
/*
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.network

import com.mifos.core.data.ChargesPayload
Expand Down Expand Up @@ -36,15 +45,15 @@ class DataManager {
private val mBaseApiManager: BaseApiManager
private var mDataManagerClient: DataManagerClient? = null

//TODO : This Constructor is temp after splitting the Datamanager layer into Sub DataManager
// TODO : This Constructor is temp after splitting the Datamanager layer into Sub DataManager
constructor(baseApiManager: BaseApiManager) {
mBaseApiManager = baseApiManager
}

@Inject
constructor(
baseApiManager: BaseApiManager,
dataManagerClient: DataManagerClient?
dataManagerClient: DataManagerClient?,
) {
mBaseApiManager = baseApiManager
mDataManagerClient = dataManagerClient
Expand All @@ -67,33 +76,41 @@ class DataManager {

fun saveCollectionSheet(
centerId: Int,
collectionSheetPayload: CollectionSheetPayload?
collectionSheetPayload: CollectionSheetPayload?,
): Observable<SaveResponse> {
return mBaseApiManager.centerApi.saveCollectionSheet(
centerId, collectionSheetPayload
centerId,
collectionSheetPayload,
)
}

fun saveCollectionSheetAsync(
id: Int,
payload: CollectionSheetPayload?
payload: CollectionSheetPayload?,
): Observable<SaveResponse> {
return mBaseApiManager.centerApi.saveCollectionSheetAsync(id, payload)
}

fun getCenterList(
dateFormat: String?, locale: String?, meetingDate: String?, officeId: Int, staffId: Int
dateFormat: String?,
locale: String?,
meetingDate: String?,
officeId: Int,
staffId: Int,
): Observable<List<OfflineCenter>> {
return mBaseApiManager.centerApi.getCenterList(
dateFormat, locale, meetingDate,
officeId, staffId
dateFormat,
locale,
meetingDate,
officeId,
staffId,
)
}

/**
* Charges API
*/
//TODO Remove this Method After fixing the Charge Test
// TODO Remove this Method After fixing the Charge Test
fun getClientCharges(clientId: Int, offset: Int, limit: Int): Observable<Page<Charges>> {
return mBaseApiManager.chargeApi.getListOfCharges(clientId, offset, limit)
}
Expand All @@ -104,7 +121,7 @@ class DataManager {

suspend fun createCharges(
clientId: Int,
payload: ChargesPayload
payload: ChargesPayload,
): ChargeCreationResponse {
return mBaseApiManager.chargeApi.createCharges(clientId, payload)
}
Expand All @@ -115,7 +132,7 @@ class DataManager {

suspend fun createLoanCharges(
loanId: Int,
chargesPayload: ChargesPayload
chargesPayload: ChargesPayload,
): ChargeCreationResponse {
return mBaseApiManager.chargeApi.createLoanCharges(loanId, chargesPayload)
}
Expand All @@ -129,7 +146,7 @@ class DataManager {

suspend fun getGroupsByOffice(
office: Int,
params: Map<String, String>
params: Map<String, String>,
): List<Group> {
return mBaseApiManager.groupApi.getAllGroupsInOffice(office, params)
}
Expand Down Expand Up @@ -182,4 +199,4 @@ class DataManager {
fun getListOfCharges(clientId: Int): Observable<Page<Charges>> {
return mBaseApiManager.loanApi.getListOfCharges(clientId)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.network
Expand All @@ -9,4 +14,4 @@ package com.mifos.core.network
*/
class GenericRequest {
var requestFields = HashMap<String, Any>()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.network
Expand All @@ -11,7 +16,7 @@ class GenericResponse {
var responseFields = HashMap<String, Any>()
override fun toString(): String {
return "GenericResponse{" +
"responseFields=" + responseFields +
'}'
"responseFields=" + responseFields +
'}'
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
/*
* This project is licensed under the open source MPL V2.
* Copyright 2024 Mifos Initiative
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.core.network
Expand Down Expand Up @@ -27,4 +32,4 @@ class MifosInterceptor(private val prefManager: com.mifos.core.datastore.PrefMan
const val HEADER_TENANT = "Fineract-Platform-TenantId"
const val HEADER_AUTH = "Authorization"
}
}
}
Loading

0 comments on commit 54aa6bc

Please sign in to comment.