lock method

Future<CuppsCommandResponse> lock({
  1. bool renew = false,
})

Implementation

Future<CuppsCommandResponse> lock({bool renew = false}) async {
  if (haveLock) {
    try {
      DeviceLockRequest req =
          DeviceLockRequest(messageID: currentMessageID, lockMethod: 'byDeviceToken', renew: renew ? "true" : "false");
      String lockResXML = await send(xml: req.toXML());
      DeviceLockResponse lockRes = DeviceLockResponse.fromXML(lockResXML);
      if (lockRes.result.toLowerCase() == "ok") {
        locked = true;
        CUPPS().notifier!();
        return CuppsCommandResponse(status: true, msg: "Device :$deviceName Locked Successfully");
      } else {
        return CuppsCommandResponse(status: false, msg: lockRes.result);
      }
    } catch (e) {
      return CuppsCommandResponse(status: false, msg: "Device $deviceName lock Exception: $e");
    }
  } else {
    return CuppsCommandResponse(status: false, msg: "Illogical Action");
  }
}