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.

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