package com.quansu.heifengwuliu.utils.net

import com.quansu.heifengwuliu.model.*
import io.reactivex.Observable
import retrofit2.http.*
import java.util.*

/**
 * Created by xianguangjin on 16/5/18.
 */
interface ApiService {


    @POST("task/save")
    @FormUrlEncoded
    fun addTodo(@Field("title") title: String?): Observable<Response<Any>>

    @POST("alipay/order_info")
    @FormUrlEncoded
    fun alipayPreOrder(@Field("vip_level") vip_level: Int): Observable<Response<String>>


    @GET("task/ls")
    fun taskList(@Query("action") action: String?, @Query("page") page: Int): Observable<Response<ArrayList<Todo>>>


    @POST("bac")
    @FormUrlEncoded
    fun bac(@Field("settings") settings: String?, @Field("funcs") funcsJson: String?, @Field("searchs") searchJson: String?, @Field("gesture") gestureJson: String?): Observable<Response<String>>

    @POST("task/save")
    @FormUrlEncoded
    fun taskSave(@Field("id") id: Int, @FieldMap params: HashMap<String?, Any?>?): Observable<Response<String>>

    @POST("task/checked")
    @FormUrlEncoded
    fun taskChecked(@Field("id") id: Int): Observable<Response<Any>>


    @GET("user/logout")
    fun logout(): Observable<Response<Any>>

    @GET("order/submmit")
    fun order_submmit(): Observable<Response<String>>

    @POST("order/active")
    @FormUrlEncoded
    fun active(@Field("code") code: String?): Observable<Response<Any>>

    @GET("func/getFuncIcon")
    fun getFuncIcon(@Query("host") host: String?): Observable<Response<String>>

//    ------------


    @POST("api/common/getOssSign")
    @FormUrlEncoded
    fun getSignedUrl(@Field("type") type: String?): Observable<Response<ImageSign>>


    /**
     * 获取验证码
     *
     * @return
     */
    @POST("api/index/loginSms")
    @FormUrlEncoded
    fun getRegisterCode(@Field("mobile") mobile: String?): Observable<Response<SendSmsBean>>


    /**
     * 获取验证码-注册
     *
     * @return
     */
    @POST("api/index/sendSms")
    @FormUrlEncoded
    fun getRegisterSms(@Field("mobile") mobile: String?): Observable<Response<SendSmsBean>>


    /**
     * 极光一键登录
     *
     * @return
     */
    @POST("api/index/jiguangLogin")
    @FormUrlEncoded
    fun jiguangLogin(@Field("loginToken") loginToken: String): Observable<Response<LoginBean>>

    /**
     * 注册
     *
     * @return
     */

    @POST("api/index/register")
    @FormUrlEncoded
    fun register(@Field("name") name: String?, @Field("mobile") mobile: String?, @Field("code") code: String?, @Field("type") type: String?, @Field("openid") openid: String? = null, @Field("unionid") unionId: String? = null): Observable<Response<LoginBean>>


    /**
     *密码登录
     *
     * @return
     */
    @POST("api/index/pwdLogin")
    @FormUrlEncoded
    fun login(@Field("mobile") mobile: String?, @Field("pwd") pwd: String?): Observable<Response<LoginBean>>

    /**
     *短信登录
     *
     * @return
     */
    @POST("api/index/smslogin")
    @FormUrlEncoded
    fun smsLogin(@Field("mobile") mobile: String?, @Field("code") code: String?): Observable<Response<LoginBean>>

    /**
     *微信登录
     *
     * @return
     */
    @POST("api/index/wxLogin")
    @FormUrlEncoded
    fun wxLogin(@Field("code") code: String?): Observable<Response<LoginBean>>


    /**
    简易版注册
     *
     * @return
     */
    @POST("api/index/siml_register")
    @FormUrlEncoded
    fun simlRegister(@Field("mobile") mobile: String?, @Field("type") type: String?): Observable<Response<LoginBean>>

    /**
     * 用户信息
     * @return
     */
    @GET("api/user/getuserinfo")
    fun getUser(): Observable<Response<User>>

    /**
     * 地址列表
     * @return
     */
    @GET("api/address/addressList")
    fun addressList(@Query("type") type: String?,
                    @Query("k") k: String, @Query("p") p: Int): Observable<Response<ArrayList<AddressBean>>>


