package com.bc_chat.contacts.task

import com.bc_chat.bc_base.http.Encryption
import com.bc_chat.bc_base.http.RetrofitHelper
import com.google.gson.JsonObject
import com.zhaohaoting.framework.abs.entity.ResultEntity
import com.zhaohaoting.framework.abs.task.RxDataAsyncTask
import io.reactivex.Flowable

/**
 * author：Created by zhaohaoting on 2019/3/5
 * email：526309416@qq.com
 * desc：修改群信息
 */
class SetGroupInfoTask constructor(var groupId: String, var uids: String, var userName: String, var group_name: String?, var photo: String?, var introduction: String?, var notice: String?, var type: String?) : RxDataAsyncTask<JsonObject, ResultEntity<JsonObject>>() {

    override fun loadDataAsyncTask(): Flowable<ResultEntity<JsonObject>>? {
        val params: MutableMap<String, Any?> = mutableMapOf("groupId" to groupId, "uids" to uids, "userName" to userName)
        if (!group_name.isNullOrEmpty()) params["group_name"] = group_name;
        if (!photo.isNullOrEmpty()) params["photo"] = photo;
        if (!introduction.isNullOrEmpty()) params["introduction"] = introduction;
        if (!notice.isNullOrEmpty()) params["notice"] = notice;
        if (!type.isNullOrEmpty()) params["type"] = type;
        return RetrofitHelper.api.setGroupInfo(Encryption.encryption(params))
    }
}
