Commit 4168f8e7 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

fix api error param

parent 3f7f30b5
......@@ -75,7 +75,7 @@ class ChooseTourDialogController : Controller {
// )
})
view.findViewById<View>(R.id.cancel_button).setOnClickListener { handleBack() }
view.findViewById<View>(R.id.close_current_button).setOnClickListener { handleBack() }
return view
}
......
......@@ -146,7 +146,7 @@ interface IBigantoMobileApi {
@Query(CLIENT_VERSION_PARAM) clientVersion: String = DEFAULT_CLIENT_VERSION,
@Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION,
@Query(LANG_PARAM) languageCode: String = Locale.getDefault().language,
@Query(OFFER_GET_TOURS_METHOD) offerId: Int
@Query(OFFER_GET_TOURS_ID) offerId: Int
): Observable<Response<OfferTours>>
@Streaming
......
......@@ -97,15 +97,21 @@ class TourPreviewsUseCase @Inject constructor(
private fun fetchDbTourList(estateId: Int) =
db.getEstateTourPreviews(estateId)
.filter { !it.isNullOrEmpty() }
private fun fetchApiTourList(multitourId:Int,estateId: Int) =
auth.currentUser().flatMap { user ->
auth.currentUser()
.doOnNext { Timber.d("user on next: $it") }
.map { it.targetResolution }
.flatMap { res ->
Timber.d("user: $res")
api.getOfferTours(multitourId)
.doOnError { Timber.e(it) }
.map {
mergeRaw(it, TourRemoteRequestModel(
estateId,
api.provideHttpUrl().toString(),
user.targetResolution
res
)
)
}
......@@ -117,8 +123,9 @@ class TourPreviewsUseCase @Inject constructor(
Observable.mergeDelayError(
arrayListOf(fetchDbTourList(parent),fetchApiTourList(multitourId,parent))
)
.map { it }
.doOnError { Timber.e(it) }
.map (::fromEntity)
.subscribeOn(Schedulers.io())
private fun mergeRaw(raw: List<TourPreviewRaw>, requestRequestModel: TourRemoteRequestModel) =
......@@ -126,6 +133,7 @@ class TourPreviewsUseCase @Inject constructor(
private fun mergeRaw(raw: TourPreviewRaw, requestRequestModel: TourRemoteRequestModel)
: TourPreviewEntity {
Timber.d("got raw: $raw")
val entity = db.getTourPreview(raw.id.toString()).firstOrNull()
?: return fromRaw(raw
, requestRequestModel.estateId
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment