Commit d5f044f7 authored by Vladislav Bogdashkin's avatar Vladislav Bogdashkin 🎣

added subscription use case

parent 61a1f848
package com.biganto.visual.roompark.domain.contract
import io.reactivex.Observable
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
*/
interface DeviceUtilsContract {
fun getDeviceId() : Observable<String>
}
\ No newline at end of file
package com.biganto.visual.roompark.domain.contract
import com.biganto.visual.roompark.data.repository.api.retrofit.raw.StatusResponse
import io.reactivex.Observable
/**
* Created by Vladislav Bogdashkin on 24.09.2019.
*/
......@@ -7,11 +10,13 @@ package com.biganto.visual.roompark.domain.contract
interface SubscriptionContract{
fun subscribeTopic(
deviceToken:String,
topic:String
)
topic:String,
topic_id:String? = null
) : Observable<StatusResponse>
fun unSubscribeTopic(
deviceToken:String,
topic:String
)
topic:String,
topic_id:String? = null
) : Observable<StatusResponse>
}
\ No newline at end of file
package com.biganto.visual.roompark.domain.use_case
import com.biganto.visual.roompark.domain.contract.DeviceUtilsContract
import com.biganto.visual.roompark.domain.contract.SubscriptionContract
import javax.inject.Inject
/**
* Created by Vladislav Bogdashkin on 01.11.2019.
*/
class SubscriptionUseCase @Inject constructor(
private val subscription: SubscriptionContract,
private val utils: DeviceUtilsContract
){
fun subscribeTopic(topic:String, topicId:String?=null) =
utils.getDeviceId()
.flatMap{deviceToken -> subscription.subscribeTopic(
deviceToken,
topic,
topicId
) }
fun unSubscribeTopic(topic:String, topicId:String?=null) =
utils.getDeviceId()
.flatMap{deviceToken -> subscription.unSubscribeTopic(
deviceToken,
topic,
topicId
) }
}
\ 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