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.

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