You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.8KB

  1. import 'package:dio/dio.dart';
  2. import 'package:farm_tpf/custom_model/CropPlot.dart';
  3. import 'package:farm_tpf/custom_model/account.dart';
  4. import 'package:farm_tpf/custom_model/password.dart';
  5. import 'package:farm_tpf/custom_model/user.dart';
  6. import 'package:farm_tpf/custom_model/user_request.dart';
  7. import 'package:farm_tpf/models/Supply.dart';
  8. import 'package:farm_tpf/models/index.dart';
  9. import 'package:farm_tpf/utils/const_common.dart';
  10. import 'package:retrofit/retrofit.dart';
  11. part 'rest_client.g.dart';
  12. @RestApi(baseUrl: ConstCommon.baseUrl)
  13. abstract class RestClient {
  14. factory RestClient(Dio dio, {String baseUrl}) = _RestClient;
  15. @POST("/api/authenticate")
  16. Future<User> login(@Body() UserRequest userRequest);
  17. @GET("/api/account")
  18. Future<Account> getMe();
  19. @POST("/api/account/reset-password/init")
  20. Future<void> forgotPassword(@Body() String email);
  21. @POST("/api/account/reset-password/finish")
  22. Future<void> resetPassword(@Body() Password password);
  23. @POST("/api/account/change-password")
  24. Future<void> changePassword(@Body() Password password);
  25. @PUT("/api/update-my-profile")
  26. Future<Account> updateProfile(@Body() Account account);
  27. @GET("/api/tb-supplies-by-type/{type}")
  28. Future<List<Supply>> getSupplies(@Path() String type);
  29. //Common
  30. @PUT("/api/update-fcmToken")
  31. Future<void> updateFcmToken(@Body() String token);
  32. @GET("/api/tb-crops?page={page}&size={size}&query={query}")
  33. Future<List<Crop>> getPlots(
  34. {@Path() int page = 0, @Path() int size = 20, @Path() String query = ""});
  35. @GET("/api/listActivityTypesOther")
  36. Future<List<ActionType>> getActionTypes();
  37. //Crop
  38. @GET(
  39. "/api/tb-crops-detail/{cropId}?page={page}&size={size}&sort=executeDate,DESC")
  40. Future<CropPlot> getCropDetail(@Path() int cropId,
  41. {@Path() int page = 0, @Path() int size = 20});
  42. }