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.

75 lines
2.6KB

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