package com.quansu.heifengwuliu.utils.net

import com.quansu.heifengwuliu.model.LoginBean
import com.quansu.heifengwuliu.model.SendSmsBean
import com.quansu.heifengwuliu.model.Todo
import com.quansu.heifengwuliu.model.User
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>>

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

    /**
     * 获取验证码
     *
     * @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("page") page: Int): Observable<Response<ArrayList<Todo>>>


}
