package com.phlx.anchorcollect.data.http;


import com.phlx.anchorcollect.entity.BreedingRecordDetailEntity;
import com.phlx.anchorcollect.entity.BreedingRecordEntity;
import com.phlx.anchorcollect.entity.CattleResumeEntity;
import com.phlx.anchorcollect.entity.DictEntity;
import com.phlx.anchorcollect.entity.GenData;
import com.phlx.anchorcollect.entity.ImmuneBatchEntity;
import com.phlx.anchorcollect.entity.LoginData;
import com.phlx.anchorcollect.entity.MedicalRecordEntity;
import com.phlx.anchorcollect.entity.PerformanceEntity;
import com.phlx.anchorcollect.entity.WeightManEntity;
import com.phlx.anchorcollect.params.CollectResponse;
import com.phlx.anchorcollect.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<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<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<CollectResponse> 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<CollectResponse> 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<CollectResponse> 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<CollectResponse> 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<CollectResponse> 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<CollectResponse> uploadImmuneBatchList(RequestBody body) {
        return apiService.uploadImmuneBatchList(body);
    }
}
