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.

124 lines
4.4KB

  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/LocationUnit.dart';
  7. import 'package:farm_tpf/custom_model/Supply.dart';
  8. import 'package:farm_tpf/custom_model/UpdateNoti.dart';
  9. import 'package:farm_tpf/custom_model/WaterType.dart';
  10. import 'package:farm_tpf/custom_model/account.dart';
  11. import 'package:farm_tpf/custom_model/password.dart';
  12. import 'package:farm_tpf/custom_model/user.dart';
  13. import 'package:farm_tpf/custom_model/user_request.dart';
  14. import 'package:farm_tpf/models/index.dart';
  15. import 'package:farm_tpf/utils/const_common.dart';
  16. import 'package:retrofit/retrofit.dart';
  17. part 'rest_client.g.dart';
  18. @RestApi(baseUrl: ConstCommon.baseUrl)
  19. abstract class RestClient {
  20. factory RestClient(Dio dio, {String baseUrl}) = _RestClient;
  21. @POST("/api/authenticate")
  22. Future<User> login(@Body() UserRequest userRequest);
  23. @GET("/api/account")
  24. Future<Account> getMe();
  25. @POST("/api/account/reset-password/init")
  26. Future<void> forgotPassword(@Body() String email);
  27. @POST("/api/account/reset-password/finish")
  28. Future<void> resetPassword(@Body() Password password);
  29. @POST("/api/account/change-password")
  30. Future<void> changePassword(@Body() Password password);
  31. @PUT("/api/update-my-profile")
  32. Future<Account> updateProfile(@Body() Account account);
  33. @GET("/api/list-supplies-in-warehouses/{type}?q={query}")
  34. Future<List<Supply>> getSupplies(@Path() String type,
  35. {@DioOptions() Options options, @Path() String query = ""});
  36. //Common
  37. @PUT("/api/update-fcmToken")
  38. Future<void> updateFcmToken(@Body() String token);
  39. @PUT("/api/delete-fcmToken")
  40. Future<void> deleteFcmToken(@Body() String token);
  41. @GET("/api/tb-crops?page={page}&size={size}&query={query}")
  42. Future<List<Crop>> getPlots(
  43. {@Path() int page = 0, @Path() int size = 20, @Path() String query = ""});
  44. @GET("/api/listActivityTypesOther")
  45. Future<List<ActionType>> getActionTypes({@DioOptions() Options options});
  46. @GET("/api/water-types")
  47. Future<List<WaterType>> getWaterTypes({@DioOptions() Options options});
  48. @GET("/api/tb-harvests")
  49. Future<List<Harvest>> getHarvests({@DioOptions() Options options});
  50. @GET("/api/listDeviceForActivity")
  51. Future<List<Device>> getDeviceForActivity({@DioOptions() Options options});
  52. @PUT("/api/notifications/update-all")
  53. Future<void> updateAllNotification(@Body() String status);
  54. @PUT("/api/notifications/update")
  55. Future<void> updateNoti(@Body() UpdateNoti updateNoti);
  56. @GET("/api/tb-countries?page={page}&size={size}&&sort=name,ASC")
  57. Future<List<LocationUnit>> getCountries(
  58. {@Path() int page = 0,
  59. @Path() int size = 20,
  60. @DioOptions() Options options});
  61. @GET(
  62. "/api/tb-cities-by-country/{countryId}?page={page}&size={size}&&sort=name,ASC")
  63. Future<List<LocationUnit>> getProvinces(@Path() int countryId,
  64. {@Path() int page = 0,
  65. @Path() int size = 20,
  66. @DioOptions() Options options});
  67. @GET(
  68. "/api/tb-districts-by-city/{provinceId}?page={page}&size={size}&&sort=name,ASC")
  69. Future<List<LocationUnit>> getDistricts(@Path() int provinceId,
  70. {@Path() int page = 0,
  71. @Path() int size = 20,
  72. @DioOptions() Options options});
  73. @GET(
  74. "/api/tb-wards-by-district/{districtId}?page={page}&size={size}&&sort=name,ASC")
  75. Future<List<LocationUnit>> getWards(@Path() int districtId,
  76. {@Path() int page = 0,
  77. @Path() int size = 20,
  78. @DioOptions() Options options});
  79. //Crop
  80. @GET(
  81. "/api/tb-crops-detail-for-app/{cropId}?page={page}&size={size}&sort=executeDate,DESC")
  82. Future<CropPlot> getCropDetail(@Path() int cropId,
  83. {@Path() int page = 0, @Path() int size = 20});
  84. @GET(
  85. "/api/tb-crops-scan-qrCode/{cropCode}?page={page}&size={size}&sort=executeDate,DESC")
  86. Future<CropPlot> getCropDetailByCode(@Path() String cropCode,
  87. {@Path() int page = 0, @Path() int size = 20});
  88. @PUT("/api/tb-crops")
  89. Future<void> updateCrop(@Body() TbCropDTO crop);
  90. //Device
  91. @GET("/api/listDeviceOfUserCustomers")
  92. Future<List<Device>> getDevices();
  93. //Get environment parameter
  94. @GET("/api/list-environment-updates-display/{cropId}?page={page}&size={size}")
  95. Future<List<EnvironmentParameter>> getEnvironmentParameters(
  96. @Path() int cropId,
  97. {@Path() int page = 0,
  98. @Path() int size = 20});
  99. }