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.

86 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/Supply.dart';
  7. import 'package:farm_tpf/custom_model/WaterType.dart';
  8. import 'package:farm_tpf/custom_model/account.dart';
  9. import 'package:farm_tpf/custom_model/password.dart';
  10. import 'package:farm_tpf/custom_model/user.dart';
  11. import 'package:farm_tpf/custom_model/user_request.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/list-supplies-in-warehouses/ALL?q={query}")
  32. Future<List<Supply>> getSupplies(
  33. {@DioOptions() Options options, @Path() String query = ""});
  34. //Common
  35. @PUT("/api/update-fcmToken")
  36. Future<void> updateFcmToken(@Body() String token);
  37. @PUT("/api/delete-fcmToken")
  38. Future<void> deleteFcmToken(@Body() String token);
  39. @GET("/api/tb-crops?page={page}&size={size}&query={query}")
  40. Future<List<Crop>> getPlots(
  41. {@Path() int page = 0, @Path() int size = 20, @Path() String query = ""});
  42. @GET("/api/listActivityTypesOther")
  43. Future<List<ActionType>> getActionTypes({@DioOptions() Options options});
  44. @GET("/api/water-types")
  45. Future<List<WaterType>> getWaterTypes({@DioOptions() Options options});
  46. @GET("/api/tb-harvests")
  47. Future<List<Harvest>> getHarvests({@DioOptions() Options options});
  48. //Crop
  49. @GET(
  50. "/api/tb-crops-detail-for-app/{cropId}?page={page}&size={size}&sort=executeDate,DESC")
  51. Future<CropPlot> getCropDetail(@Path() int cropId,
  52. {@Path() int page = 0, @Path() int size = 20});
  53. @GET(
  54. "/api/tb-crops-scan-qrCode/{cropCode}?page={page}&size={size}&sort=executeDate,DESC")
  55. Future<CropPlot> getCropDetailByCode(@Path() String cropCode,
  56. {@Path() int page = 0, @Path() int size = 20});
  57. @PUT("/api/tb-crops")
  58. Future<void> updateCrop(@Body() TbCropDTO crop);
  59. //Device
  60. @GET("/api/listDeviceOfUserCustomers")
  61. Future<List<Device>> getDevices();
  62. //Get environment parameter
  63. @GET("/api/list-environment-updates-display/{cropId}?page={page}&size={size}")
  64. Future<List<EnvironmentParameter>> getEnvironmentParameters(
  65. @Path() int cropId,
  66. {@Path() int page = 0,
  67. @Path() int size = 20});
  68. }