Commit 09ccdde3 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

get feeds worklflow

parent 2ca86258
......@@ -13,6 +13,7 @@ import io.reactivex.Observable
import io.reactivex.Single
import io.reactivex.schedulers.Schedulers
import timber.log.Timber
import timber.log.Timber.e
import javax.inject.Inject
/**
......@@ -31,6 +32,7 @@ class FeedsContractModule @Inject constructor(
override fun fetchFeeds(): Observable<List<FeedModel>> =
fetchAllFeeds(session.token)
.doOnError (::e)
override fun fetchFeedObservable(id: Int): Observable<ArticlesPreviewModel> {
......
......@@ -30,7 +30,7 @@ class DbModule{
Timber.d("Kotlin store creating..")
val source = DatabaseSource(context, Models.DEFAULT, "BigantoPerfect", DATABASE_VERSION)
source.setLoggingEnabled(false)
source.setLoggingEnabled(true)
val store = KotlinEntityDataStore<Persistable>(source.configuration)
Timber.d("Kotlin store %s",source)
......
......@@ -22,9 +22,9 @@ interface Article : Persistable {
val preview : String?
@get:Nullable
val body : String?
@get:ForeignKey(references = Feed::class, referencedColumn = "alias")
// @get:ForeignKey(references = Feed::class, referencedColumn = "alias")
@get:ManyToOne
val feed : Feed
val feed : Feed?
@get:Convert(TitledPhotoListConverter::class)
val photo : List<TitledPhoto>?
}
\ No newline at end of file
......@@ -13,9 +13,9 @@ interface Feed : Persistable {
@get:Key
val id: Int
val title:String
@get:Key
// @get:Key
val alias: String
@get:OneToMany(mappedBy = "id")
@get:Nullable
@get:JunctionTable(name= "FeedArticlesRule")
@get:OneToMany( cascade = arrayOf(CascadeAction.DELETE))
val articles:Set<Article>?
}
\ No newline at end of file
......@@ -21,8 +21,7 @@ class UserSessionService @Inject constructor(
private var _token:String? = null
override val token = _token?: throw CustomApiException
.UnknownCustomApiException(-1, R.string.unauthorized_user_request)
override val token = _token?: ""
val disposable =
......@@ -51,9 +50,9 @@ class UserSessionService @Inject constructor(
is UserState.Authenticated ->it.uuid
is UserState.NotAuthenticated ->
CustomApiException
.UnknownCustomApiException(-1, R.string.unauthorized_user_request)
.UnknownCustomApiException(-1, R.string.unauthorized_user_request,null)
else -> CustomApiException
.UnknownCustomApiException(-1, R.string.unauthorized_user_request)
.UnknownCustomApiException(-1, R.string.unauthorized_user_request,null)
}
}
......
......@@ -128,14 +128,14 @@ sealed class CustomApiException(val code:Int,@StringRes val messageStringId: In
class TourByIdNotFoundException() : CustomApiException(
CUSTOM_API_ERROR_RESPONSE_CODE_TOUR_NOT_FOUND
,messageStringId= CUSTOM_API_ERROR_RESPONSE_CODE_TOUR_NOT_FOUND_MESSAGE_ID)
class UnknownCustomApiException(code: Int, @StringRes messageStringId: Int?)
class UnknownCustomApiException(code: Int, @StringRes messageStringId: Int?, apiMessage:String?)
: CustomApiException(code,messageStringId,apiMessage)
}
//as an agreement error message should be correct for user (and localized, if needed) on server-side
fun parseException(err: ErrorRaw) =
CustomApiException.UnknownCustomApiException(err.code, null)
CustomApiException.UnknownCustomApiException(err.code, null, err.message)
......@@ -2,6 +2,7 @@ package com.biganto.visual.roompark.domain.interactor
import com.biganto.visual.roompark.domain.model.*
import com.biganto.visual.roompark.domain.use_case.FeedUseCase
import io.reactivex.Observable
import io.reactivex.Single
import java.util.*
import javax.inject.Inject
......@@ -14,10 +15,10 @@ class FeedsInteractor @Inject constructor(
private val feedsUseCase:FeedUseCase
) {
fun fetchTopFeeds(): Single<FeedsHeaderModel> =
fun fetchTopFeeds(): Observable<FeedsHeaderModel> =
feedsUseCase.getFeeds().map {
FeedsHeaderModel(it)
}.single(FeedsHeaderModel(arrayListOf()))
}
//Single.just(testFeeds)
fun fetchArticles(feedId: Int): Single<ArticlesPreviewModel> = Single.just(
......
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