Discord: UnLegit#6190
@Data
@FieldDefaults(level = AccessLevel.PRIVATE)
public class User {
final long id;
final String name;
double balance;
}
Creating service hook (you can use the entity as a return type, but I recommend using RestResponse, because you can use it to process the status returned by the server)
@RequestPath("127.0.0.1:1000/user")
public interface UserServiceHook {
@RequestMethod(HttpMethod.POST)
RestResponse<User> register(@Param("name") String name);
@RequestMethod(HttpMethod.GET)
RestResponse<User> get(@Path String name);
@RequestMethod(HttpMethod.PATCH)
RestResponse<Void> save(@Body User user);
}
Creating HTTP request executor (you can create you own request executor and json codec implementations)
RequestExecutor requestExecutor = new OkHttpRequestExecutor(new GsonCodec(new Gson()));
UserServiceHook userServiceHook = requestExecutor.implementHook(UserServiceHook.class);