import 'package:flutter/cupertino.dart'; import 'package:queuing_system/core/base/base_app_client.dart'; import 'package:queuing_system/core/response_model/patient_call.dart'; const _getCallRequestInfoByClinicInfo = "/GetCallRequestInfoByClinincInfo"; const _call_UpdateNotIsQueueRecordByIDAsync = "/Call_UpdateNotIsQueueRecordByIDAsync"; class API{ static GetCallRequestInfoByClinincInfo(String deviceIp, {@required Function(List, List) onSuccess, @required Function(dynamic) onFailure}) async{ final body = { "IPAdress" : deviceIp }; BaseAppClient.post(_getCallRequestInfoByClinicInfo, body: body, onSuccess: (response, status){ if(status == 200){ final calledByNurse = (response["CalledByNurse"] as List).map((j) => Tickets.fromJson(j)).toList(); final clinicCurrentPatient = (response["ClinicCurrentPatient"] as List).map((j) => Tickets.fromJson(j)).toList(); onSuccess(calledByNurse, clinicCurrentPatient); }else{ onFailure(response); } }, onFailure: (error, status) => onFailure(error)); } // static Call_UpdateNotIsQueueRecordByIDAsync(String deviceIp, {@required List tickets, @required Function(List) onSuccess, @required Function(dynamic) onFailure}) async{ // if(tickets.isEmpty) { // return; // } // // List _ticketsUpdated = []; // // for (var ticket in tickets) { // final body = { "CallID" : ticket.callNo}; // await BaseAppClient.post(_call_UpdateNotIsQueueRecordByIDAsync, body: body, onSuccess: (response, status){ // if(status == 200){ // ticket.call_updated = true; // _ticketsUpdated.add(ticket); // } // }, onFailure: (error, status) => onFailure(error)); // } // // if(_ticketsUpdated.isNotEmpty) { // onSuccess(_ticketsUpdated); // }else{ // onFailure(false); // } // } }