package com.phlx.wool.data.http;



import com.phlx.wool.entity.DivisionEntity;
import com.phlx.wool.entity.Harmless;
import com.phlx.wool.entity.Label;
import com.phlx.wool.entity.Marking;
import com.phlx.wool.entity.Quarantine;
import com.phlx.wool.entity.Unit;
import com.phlx.wool.entity.User;
import com.phlx.wool.entity.Veterinary;
import com.phlx.wool.entity.VillusBuyEntity;
import com.phlx.wool.entity.VillusGaugeEntity;
import com.phlx.wool.params.BasicParams;
import com.phlx.wool.params.CattleResponse;

import java.util.List;

import io.reactivex.Observable;
import okhttp3.RequestBody;

/**
 * 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<CattleResponse> versionGet() {
        return apiService.versionGet();
    }

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

    @Override
    public Observable<CattleResponse<User>> loginPost(RequestBody body) {
        return apiService.loginPost(body);
    }

    @Override
    public Observable<CattleResponse<BasicParams>> getBasicInfo(RequestBody body) {
        return apiService.getBasicInfo(body);
    }

    @Override
    public Observable<CattleResponse<List<Label>>> getLabelList(RequestBody body) {
        return apiService.getLabelList(body);
    }

    @Override
    public Observable<CattleResponse<List<Unit>>> getUnitList(RequestBody body) {
        return apiService.getUnitList(body);
    }

    @Override
    public Observable<CattleResponse<List<Veterinary>>> getVeterinaryList(RequestBody body) {
        return apiService.getVeterinaryList(body);
    }

    @Override
    public Observable<CattleResponse<List<VillusBuyEntity>>> getVillusBuyList(RequestBody body) {
        return apiService.getVillusBuyList(body);
    }

    @Override
    public Observable<CattleResponse<List<DivisionEntity>>> getDivisionList(RequestBody body) {
        return apiService.getDivisionList(body);
    }

    @Override
    public Observable<CattleResponse<List<Marking>>> submitMarking(RequestBody body) {
        return apiService.submitMarking(body);
    }

    @Override
    public Observable<CattleResponse<List<VillusBuyEntity>>> submitVillusBuy(RequestBody body) {
        return apiService.submitVillusBuy(body);
    }

    @Override
    public Observable<CattleResponse<List<VillusGaugeEntity>>> submitVillusGauge(RequestBody body) {
        return apiService.submitVillusGauge(body);
    }

    @Override
    public Observable<CattleResponse<List<Quarantine>>> submitQuarantine(RequestBody body) {
        return apiService.submitQuarantine(body);
    }

    @Override
    public Observable<CattleResponse<List<Harmless>>> submitHarmless(RequestBody body) {
        return apiService.submitHarmless(body);
    }


}
