Add BoardService implementation. #3
@ -1,51 +0,0 @@
|
||||
package wekan.wrapper.api;
|
||||
|
||||
import okhttp3.Interceptor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
import org.junit.Test;
|
||||
import retrofit2.Retrofit;
|
||||
import retrofit2.converter.gson.GsonConverterFactory;
|
||||
import wekan.wrapper.entity.Board;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class BoardServiceTestX {
|
||||
|
||||
@Test
|
||||
public void test() {
|
||||
|
||||
OkHttpClient.Builder httpClient = new OkHttpClient.Builder();
|
||||
|
||||
httpClient.addInterceptor(new Interceptor() {
|
||||
@Override
|
||||
public Response intercept(Chain chain) throws IOException {
|
||||
Request request = chain.request().newBuilder()
|
||||
.addHeader("Authorization", "Bearer GC0ibjF-5OlYczYe6WKCXX_72MtXVC-OEUK4puf9VeI")
|
||||
.addHeader("Accept", "application/json")
|
||||
.build();
|
||||
return chain.proceed(request);
|
||||
}
|
||||
});
|
||||
|
||||
Retrofit retrofit = new Retrofit.Builder()
|
||||
.baseUrl("https://board.norangeb.it")
|
||||
.addConverterFactory(GsonConverterFactory.create())
|
||||
.client(httpClient.build())
|
||||
.build();
|
||||
|
||||
BoardService boardService = retrofit.create(BoardService.class);
|
||||
|
||||
try {
|
||||
List<Board> list = boardService.getPublicBoard().execute().body();
|
||||
for (Board b : list){
|
||||
System.out.println(b.getId());
|
||||
System.out.println(b.getTitle());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user