import 'dart:convert';

import 'package:logging/logging.dart';

import 'package:http/http.dart' as http;

import 'package:pshared/service/pfe/login.dart';


class PfeService {
  static final _logger = Logger('service.pfe');

  static Future<String> login(String email, String password) async {
    _logger.fine('Logging in');

    try {
    final res = await http.post(
      Uri.parse('http://localhost:3000/api/v1/auth/login'), 
      headers: {'Content-Type': 'application/json'},
      body: json.encode(LoginRequest(login: email, password: password).toJson()),
    );
    return res.toString();
    } catch (e) {
      _logger.warning(e.toString());
      rethrow;
    }

  }
}
