package com.develop.food.base.http


class BaseRetrofit<T>(var tClass: Class<T>, var factory: HttpFactory) : RetrofitWrapper<T> {
    private var service: T? = null
    private var retrofit = factory.retrofit
    private var baseUrl = factory.baseUrl

    init {
        initRetrofit(tClass)
    }

    override fun initRetrofit(tClass: Class<T>) {
        if (!baseUrl.endsWith("/")) {
            baseUrl += "/"
        }
        service = factory.retrofit.create(tClass)
    }

    override fun getSerVice(): T? {
        if (null == service) {
            service = retrofit.create(tClass)
        }
        return service
    }

}