|
- import 'package:dio/dio.dart';
- import 'package:farm_tpf/custom_model/CropPlot.dart';
- import 'package:farm_tpf/custom_model/Device.dart';
- import 'package:farm_tpf/custom_model/Harvest.dart';
- import 'package:farm_tpf/custom_model/WaterType.dart';
- import 'package:farm_tpf/custom_model/account.dart';
- import 'package:farm_tpf/custom_model/password.dart';
- import 'package:farm_tpf/custom_model/user.dart';
- import 'package:farm_tpf/custom_model/user_request.dart';
- import 'package:farm_tpf/models/Supply.dart';
- import 'package:farm_tpf/models/index.dart';
- import 'package:farm_tpf/utils/const_common.dart';
- import 'package:retrofit/retrofit.dart';
-
- part 'rest_client.g.dart';
-
- @RestApi(baseUrl: ConstCommon.baseUrl)
- abstract class RestClient {
- factory RestClient(Dio dio, {String baseUrl}) = _RestClient;
-
- @POST("/api/authenticate")
- Future<User> login(@Body() UserRequest userRequest);
-
- @GET("/api/account")
- Future<Account> getMe();
-
- @POST("/api/account/reset-password/init")
- Future<void> forgotPassword(@Body() String email);
-
- @POST("/api/account/reset-password/finish")
- Future<void> resetPassword(@Body() Password password);
-
- @POST("/api/account/change-password")
- Future<void> changePassword(@Body() Password password);
-
- @PUT("/api/update-my-profile")
- Future<Account> updateProfile(@Body() Account account);
-
- @GET("/api/tb-supplies-by-type/{type}")
- Future<List<Supply>> getSupplies(@Path() String type);
-
- //Common
- @PUT("/api/update-fcmToken")
- Future<void> updateFcmToken(@Body() String token);
-
- @GET("/api/tb-crops?page={page}&size={size}&query={query}")
- Future<List<Crop>> getPlots(
- {@Path() int page = 0, @Path() int size = 20, @Path() String query = ""});
- @GET("/api/listActivityTypesOther")
- Future<List<ActionType>> getActionTypes({@DioOptions() Options options});
-
- @GET("/api/water-types")
- Future<List<WaterType>> getWaterTypes({@DioOptions() Options options});
-
- @GET("/api/tb-harvests")
- Future<List<Harvest>> getHarvests({@DioOptions() Options options});
-
- //Crop
- @GET(
- "/api/tb-crops-detail-for-app/{cropId}?page={page}&size={size}&sort=executeDate,DESC")
- Future<CropPlot> getCropDetail(@Path() int cropId,
- {@Path() int page = 0, @Path() int size = 20});
-
- @GET(
- "/api/tb-crops-scan-qrCode/{cropCode}?page={page}&size={size}&sort=executeDate,DESC")
- Future<CropPlot> getCropDetailByCode(@Path() String cropCode,
- {@Path() int page = 0, @Path() int size = 20});
-
- @PUT("/api/tb-crops")
- Future<void> updateCrop(@Body() TbCropDTO crop);
- //Device
- @GET("/api/listDeviceOfUserCustomers")
- Future<List<Device>> getDevices();
- }
|