import 'dart:convert';
import 'package:http/http.dart';
import '../../../Helper/Logger.dart';
import '../../../Model/Request/update_delivery/update_delivery.dart';
import '../../../Model/Response/update_delivery_response/update_delivery_response.dart';

class UpdateDeliveryProvider {

  Future<UpdateDeliveryResponse?> updateDelivery (UpdateDeliveryRequest data,String urldata,) async {
    UpdateDeliveryResponse? updateDeliveryResponse;
    try {

      final url = Uri.parse(urldata);

      final response = await put(url,
          body: json.encode(data),
          headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            // 'Authorization': '$token',
          });

      logger.i('Update Delivery Response : ${response.body}');

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

      updateDeliveryResponse = UpdateDeliveryResponse.fromJson(parsedJson);

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


}