import 'package:{{ name }}/converters/APIResponse.dart';
import 'package:{{ name }}/services/Api.dart';
import 'package:retrofit/retrofit.dart';
import 'package:dio/dio.dart' hide Headers;
import 'package:{{ name }}/models/User.dart';
import 'package:{{ name }}/utils/dio_logging_interceptors.dart';


part 'UsersProvider.g.dart';

@RestApi(baseUrl: baseUrl)
abstract class RestClient {
  factory RestClient(Dio dio){
    dio.interceptors.add(DioLoggingInterceptors(dio));
    return _RestClient(dio, baseUrl: baseUrl);
  }

  @GET("/users")
  @Headers(<String, String>{"requiresToken": "true"})
  Future<APIResponse<List<User>>> getUsers();

  @GET("/users/{id}")
  @Headers(<String, String>{"requiresToken": "true"})
  Future<APIResponse<User>> getUser(@Path("id") String id);

  @POST("/users")
  @Headers(<String, String>{"requiresToken": "true"})
  Future<APIResponse<User>> createUser(@Body() User user);

  @PUT("/users/{id}")
  @Headers(<String, String>{"requiresToken": "true"})
  Future<APIResponse<User>> updateUser(@Path() String id, @Body() User user);

  @DELETE("/users/{id}")
  @Headers(<String, String>{"requiresToken": "true"})
  Future<void> deleteUser(@Path() String id);

}
