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.

85 lines
3.0KB

  1. import 'package:dio/dio.dart';
  2. import 'package:farm_tpf/custom_model/CropPlot.dart';
  3. import 'package:farm_tpf/custom_model/Device.dart';
  4. import 'package:farm_tpf/custom_model/EnvironmentParameter.dart';
  5. import 'package:farm_tpf/custom_model/Harvest.dart';
  6. import 'package:farm_tpf/custom_model/WaterType.dart';
  7. import 'package:farm_tpf/custom_model/account.dart';
  8. import 'package:farm_tpf/custom_model/password.dart';
  9. import 'package:farm_tpf/custom_model/user.dart';
  10. import 'package:farm_tpf/custom_model/user_request.dart';
  11. import 'package:farm_tpf/models/Supply.dart';
  12. import 'package:farm_tpf/models/index.dart';
  13. import 'package:farm_tpf/utils/const_common.dart';
  14. import 'package:retrofit/retrofit.dart';
  15. part 'rest_client.g.dart';
  16. @RestApi(baseUrl: ConstCommon.baseUrl)
  17. abstract class RestClient {
  18. factory RestClient(Dio dio, {String baseUrl}) = _RestClient;
  19. @POST("/api/authenticate")
  20. Future<User> login(@Body() UserRequest userRequest);
  21. @GET("/api/account")
  22. Future<Account> getMe();
  23. @POST("/api/account/reset-password/init")
  24. Future<void> forgotPassword(@Body() String email);
  25. @POST("/api/account/reset-password/finish")
  26. Future<void> resetPassword(@Body() Password password);
  27. @POST("/api/account/change-password")
  28. Future<void> changePassword(@Body() Password password);
  29. @PUT("/api/update-my-profile")
  30. Future<Account> updateProfile(@Body() Account account);
  31. @GET("/api/tb-supplies-by-type/{type}")
  32. Future<List<Supply>> getSupplies(@Path() String type);
  33. //Common
  34. @PUT("/api/update-fcmToken")
  35. Future<void> updateFcmToken(@Body() String token);
  36. @PUT("/api/delete-fcmToken")
  37. Future<void> deleteFcmToken(@Body() String token);
  38. @GET("/api/tb-crops?page={page}&size={size}&query={query}")
  39. Future<List<Crop>> getPlots(
  40. {@Path() int page = 0, @Path() int size = 20, @Path() String query = ""});
  41. @GET("/api/listActivityTypesOther")
  42. Future<List<ActionType>> getActionTypes({@DioOptions() Options options});
  43. @GET("/api/water-types")
  44. Future<List<WaterType>> getWaterTypes({@DioOptions() Options options});
  45. @GET("/api/tb-harvests")
  46. Future<List<Harvest>> getHarvests({@DioOptions() Options options});
  47. //Crop
  48. @GET(
  49. "/api/tb-crops-detail-for-app/{cropId}?page={page}&size={size}&sort=executeDate,DESC")
  50. Future<CropPlot> getCropDetail(@Path() int cropId,
  51. {@Path() int page = 0, @Path() int size = 20});
  52. @GET(
  53. "/api/tb-crops-scan-qrCode/{cropCode}?page={page}&size={size}&sort=executeDate,DESC")
  54. Future<CropPlot> getCropDetailByCode(@Path() String cropCode,
  55. {@Path() int page = 0, @Path() int size = 20});
  56. @PUT("/api/tb-crops")
  57. Future<void> updateCrop(@Body() TbCropDTO crop);
  58. //Device
  59. @GET("/api/listDeviceOfUserCustomers")
  60. Future<List<Device>> getDevices();
  61. //Get environment parameter
  62. @GET("/api/list-environment-updates-display/{cropId}?page={page}&size={size}")
  63. Future<List<EnvironmentParameter>> getEnvironmentParameters(
  64. @Path() int cropId,
  65. {@Path() int page = 0,
  66. @Path() int size = 20});
  67. }