Last active
April 1, 2020 22:47
-
-
Save hissain/35513214fa7eac6ec9ecf0808bb2573e to your computer and use it in GitHub Desktop.
Service Builder Class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import okhttp3.OkHttpClient | |
import retrofit2.Retrofit | |
import retrofit2.converter.gson.GsonConverterFactory | |
object ServiceBuilder { | |
private val client = OkHttpClient.Builder().build() | |
private val retrofit = Retrofit.Builder() | |
.baseUrl("http://api.server.com") // change this IP for testing by your actual machine IP | |
.addConverterFactory(GsonConverterFactory.create()) | |
.client(client) | |
.build() | |
fun<T> buildService(service: Class<T>): T{ | |
return retrofit.create(service) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment