Commit 7d76b6be authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

actualize api calls

parent 6c81fb51
package com.biganto.visual.roompark.data.data_provider
import com.biganto.visual.androidplayer.data.repository.local.ILocalStore
import com.biganto.visual.roompark.data.local.UserState
import com.biganto.visual.roompark.data.repository.api.IRoomParkApi
import com.biganto.visual.roompark.data.repository.db.IDb
import com.biganto.visual.roompark.domain.contract.DealContract
import com.biganto.visual.roompark.domain.custom_exception.CustomApiException
import com.biganto.visual.roompark.domain.model.EstateModel
import timber.log.Timber
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 29.10.2019.
*/
//
class EstateRepository @Inject constructor(
private val local: ILocalStore,
private val api: IRoomParkApi,
private val db: IDb
): DealContract{
init {
Timber.d("Estate Repository Created")
}
val getFavoritesApi =
local.recentUser()
.flatMap{ when(it){
is UserState.Authenticated -> db.fetchUser(it.uuid.toInt())
else -> throw CustomApiException.NotAuthorizedException()
} }
.flatMap { api.getFavorites(it.authToken)
// .map(::fromRaw)
}
override fun getFavorites(): io.reactivex.rxjava3.core.Observable<List<EstateModel>> {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
}
}
......@@ -35,8 +35,7 @@ data class EstateRaw(
val plan_jpg:PlanRaw?,
val url:String,
val album_id:Int,
val multitour_id:Int?,
val explications: List<ExplicationRaw>?
val multitour_id:Int?
)
data class PlanRaw(
......@@ -48,6 +47,7 @@ data class PlanRaw(
data class CommonInfoRaw(
val building: Int,
val section_begin:Int,
val section_end:Int?,
val floor:Int,
val floor_max:Int,
val area: Float?,
......@@ -65,8 +65,6 @@ data class CommonInfoRaw(
val rooms:Int?
)
data class ExplicationRaw(val plan_id:Int,val items:List<EstateRoomRaw>)
data class EstateRoomRaw(
val title:String,
val living:Boolean,
......@@ -138,7 +136,8 @@ data class ResolutionRaw(
data class PlanTypeRaw(
val plan_id:Int,
val title:String,
val features: List<String>
val features: List<String>,
val explication: List<EstateRoomRaw>?
)
data class MultiTourRaw(
......
......@@ -56,4 +56,14 @@ interface Estate : Persistable {
val info_dependent: Boolean?
@get:Nullable
val info_decoration: String?
@get:Nullable
val info_window_face: String?
@get:Nullable
val info_price: Int?
@get:Nullable
val info_price_meter: Int?
@get:Nullable
val info_ceiling: Float?
@get:Nullable
val info_direction: String?
}
\ No newline at end of file
package com.biganto.visual.roompark.domain.model
import com.biganto.visual.roompark.data.repository.api.retrofit.raw.EstateRaw
import com.biganto.visual.roompark.data.repository.db.requrey.model.EstateEntity
import com.biganto.visual.roompark.data.repository.db.requrey.model.ExplicationEntity
/**
* Created by Vladislav Bogdashkin on 23.09.2019.
*/
......@@ -41,6 +45,43 @@ data class EstateModel(
val url:String?
)
fun fromRaw(raw:EstateRaw):EstateEntity{
val entity = EstateEntity()
entity.setId(raw.id)
entity.setType(raw.type)
entity.setNumber(raw.number)
entity.setSectionBegin(raw.common_info.section_begin)
entity.setSectionEnd(raw.common_info.section_end)
entity.setPlanJpgUrl(raw.plan_jpg?.url)
entity.setPlanJpgWidth(raw.plan_jpg?.width)
entity.setPlanJpgHeight(raw.plan_jpg?.height)
entity.setPlanPngUrl(raw.plan_png?.url)
entity.setPlanPngWidth(raw.plan_png?.width)
entity.setPlanPngHeight(raw.plan_png?.height)
entity.setRooms(raw.common_info.rooms)
entity.setAlbumId(raw.album_id)
entity.setMultitourId(raw.multitour_id)
entity.setUrl(raw.url)
entity.setInfo_floor_max(raw.common_info.floor_max)
entity.setInfo_area(raw.common_info.area)
entity.setInfo_area_living(raw.common_info.area_living)
entity.setInfo_kind(raw.common_info.kind)
entity.setInfo_dependent(raw.common_info.dependent)
entity.setInfo_decoration(raw.common_info.decoration)
entity.setInfo_building(raw.common_info.building)
entity.setInfo_section_begin(raw.common_info.section_begin)
entity.setInfo_floor(raw.common_info.floor)
entity.setInfo_window_face(raw.common_info.windows_face)
entity.setInfo_price(raw.common_info.price)
entity.setInfo_price_meter(raw.common_info.price_meter)
entity.setInfo_ceiling(raw.common_info.ceiling)
entity.setInfo_direction(raw.common_info.direction)
return entity
}
data class PlanModel(
val url:String,
val width:Int,
......
package com.biganto.visual.roompark.domain.use_case
import com.biganto.visual.roompark.domain.contract.DealContract
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
*/
class EstateUseCase @Inject constructor(
private val contract: DealContract
){
fun fetchFavorites() = contract.getFavorites()
}
\ No newline at end of file
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