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

import '../../../Model/Request/Authentication/Loginrequest.dart';
import '../../../Model/Response/Authentication/Loginresponse.dart';

class LoginProvider{

  Future<LoginResponse?> signIn(String urldata, LoginRequest data) async {
    LoginResponse? loginResponse;

    try {
      final url = Uri.parse(urldata);
      final response = await post(url,

        body: json.encode(data),
        headers: {
          'Content-Type': 'application/json',
          'Accept': 'application/json',
          // 'Authorization': '$token',
        }
      );
      print('urldatasssssssssssssss $urldata');
      print('LoginRequestdata ${data.toJson()}');
      print("signIncontactnosss${data.contactno}");
      print("signIndevicetype${data.devicetype}");
      print("signInconfigid${data.configid}");
      print("deviceidsssssssss${data.deviceid}");
      print("customertokensssss${data.userfcmtoken}");
      print("responseeeeeedata ${response.body}");

      Map<String, dynamic> parsedJson = json.decode(response.body.toString());

      loginResponse = LoginResponse.fromJson(parsedJson);
      print('provider result$loginResponse');
    } catch (e) {
      print(e.toString());
      print("errr");
    }
    return loginResponse;
  }

}