package com.bc_chat.account.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 RegisterTask constructor(var phone: String, var password: String, var photo: String?, var nickname: String?, var introduction: String?, var province: String?, var city: String?)
    : RxDataAsyncTask<JsonObject, ResultEntity<JsonObject>>() {

    //    phone	string	是	手机号
//    password	string	是	密码
//    photo	string	否	头像
//    nickname	string	否	昵称
//    introduction	string	否	个人简介
//    province	string	否	省份
//    city	string	否	城市
    override fun loadDataAsyncTask(): Flowable<ResultEntity<JsonObject>>? {
        val params: MutableMap<String, Any?> = mutableMapOf("phone" to phone, "password" to password)
        if (!photo.isNullOrEmpty()) params["photo"] = photo
        if (!nickname.isNullOrEmpty()) params["nickname"] = nickname
        if (!introduction.isNullOrEmpty()) params["introduction"] = introduction
        if (!province.isNullOrEmpty()) params["province"] = province
        if (!city.isNullOrEmpty()) params["city"] = city
        return RetrofitHelper.api.register(Encryption.encryption(params))
    }
}
