import 'dart:io';

import 'package:diplomaticquarterapp/config/config.dart';
import 'package:diplomaticquarterapp/core/model/feedback/COC_items.dart';
import 'package:diplomaticquarterapp/core/model/feedback/request_insert_coc_item.dart';
import 'package:diplomaticquarterapp/core/service/base_service.dart';

class FeedbackService extends BaseService {
  List<COCItem> cOCItemList = List();
  RequestInsertCOCItem _requestInsertCOCItem = RequestInsertCOCItem();

  Future sendCOCItem(
      {String title,
      String details,
      String cOCTypeName,
      String attachment}) async {
    hasError = false;

    _requestInsertCOCItem.attachment = attachment;
    _requestInsertCOCItem.title = title;
    _requestInsertCOCItem.details = details;
    _requestInsertCOCItem.cOCTypeName = cOCTypeName;
    _requestInsertCOCItem.formTypeID = cOCTypeName;
    _requestInsertCOCItem.mobileNo =
        "966537503378"; //TODO Change it to be dynamic
    _requestInsertCOCItem.isUserLoggedIn = true;
    _requestInsertCOCItem.projectID = 1231755;
    _requestInsertCOCItem.patientName = "TAMER FANASHEH";
    _requestInsertCOCItem.fileName = "";
    _requestInsertCOCItem.uILanguage = "ar"; //TODO Change it to be dynamic
    _requestInsertCOCItem.browserInfo = Platform.localHostname;
    _requestInsertCOCItem.deviceInfo = Platform.localHostname;
    _requestInsertCOCItem.resolution = "400x847";
    _requestInsertCOCItem.projectID = 0;
    _requestInsertCOCItem.identificationNo = 2344670985;

    await baseAppClient
        .post(SEND_FEEDBACK, onSuccess: (dynamic response, int statusCode) {
          var asd = "";
    },
            onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: _requestInsertCOCItem.toJson());
  }

  Future getStatusCOC() async {
    hasError = false;
     Map<String, dynamic> body = new Map<String, dynamic>();
    body['IdentificationNo'] = '2344670985';
    body['MobileNo'] = '966537503378';
    body['Searching_type'] = '1';

    await baseAppClient.post(GET_STATUS_FOR_COCO,
        onSuccess: (dynamic response, int statusCode) {
      cOCItemList = [];
      response['ListCOCItems'].forEach((cOC) {
        cOCItemList.add(COCItem.fromJson(cOC));
      });
    }, onFailure: (String error, int statusCode) {
      hasError = true;
      super.error = error;
    }, body: body);
  }
}
