package com.tsi.navi.service.download;

import okhttp3.ResponseBody;
import retrofit2.Call;
import retrofit2.Retrofit;
import retrofit2.http.GET;
import retrofit2.http.Streaming;
import retrofit2.http.Url;

public class ApiDownloadService {

    interface ApiService {
        @GET
        @Streaming
        Call<ResponseBody> downloadFile(@Url String url);
    }

    private ApiService apiService;
    private String downloadUrl;

    private ApiDownloadService(String downloadUrl) {
        this.downloadUrl = downloadUrl;
        Retrofit retrofit = new Retrofit.Builder().baseUrl(downloadUrl).build();
        this.apiService = retrofit.create(ApiService.class);
    }

    public static ApiDownloadService getInstance() {
        return Holder.apiService;
    }

    private static class Holder {
        public static final ApiDownloadService apiService = new ApiDownloadService("");
    }
}
