package tech.starwin.mvp.api;


import io.reactivex.Observable;
import okhttp3.MultipartBody;
import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Header;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Part;
import retrofit2.http.Query;

import com.common.bean.BasicAck;
import com.common.bean.OcrResultBean;
import com.common.bean.RecordFilesResponse;
import com.common.bean.UploadCollectionBean;

/**
 * Created by SiKang on 2018/9/14.
 * 涉及上传的API
 */
public interface UploadApi {

    /**
     * 上传照片
     *
     * @param fileType 照片类型   KTP_PHOTO：身份证;
     *                 EMPLOYMENT_PHOTO：工作证件;
     *                 CONTRACT_VIDEO：合同;
     */
    @Multipart
    @PUT("record/files")//*Keep*
    Observable<ResponseBody> uploadPhoto(
            @Part MultipartBody.Part photoFile,
            @Query("fileType") String fileType
    );

    @FormUrlEncoded
    @PUT("record/firebase_token")
    Observable<ResponseBody> uploadFirebaseToken(@Field("firebase_token") String token);


//    @Multipart
//    @PUT("loanapp/contract/video")
//    Call<ResponseBody> uploadVideo(@Part MultipartBody.Part videoFile,
//                                   @Query("loanAppId") String loanAppId,
//                                   @Query("fileType") String fileType,
//                                   @Header("X-AUTH-TOKEN") String token);

//    @GET("record/files")
//    Call<RecordFilesResponse> recordFiles(@Header("X-AUTH-TOKEN") String token);

    @Multipart
    /*@PUT("/loanapp/verify/face") face++*/
    @PUT("/loanapp/verify/yitu")
    Observable<BasicAck> faceVerify(@Query("loanType") String loanType,
                                    @Query("amount") double amount,
                                    @Query("period") int period,
                                    @Query("periodUnit") String periodUnit,
                                    @Part MultipartBody.Part imageBest,
                                    @Part MultipartBody.Part imageEnv,
                                    @Part MultipartBody.Part delta,
                                    @Query("imei") String imei,
                                    @Query("productId") long productId,
                                    @Query("thirdpartyDataFlag") Boolean thirdpartyDataFlag,
                                    @Query("method") String method);


    /**
     * 身份证ocr识别
     */
    @Multipart
    @PUT("/record/ocr")//*Keep*
    Observable<OcrResultBean> identityOcr(@Part MultipartBody.Part part);


    /**
     * 上传其他证明图片
     *
     * @param action ADD:添加、 MODIFY：更新 、DELETE：删除
     */
    @Multipart
    @PUT("/record/files-extra")//*Keep*
    Observable<ResponseBody> uploadOtherPhoto(@Part MultipartBody.Part file, @Query("fileType") String fileType, @Query("fileIndex") int fileIndex, @Query("fileAction") String action);

    @POST("/harvest/xtrace/upload/gzip")
    Observable<ResponseBody> uploadContact(@Body UploadCollectionBean bean);
}