I want to get this kind of response (if a user search for specific keyword):
VendListRequest(row=50, page=1, query=[["vendorName", contain, "erlangga"],["status","true"]])
But I cannot get that kind of response. I have data class like this:
data class VendListRequest (
val row : Int,
val page : Int,
val query : List<List<String>>
)
It can only retrieve the response like this:
(row=50, page=1, query=[["vendorName", contain, "erlangga"])
The cases that I want it to be are like these:
When a user doesn't type any keyword on search box, the list will appear and the debug query response will be like this :
VendListRequest(row=50, page=1, query=[["status", "true"]])
When a user types any keyword on the search box, the list will appear and the debug query response will be like this:
VendListRequest(row=50, page=1, query=[["vendorName", contain, "erlangga"],["status", "true"]])
here's my code in the kotlin class to retrieve the data:
override fun getVendorList(row: Int, page: Int, vendorName: String?, query: String?, status: String?, isLoadMore: Boolean): Observable<SearchListResponse<VendorItem>> {
var searchList: List<List<String>> = emptyList()
if (!vendorName.isNullOrEmpty() && !query.isNullOrEmpty()) {
searchList = listOf(status, EQUALS, true)
}
//___________________________________________________________________
}
I finally found the answer. This is what I did :
Before :
fun getVendorList(row: Int, page: Int, vendorName: String?, query: String?, isLoadMore: Boolean) : Observable<Response<VendorItem>>
After :
fun getVendorList(row: Int, page: Int, vendorName: String?, query: String?, status: String, isLoadMore: Boolean) : Observable<Response<VendorItem>>
val vendListReq= VendListReq(row, page, searchList + statusList)
then call it in :
.concatMap { remRegData.getVendList(it, vendListReq) }