    /**
     * 获取区域
     * @return
     */
    @GET("api/common/getArea")
    fun getArea(@Query("code") code: String?, @Query("page") page: Int): Observable<Response<ArrayList<AreaBean>>>


    /**
     * 添加编辑地址
     *
     * @return
     */
    @POST("api/address/addressEdit")
    @FormUrlEncoded
    fun addressEdit(@Field("addr_id") addr_id: String?, @Field("lat") lat: String?,
                    @Field("lng") lng: String?, @Field("province") province: String?,
                    @Field("city") city: String?, @Field("area") area: String?,
                    @Field("address") address: String?, @Field("name") name: String?,
                    @Field("mobile") mobile: String?, @Field("type") type: String?,
                    @Field("is_default") is_default: String?): Observable<Response<Any>>



    /**
     * 获取详情-地址
     * @return
     */
    @GET("api/address/addressGet")
    fun getAddress(@Query("addr_id") addr_id: String?): Observable<Response<AddressDetailsBean>>



    /**
     * 删除-地址
     * @return
     */
    @GET("api/address/addressDel")
    fun setAddressDel(@Query("addr_id") addr_id: String?): Observable<Response<Any>>

    /**
     * 获取详情
     * @return
     */
    @GET("api/info/infoGet")
    fun infoGet(@Query("info_id") info_id: String?): Observable<Response<DataInfoBean>>


    /**
     * 添加编辑信息-货源管理
     * @return
     */
    @POST("api/info/infoEdit")
    @FormUrlEncoded
    fun infoEdit(@Field("info_id") info_id: String?,
                 @Field("type_id") type_id: String?,
                 @Field("total") total: String?,
                 @Field("driver") driver: String?,
                 @Field("nums") nums: String?,
                 @Field("is_public") is_public: String?,
                 @Field("is_insurance") is_insurance: String?,
                 @Field("type") type: String?,
                 @Field("data") data: String?,
                 @Field("send") send: String?,
                 @Field("receive") receive: String?
    ): Observable<Response<InfoEditBean>>



    /**
     * 货源支付
     * @return
     */
    @POST("api/info/infoPay")
    @FormUrlEncoded
    fun infoGetPay(@Field("info_id") info_id: String?,@Field("pay_pwd") pay_pwd: String?): Observable<Response<Any>>


    /**
     * 货源取消
     * @return
     */
    @GET("api/info/infoCancel")
    fun infoCancel(@Query("info_id") info_id: String?): Observable<Response<Any>>

    /**
     * 货源列表
     * @return
     */
    @GET("api/info/infoList")
    fun infoList(@Query("info_state") info_state: String?, @Query("p") p: Int): Observable<Response<ArrayList<InfoListBean>>>


    /**
     * 常用司机
     * @return
     */
    @GET("api/driver/myDriver")
    fun myDriver(@Query("k") k: String?, @Query("p") p: Int): Observable<Response<ArrayList<DriverBean>>>


    /**
     * 所有司机
     * @return
     */
    @GET("api/driver/allDriver")
    fun allDriver(@Query("k") k: String?, @Query("p") p: Int): Observable<Response<ArrayList<DriverBean>>>

    /**
     * 常用司机-添加收藏
     * @return
     */
    @POST("api/driver/setDriver")
    @FormUrlEncoded
    fun setDriver(@Field("arr") arr: String): Observable<Response<Any>>



    /**
     * 身份认证
     * @return
     */
    @POST("api/user/setInfo")
    @FormUrlEncoded
    fun setInfo(@Field("idcard_z") idcard_z: String?, @Field("idcard_f") idcard_f: String?,
                @Field("name") name: String?, @Field("idcard") idcard: String?
    ): Observable<Response<Any>>



    /**
     * 获取信息-认证信息 身份 车辆 公司
     * @return
     */
    @GET("api/user/getInfo")
    fun getInfo(@Query("type") type: String?): Observable<Response<InfoBean>>


    /**
     * 公司认证
     * @return
     */
    @POST("api/user/setCompany")
    @FormUrlEncoded
    fun setCompany(@Field("license_img") license_img: String?, @Field("license_sn") license_sn: String?,
                @Field("company_name") company_name: String?
    ): Observable<Response<Any>>



    /**
     * 密码/支付密码
     * @return
     */
    @POST("api/user/setPwd")
    @FormUrlEncoded
    fun setPwd(@Field("oldpwd") oldpwd: String?, @Field("newpwd") newpwd: String?,
                @Field("type") type: String?): Observable<Response<Any>>



}
