package com.bc_chat.mine.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 UpdateUserInfoTask constructor(var nickname: String? = null, var photo: String? = null, var introduction: String? = null, var province: String? = null, var city: String? = null) : RxDataAsyncTask<JsonObject, ResultEntity<JsonObject>>() {

    override fun loadDataAsyncTask(): Flowable<ResultEntity<JsonObject>>? {
        val params: MutableMap<String, Any?> = mutableMapOf()
        if (!nickname.isNullOrEmpty()) params["nickname"] = nickname;
        if (!photo.isNullOrEmpty()) params["photo"] = photo;
        if (!introduction.isNullOrEmpty()) params["introduction"] = introduction;
        if (!province.isNullOrEmpty()) params["province"] = province;
        if (!city.isNullOrEmpty()) params["city"] = city;
        return RetrofitHelper.api.savePersonalData(Encryption.encryption(params))
    }
}
