package com.zxhl.main.page.presenter

import android.util.Log
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.chat.ChatRoomEntity
import com.zxhl.cms.net.model.chat.RoomTypeEntity
import com.zxhl.cms.net.model.chat.ToCreateRoomEntity
import com.zxhl.main.page.contract.CreateRoomContract

class CreateRoomPresenter :CreateRoomContract.Presenter{
    private val mView: CreateRoomContract.View


    constructor(mView: CreateRoomContract.View) {
        this.mView = mView
    }
    override fun getTab() {

    }

    override fun toCreateRoom() {
        ApiClient.chatApi.toCreateRoom().compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<ToCreateRoomEntity>() {
                override fun onSuccess(result: ToCreateRoomEntity?) {
                    mView.setData(result)
                }

                override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
                    Log.e("MXL", "ERROR" + code + errorMsg)

                }
            })
    }

    override fun createRoom(entity:ChatRoomEntity?) {
        ApiClient.chatApi.createRoom(entity).compose(RxSchedulers.observableIO2Main())
            .subscribe(object : BaseObserver<ChatRoomEntity>() {
                override fun onSuccess(result: ChatRoomEntity?) {

                }

                override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
                    Log.e("MXL", "ERROR" + code + errorMsg)

                }
            })
    }

}