-
Notifications
You must be signed in to change notification settings - Fork 669
refactor (core:network ) Network converted to KMP #2346
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor (core:network ) Network converted to KMP #2346
Conversation
# Conflicts: # core/network/build.gradle.kts
|
@biplab1 review it once if things are ok then we can merge this and complete the data and domain next |
core/network/src/commonMain/kotlin/com/mifos/core/network/BaseApiManager.kt
Outdated
Show resolved
Hide resolved
biplab1
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are some minor changes that needs to be addressed.
Also, add @OptIn(ExperimentalCoroutinesApi::class) to functions using flatMapLatest in DataManagers
| if (dueDateList.size > 2) { | ||
| return String.format(pattern, dueDateList[0], dueDateList[1], dueDateList[2]) | ||
| return "" | ||
| // return String.format(pattern, dueDateList[0], dueDateList[1], dueDateList[2]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you tell me the reason for commenting out this code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by mistake uncommented it
core/network/build.gradle.kts
Outdated
| id("kotlinx-serialization") | ||
| id("com.google.devtools.ksp") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use version catalog instead:
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.ksp)
| } | ||
|
|
||
| suspend fun getRechdeduleLoansTaskList(): List<com.mifos.core.model.objects.checkerinboxtask.RescheduleLoansTask> { | ||
| return mBaseApiManager.checkerInboxApi.getRescheduleLoansTaskList() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"getRechdeduleLoansTaskList" should be "getRescheduleLoansTaskList"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't understood . It's already getRescheduleLoansTaskList
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| resourceId: Int?, | ||
| ): Flow<List<CheckerTask>> { | ||
| return flow { emit(dataManagerCheckerInbox.getCheckerTaskList()) } | ||
| return dataManagerCheckerInbox.getCheckerTaskList() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So due to Github limitation, I cannot comment on the lines that are outside this PR, so I am adding it here. In line no. 27 of this file,
"getRechdeduleLoansTaskList" should be "getRescheduleLoansTaskList"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| ) | ||
| clientsTemplate | ||
| } | ||
| flow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clientTemplate should be marked with @OptIn(ExperimentalCoroutinesApi::class)
@OptIn(ExperimentalCoroutinesApi::class)
val clientTemplate: Flow<ClientsTemplateEntity>There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| @Serializable | ||
| data class GetCentersResponse( | ||
|
|
||
| val pageItems: kotlin.collections.Set<GetCentersPageItems>? = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
kotlin.collections is redundant here and can be removed.
Similarly, other files in :core:network:model makes use of it, please check and update.
|
|
||
| val columnName: kotlin.String? = null, | ||
|
|
||
| val columnType: ResultsetColumnHeaderData.ColumnType? = null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here ResultsetColumnHeaderData is redundant. It is better to remove. There are two occurrences in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use an alternative to import java.util.Date which is compatible with KMP. Try using
import kotlinx.datetime.Instant and Instant in place of Date data type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
|
||
| @GET(APIEndPoint.MAKER_CHECKER + "/searchtemplate?fields=entityNames,actionNames") | ||
| fun getCheckerInboxSearchTempalate(): Observable<CheckerInboxSearchTemplate> | ||
| fun getCheckerInboxSearchTempalate(): Flow<CheckerInboxSearchTemplate> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getCheckerInboxSearchTempalate should be getCheckerInboxSearchTemplate. Please make appropriate changes in places where it is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line 40: saveindividualCollectionSheet should be saveIndividualCollectionSheet. Also, make changes where it is used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
@revanthkumarJ Just a quick note for future reference — it's best to leave the review comments unresolved even after you've fixed them. That way, maintainers and reviewers can go through and verify the changes before marking them resolved. |
|
@revanthkumarJ I have seen below in many places I give an example change all of them accordingly.
Api DataManager Repository UseCase (it is just an example fix it accordingly) |
| interface GenerateCollectionSheetRepository { | ||
|
|
||
| suspend fun getCentersInOffice(id: Int, params: Map<String, String>): List<CenterEntity> | ||
| suspend fun getCentersInOffice(id: Int, params: Map<String, String>): Flow<List<CenterEntity>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why some functions like these are at the same time suspend and flowable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok i will resolve them . actually they belongs to data module at first i tried to resolve the things to make application run but later Rajan sir told that it will be done during data module migration
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@revanthkumarJ ok then keep your scope to your own and change it to where it belongs to your module. If it is sth like that can you revert it back so someone who works in data module should get any conflicts. and for them it might be confusing like ok it's suspend and at the same time stream and they keep it
|
|
||
| @GET(APIEndPoint.GROUPS) | ||
| suspend fun getAllGroupsInOffice( | ||
| fun getAllGroupsInOffice( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the API call previously was suspend not a stream. so keep it suspend. and you manually wrap it in flow {} at repository layer or wherever it is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or in the above i provided an example if you change it to stream how to do it. In chain some places you added both suspent and return type flow, in some places you removed suspend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in nagarjuna pr niyaj brother mentioned that if any service returns list make it flow and remove suspend i followed that .
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes cause of that in my second message i mentioned that if you remove the suspend and add flow what you should do in other files that calls it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yah after the domain and data are merged we have to change in all feature modules where they are called.
In mifos-mobile we have done similarly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What niyaj mentioned in mifos-mobile network module conversion is
Few things to change I'm commenting on one place
if the function return as List or Observable then convert into Flow<List> or Flow
If the function return as a Flow then that shouldn't be suspend fun, so remove suspend modifier from function.
| override suspend fun uploadClientImage(id: Int, file: MultipartBody.Part?) { | ||
| dataManagerClient.uploadClientImage(id, file) | ||
| override suspend fun uploadClientImage(id: Int, file: PartData?) { | ||
| // dataManagerClient.uploadClientImage(id, file) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you commented this one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
uncommneted it was a mistake
|
|
||
| override fun offices(): Flow<List<OfficeEntity>> { | ||
| return dataManagerOffices.offices() | ||
| return dataManagerOffices.offices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
previously it was calling offices() from DataManagerOffices, which you changed it to fetchOffices. But now you are calling offices not fetchOffices. what is the reason?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved, used fetchoffices()
| ): Flow<SavingsAccountTransactionTemplateEntity?> { | ||
| return dataManagerSavings.getSavingsAccountTransactionTemplate( | ||
| type, | ||
| type!!, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Don't force it like this in here that it is not null. If it is always not null then change the
typetype toStringwherever it is called.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| * This Method Request the REST API of Note and In response give the List of Notes | ||
| */ | ||
| fun getNotes(entityType: String?, entityId: Int): List<Note> { | ||
| fun getNotes(entityType: String, entityId: Int): List<Note> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you changed the entityType type from String? to String. are you sure that when this function is called they entityType is not null, and also the actual api getNotes(...) only accept String cause of that you changed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason i done that is when i runned the application it showed the error like path parameter in ktorfit should not be null
| .apply { | ||
| logger(DebugLogger()) | ||
| }.build() | ||
| single { (context: Any) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This DI injection looks so messy. I haven't work on network, but ask @niyajali to review this file for you.
| code = entity.status?.code, | ||
| value = entity.status?.description, | ||
| code = entity.status.code, | ||
| value = entity.status.description, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does GetGroupsStatus code and description is not nullable that you removed safe call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so so make it safe call
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
| @get:GET(APIEndPoint.CLIENTS + "/template") | ||
| val clientTemplate: Flow<ClientsTemplateEntity> | ||
| @GET(APIEndPoint.CLIENTS + "/template") | ||
| suspend fun getClientTemplate(): ClientsTemplateEntity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why you are making it suspend when it is stream
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is not stream the below function to it is Flow it is not suspend function
| entityName: String? = null, | ||
| resourceId: Int? = null, | ||
| ): List<CheckerTask> | ||
| ): Flow<List<CheckerTask>> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when it is suspend why adding flow, maybe in the UseCase that it is called it will call this suspend function and then emit it accordigly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
@biplab1 @HekmatullahAmin i have done all the suggestions you guys mentioned , see it once if i have missed anything let me know before standup i will do it |
| interface ClientDetailsRepository { | ||
|
|
||
| suspend fun uploadClientImage(id: Int, file: MultipartBody.Part?) | ||
| suspend fun uploadClientImage(id: Int, file: PartData?) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these two equivalent— okhttp3.MultipartBody and io.ktor.http.content.PartData? They must be having different APIs and hence different implementations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes they have different implementations , while passing the the things in domain we have to take care of it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have taken reference from mifos-wallet there MultipartBody.Part? is replaced with PartData
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the information
* initial setup * updated * Updated * Changed Imports in Services * Updated * Updated * Added ktorHttpClient * Added ktorHttpClient * Updated * Updated * Updated * updated mappers * updated mappers * Updated * Updated * Updated * Updated * Updated * Updated ImageLoader.Utils * changed observable to flow in data * Updated * Updated * Updated * Updated based on suggestions * Updated * Updated * Updated
* initial setup * updated * Updated * Changed Imports in Services * Updated * Updated * Added ktorHttpClient * Added ktorHttpClient * Updated * Updated * Updated * updated mappers * updated mappers * Updated * Updated * Updated * Updated * Updated * Updated ImageLoader.Utils * changed observable to flow in data * Updated * Updated * Updated * Updated based on suggestions * Updated * Updated * Updated


Fixes - Jira-#402
Didn't create a Jira ticket, click here to create new.
Please Add Screenshots If there are any UI changes.
Please make sure these boxes are checked before submitting your pull request - thanks!
Run the static analysis check
./gradlew checkorci-prepush.shto make sure you didn't break anythingIf you have multiple commits please combine them into one commit by squashing them.