package com.phlx.anchorcollect_p.data.http;



import com.phlx.anchorcollect_p.entity.BreedingRecordDetailEntity;
import com.phlx.anchorcollect_p.entity.BreedingRecordEntity;
import com.phlx.anchorcollect_p.entity.CattleResumeEntity;
import com.phlx.anchorcollect_p.entity.DictEntity;
import com.phlx.anchorcollect_p.entity.GenData;
import com.phlx.anchorcollect_p.entity.ImmuneBatchDetailEntity;
import com.phlx.anchorcollect_p.entity.ImmuneBatchEntity;
import com.phlx.anchorcollect_p.entity.LoginData;
import com.phlx.anchorcollect_p.entity.MedicalRecordEntity;
import com.phlx.anchorcollect_p.entity.PerformanceEntity;
import com.phlx.anchorcollect_p.entity.WeightManEntity;
import com.phlx.anchorcollect_p.params.BaseResponse;
import com.phlx.anchorcollect_p.params.CollectResponse;
import com.phlx.anchorcollect_p.params.ListResponse;

import java.util.Map;

import io.reactivex.Observable;
import okhttp3.RequestBody;
import retrofit2.http.Body;
import retrofit2.http.FieldMap;

/**
 * Created by goldze on 2019/3/26.
 */
public class HttpDataSourceImpl implements HttpDataSource {
    private ApiService apiService;
    private volatile static HttpDataSourceImpl INSTANCE = null;

    public static HttpDataSourceImpl getInstance(ApiService apiService) {
        if (INSTANCE == null) {
            synchronized (HttpDataSourceImpl.class) {
                if (INSTANCE == null) {
                    INSTANCE = new HttpDataSourceImpl(apiService);
                }
            }
        }
        return INSTANCE;
    }

    public static void destroyInstance() {
        INSTANCE = null;
    }

    private HttpDataSourceImpl(ApiService apiService) {
        this.apiService = apiService;
    }

    @Override
    public Observable<BaseResponse<Double>> versionGet() {
        return apiService.versionGet();
    }

    @Override
    public Observable<BaseResponse> DownloadApp() {
        return apiService.DownloadApp();
    }

    @Override
    public Observable<CollectResponse<LoginData>> loginPost(@FieldMap Map<String, String> map) {
        return apiService.loginPost(map);
    }

    @Override
    public Observable<CollectResponse<GenData>> genGet() {
        return apiService.genGet();
    }

    @Override
    public Observable<ListResponse<CattleResumeEntity>> downloadCattleList(@FieldMap Map<String, String> map) {
        return apiService.downloadCattleList(map);
    }

    @Override
    public Observable<CollectResponse> downloadCattleListSync(@Body RequestBody body) {
        return apiService.downloadCattleListSync(body);
    }

    @Override
    public Observable<ListResponse<Long>> uploadCattleList(RequestBody body) {
        return apiService.uploadCattleList(body);
    }

    @Override
    public Observable<ListResponse<DictEntity>> downloadDict() {
        return apiService.downloadDict();
    }

    @Override
    public Observable<ListResponse<PerformanceEntity>> downloadPerformanceList(Map<String, String> map) {
        return apiService.downloadPerformanceList(map);
    }

    @Override
    public Observable<CollectResponse> downloadPerformanceListSync(RequestBody body) {
        return apiService.downloadPerformanceListSync(body);
    }

    @Override
    public Observable<ListResponse<Long>> uploadPerformanceList(RequestBody body) {
        return apiService.uploadPerformanceList(body);
    }

    @Override
    public Observable<ListResponse<BreedingRecordEntity>> downloadBreedingRecordList(Map<String, String> map) {
        return apiService.downloadBreedingRecordList(map);
    }

    @Override
    public Observable<CollectResponse> downloadBreedingRecordListSync(RequestBody body) {
        return apiService.downloadBreedingRecordListSync(body);
    }

    @Override
    public Observable<ListResponse<Long>> uploadBreedingRecordList(RequestBody body) {
        return apiService.uploadBreedingRecordList(body);
    }

    @Override
    public Observable<ListResponse<BreedingRecordDetailEntity>> downloadBreedingRecordDetailList(Map<String, String> map) {
        return apiService.downloadBreedingRecordDetailList(map);
    }

    @Override
    public Observable<CollectResponse> downloadBreedingRecordDetailListSync(RequestBody body) {
        return apiService.downloadBreedingRecordDetailListSync(body);
    }

    @Override
    public Observable<ListResponse<Long>> uploadBreedingRecordDetailList(RequestBody body) {
        return apiService.uploadBreedingRecordDetailList(body);
    }

    @Override
    public Observable<ListResponse<WeightManEntity>> downloadWeightManList(Map<String, String> map) {
        return apiService.downloadWeightManList(map);
    }

    @Override
    public Observable<CollectResponse> downloadWeightManListSync(RequestBody body) {
        return apiService.downloadWeightManListSync(body);
    }

    @Override
    public Observable<ListResponse<Long>> uploadWeightManList(RequestBody body) {
        return apiService.uploadWeightManList(body);
    }

    @Override
    public Observable<ListResponse<MedicalRecordEntity>> downloadMedicalRecordList(Map<String, String> map) {
        return apiService.downloadMedicalRecordList(map);
    }

    @Override
    public Observable<CollectResponse> downloadMedicalRecordListSync(RequestBody body) {
        return apiService.downloadMedicalRecordListSync(body);
    }

    @Override
    public Observable<ListResponse<Long>> uploadMedicalRecordList(RequestBody body) {
        return apiService.uploadMedicalRecordList(body);
    }

    @Override
    public Observable<ListResponse<ImmuneBatchEntity>> downloadImmuneBatchList(Map<String, String> map) {
        return apiService.downloadImmuneBatchList(map);
    }

    @Override
    public Observable<CollectResponse> downloadImmuneBatchListSync(RequestBody body) {
        return apiService.downloadImmuneBatchListSync(body);
    }

    @Override
    public Observable<ListResponse<Long>> uploadImmuneBatchList(RequestBody body) {
        return apiService.uploadImmuneBatchList(body);
    }

    @Override
    public Observable<ListResponse<ImmuneBatchDetailEntity>> downloadImmuneBatchDetailList(Map<String, String> map) {
        return apiService.downloadImmuneBatchDetailList(map);
    }

    @Override
    public Observable<CollectResponse> downloadImmuneBatchDetailListSync(RequestBody body) {
        return apiService.downloadImmuneBatchDetailListSync(body);
    }

    @Override
    public Observable<ListResponse<Long>> uploadImmuneBatchDetailList(RequestBody body) {
        return apiService.uploadImmuneBatchDetailList(body);
    }

    @Override
    public Observable<CollectResponse> uploadErrorData(RequestBody body) {
        return apiService.uploadErrorData(body);
    }
}
