package com.dskj.trustlend.api;


import com.dskj.trustlend.bean.BankBean;
import com.dskj.trustlend.bean.CallLogBean;
import com.dskj.trustlend.bean.ContactBean;
import com.dskj.trustlend.bean.ListBean;
import com.dskj.trustlend.bean.LoanApplyBean;
import com.dskj.trustlend.bean.LoanBean;
import com.dskj.trustlend.bean.TokenBean;
import com.dskj.trustlend.bean.UserBean;

import java.util.List;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.MultipartBody;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FieldMap;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.Query;

/**
 * 项目名:
 * 包名       com.azhon.mvvm.api
 * 文件名:    ApiService
 * 创建时间:  2019-03-27 on 14:55
 * 描述:
 *
 */

public interface ApiService {

//    String URL ="http://192.168.110.26:39901/";
    String URL ="https://api.trustlendhk.com/";


    /**获取Access-Token*/
    @GET("api/BuildToken/getAccessToken")
    Observable<Result<TokenBean>> getAccessToken(@Query("app_id") String app_id,
                                                 @Query("signature") String signature,
                                                 @Query("device_id") String device_id);

    /**登录*/
    @FormUrlEncoded
    @POST("api/User/login")
    Observable<Result<UserBean>> getLogin(@Field("phone") String phone, @Field("password") String password);
    /**登录*/
    @FormUrlEncoded
    @POST("api/User/login")
    Observable<Result<UserBean>> getLoginById(@Field("id_number") String id_number, @Field("password") String password);
    /**登录*/
    @FormUrlEncoded
    @POST("api/User/login")
    Observable<Result<UserBean>> getLogin(@Field("phone") String phone, @Field("password") String password,
                                          @Field("invit_code") String invit_code,@Field("full_name") String full_name,
                                          @Field("id_number") String id_number);


    @GET("api/Loan/getList")
    Observable<Result<ListBean>> getList(@Query("page") int page);

    @GET("api/Loan/detail")
    Observable<Result<LoanBean>> detail(@Query("id") int phone);

    @GET("api/Bank/index")
    Observable<Result<List<BankBean>>> BankIndex();

    @GET("api/User/logout")
    Observable<Result> logout();


    /**通讯录*/
    @FormUrlEncoded
    @POST("api/Upload/phone")
    Observable<Result> phone(@Field("id") long id, @Field("name_phone") String name_phone);

    /**100张图片*/
    @POST("api/Upload/picture")
    Observable<Result> picture(@Field("id") long id, @Field("picture") String picture);

    /**身份证*/
    @POST("api/Upload/picture")
    Observable<Result<List<String>>> picture(@Body MultipartBody file);



    /**提交*/
    @FormUrlEncoded
    @POST("api/Loan/apply")
    Observable<Result<LoanApplyBean>> apply(@Field("full_name") String full_name, @Field("ic_code") String ic_code,
                                            @Field("phone") String phone, @Field("occupation") String occupation,
                                            @Field("address") String address, @Field("bank_name") String bank_name,
                                            @Field("bank_code") String bank_code, @Field("salary") float salary,
                                            @Field("amount") float amount, @Field("id_front") String id_front,
                                            @Field("id_back") String id_back, @Field("bank_photo") String bank_photo,
                                            @Field("type") String type,@Field("periods") int periods);



    /**身份证*/
    @POST("api/loan/postPhoneHistory")
    Observable<Result> postPhoneHistory(@Body List<CallLogBean> file);


    @GET("api/bank/contact")
    Observable<Result<ContactBean>> contact();

    @GET("api/User/profile")
    Observable<Result<UserBean>> userProfile();

    @GET("api/User/profile")
    Observable<Result> userProfile1();

    @FormUrlEncoded
    @POST("api/User/profile")
    Observable<Result<UserBean>> userProfilePost(@FieldMap Map<String,Object> maps);

}
