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

fix api error param

parent 3f7f30b5
...@@ -75,7 +75,7 @@ class ChooseTourDialogController : Controller { ...@@ -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 return view
} }
......
...@@ -146,7 +146,7 @@ interface IBigantoMobileApi { ...@@ -146,7 +146,7 @@ interface IBigantoMobileApi {
@Query(CLIENT_VERSION_PARAM) clientVersion: String = DEFAULT_CLIENT_VERSION, @Query(CLIENT_VERSION_PARAM) clientVersion: String = DEFAULT_CLIENT_VERSION,
@Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION, @Query(API_VERSION_PARAM) apiVersion: String = DEFAULT_API_VERSION,
@Query(LANG_PARAM) languageCode: String = Locale.getDefault().language, @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>> ): Observable<Response<OfferTours>>
@Streaming @Streaming
......
...@@ -97,15 +97,21 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -97,15 +97,21 @@ class TourPreviewsUseCase @Inject constructor(
private fun fetchDbTourList(estateId: Int) = private fun fetchDbTourList(estateId: Int) =
db.getEstateTourPreviews(estateId) db.getEstateTourPreviews(estateId)
.filter { !it.isNullOrEmpty() }
private fun fetchApiTourList(multitourId:Int,estateId: Int) = 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) api.getOfferTours(multitourId)
.doOnError { Timber.e(it) }
.map { .map {
mergeRaw(it, TourRemoteRequestModel( mergeRaw(it, TourRemoteRequestModel(
estateId, estateId,
api.provideHttpUrl().toString(), api.provideHttpUrl().toString(),
user.targetResolution res
) )
) )
} }
...@@ -117,8 +123,9 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -117,8 +123,9 @@ class TourPreviewsUseCase @Inject constructor(
Observable.mergeDelayError( Observable.mergeDelayError(
arrayListOf(fetchDbTourList(parent),fetchApiTourList(multitourId,parent)) arrayListOf(fetchDbTourList(parent),fetchApiTourList(multitourId,parent))
) )
.map { it } .doOnError { Timber.e(it) }
.map (::fromEntity) .map (::fromEntity)
.subscribeOn(Schedulers.io())
private fun mergeRaw(raw: List<TourPreviewRaw>, requestRequestModel: TourRemoteRequestModel) = private fun mergeRaw(raw: List<TourPreviewRaw>, requestRequestModel: TourRemoteRequestModel) =
...@@ -126,6 +133,7 @@ class TourPreviewsUseCase @Inject constructor( ...@@ -126,6 +133,7 @@ class TourPreviewsUseCase @Inject constructor(
private fun mergeRaw(raw: TourPreviewRaw, requestRequestModel: TourRemoteRequestModel) private fun mergeRaw(raw: TourPreviewRaw, requestRequestModel: TourRemoteRequestModel)
: TourPreviewEntity { : TourPreviewEntity {
Timber.d("got raw: $raw")
val entity = db.getTourPreview(raw.id.toString()).firstOrNull() val entity = db.getTourPreview(raw.id.toString()).firstOrNull()
?: return fromRaw(raw ?: return fromRaw(raw
, requestRequestModel.estateId , 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