package ru.myitschool.work.data.network;

import static ru.myitschool.work.core.Constants.SERVER_ADDRESS;

import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
import ru.myitschool.work.data.network.api.AdminApi;
import ru.myitschool.work.data.network.api.EmployeeApi;

public class RetrofitFactory {

    private static RetrofitFactory INSTANCE;

    private RetrofitFactory() {
    }

    public static synchronized RetrofitFactory getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new RetrofitFactory();
        }
        return INSTANCE;
    }

    private final Retrofit retrofit = new Retrofit.Builder()
            .baseUrl(SERVER_ADDRESS)
            .addConverterFactory(GsonConverterFactory.create())
            .build();

    public EmployeeApi getEmployeeApi() {
        return retrofit.create(EmployeeApi.class);
    }

    public AdminApi getAdminApi() {
        return retrofit.create(AdminApi.class);
    }
}
