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 CreateGroupTask constructor(var groupName: String, var userName: String, var uids: String, var photo: String?) : RxDataAsyncTask<JsonObject, ResultEntity<JsonObject>>() {
    /*
    * groupName	string	是	群组名称
    * uids	string	是	群组用户id集合，英文逗号分隔
    * userName	string	是	群主昵称
    * */
    override fun loadDataAsyncTask(): Flowable<ResultEntity<JsonObject>>? {
        val params: MutableMap<String, Any?> = mutableMapOf("groupName" to groupName, "userName" to userName, "uids" to uids)
        if (!photo.isNullOrEmpty())params["photo"] = photo
        return RetrofitHelper.api.createGroup(Encryption.encryption(params))
    }
}
