import 'dart:convert';

import 'package:http/http.dart';

import '../../../../Helper/Logger.dart';
import '../../../../Model/Request/Staffs/Addstaffs/Addstaffsrequest.dart';
import '../../../../Model/Response/Staffs/Addstaffs/Addstaffresponse.dart';

class AddStaffProvider{

  Future<CreateStaffResponse?> addStaff(CreateStaffRequest data,String urldata,) async {
    CreateStaffResponse? createStaffResponse;
    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('createStaffResponseresponsebody ${response.body}');
      print('createStaffResponsedatatoJson ${data.toJson()}');
      print('createStaffResponseresponseorderdate ${data.tenantid}');
      print('createStaffResponseresponsetenantid ${data.locationid}');
      print('createStaffResponseresponseconfigid ${data.configid}');
      print('createStaffResponseresponsepartnerid ${data.partnerid}');
      logger.i(json.encode(data.toJson()));



      // print('headerssssssssss ${response.headers}');
      print('CreateOrderurlsssssssssss ${urldata.toString()}');
      Map<String, dynamic> parsedJson = json.decode(response.body.toString());

      createStaffResponse = CreateStaffResponse.fromJson(parsedJson);
      print('createOrderinprovider${createStaffResponse}');

    } catch (e) {
      print(e.toString());
      print("error");
    }
    return createStaffResponse;
  }

}