-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathApiService.java
More file actions
34 lines (28 loc) · 857 Bytes
/
ApiService.java
File metadata and controls
34 lines (28 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package io.psisoft.codechallenge.api;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
/* Singleton class
* for Retrofit
*/
public class ApiService {
private static final String BASE_URL = "https://api.github.com/";
private static ApiService mInstance;
private Retrofit retrofit;
// private constructor
private ApiService(){
retrofit = new Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(GsonConverterFactory.create())
.build();
}
// Get Retrofit instance
public static synchronized ApiService getInstance(){
if(mInstance == null){
mInstance = new ApiService();
}
return mInstance;
}
public ApiHelper getApiHelper(){
return retrofit.create(ApiHelper.class);
}
}