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 }}/models/Auth/JwtToken.dart';
import 'package:{{ name }}/utils/dio_logging_interceptors.dart';

part 'AuthProvider.g.dart';

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

  @POST("/auth/login")
  Future<JwtToken> login(@Field("email") String email, @Field("password") String password, @Field("rememberMe") bool rememberMe);

  @POST("/auth/logout")
  @Headers(<String, String>{"requiresToken": "true"})
  Future<String> logout();

  @GET("/auth/refresh")
  @Headers(<String, String>{"requiresToken": "true"})
  Future<JwtToken> refresh();

  @POST("/auth/password/email")
  Future<String> reset(@Field("email") String email);

  @POST("/auth/register")
  Future<String> register(@Field("name") String name, @Field("email") String email, @Field("password") String password);

  @GET("/auth/user")
  @Headers(<String, String>{"requiresToken": "true"})
  Future<User> getUser();

  @POST("/auth/{provider}/callback")
  Future<String> socialLogin(@Path("provider") String provider);

}
