-
Notifications
You must be signed in to change notification settings - Fork 16
Persist on the network (with Retrofit)
xcesco edited this page May 4, 2018
·
2 revisions
There are many libraries that permit to generate REST service client easily. The one that I prefer is Retrofit.
So, I decide to integrate Kripton with Retrofit, just to use Kripton persistence mechanism in Retrofit library. I want to show you here how simple is to work with them.
For example, we want to consume the REST service at
https://jsonplaceholder.typicode.com/posts/
So we define a Post class with Kripton BindType annotation
@BindType
public class Post {
public long userId;
public long id;
public String title;
public String body;
}
We can define the REST client interface:
public interface JsonPlaceHolderService {
@POST("/posts/")
Call<List<Post>> getAllPost();
}
The code to consume the REST service is:
// create retrofit using Kripton converter factory
Retrofit retrofit = new Retrofit.Builder()
.baseUrl(“https://jsonplaceholder.typicode.com/")
.addConverterFactory(KriptonBinderConverterFactory.create())
.build();
JsonPlaceHolderService service = Retrofit.create(JsonPlaceHolderService.class);
// consume service
Response<List<Post>> response = service.getAllPost().execute();
The integration between Kripton and Retrofit is done by KriptonBinderConverterFactoryconverter.
- Introduction
- Goals & Features
- Kotlin
- Immutable or Mutable Pojo
- Annotation Processor Args
- Credits
- Articles
- Benchmarks
- Setup
- Tutorial
- Usage
- Dependencies and inspirations
- Stackoverflow
- Documentation
- SQL logging
- Data source options
- Indices
- SQL Type adapter
- Global SQL Type adapter
- Constraints
- Live data: welcome Architectural components!!
- Paged Live data
- Dynamic parts
- Transactional and batch operations
- Async Transactional and batch operations
- Global transaction
- Support for immutable POJO
- Generate Content provider
- Generate Database schema generation
- Database migration
- BindSqlColumn
- BindContentProvider
- BindContentProviderEntry
- BindContentProviderPath
- BindDao
- BindDaoMany2Many
- BindDataSource
- BindDataSourceOptions
- BindDataSourceUpdateTask
- BindIndex
- BindSqlRelation
- BindSqlAdapter
- BindSqlChildSelect
- BindSqlDelete
- BindSqlDynamicOrderBy
- BindSqlDynamicWhere
- BindSqlDynamicWhereParams
- BindSqlInsert
- BindSqlPageSize
- BindSqlParam
- BindSqlSelect
- BindSqlUpdate
- BindSqlType
- BindSqlTransaction