class ServerResponse {
  dynamic response = {};
  bool isError = false;
  String errorCode = "";
  String errorMsg = "";
  int statusCode = -1;

  ServerResponse(this.response, this.isError, this.errorCode, this.errorMsg, this.statusCode);

  ServerResponse.init() {
    response = {};
    isError = false;
    errorCode = "";
    errorMsg = "";
    statusCode;
  }

  Map<String, dynamic> toMap() {
    return {
      'response': response,
      'isError': isError,
      'errorCode': errorCode,
      'errorMsg': errorMsg,
      'statusCode': statusCode,
    };
  }

  factory ServerResponse.fromMap(Map<String, dynamic> map) {
    return ServerResponse(
      map['response'] as Map<dynamic, dynamic>,
      map['isError'] as bool,
      map['errorCode'] ?? "",
      map['errorMsg'] ?? "",
      map['statusCode'] as int,
    );
  }

  ServerResponse setStatusCode(int value) {
    statusCode = value;
    return this;
  }

  ServerResponse setErrorMsg(String value) {
    errorMsg = value;
    return this;
  }

  ServerResponse setErrorCode(String value) {
    errorCode = value;
    return this;
  }

  ServerResponse setIsError(bool value) {
    isError = value;
    return this;
  }

  // ServerResponse setResponse(Map<dynamic, dynamic> value) {
  //   response = value;
  //   return this;
  // }
  ServerResponse setResponse(dynamic value) {
    response = value;
    return this;
  }


  @override
  String toString() {
    return 'ServerResponse{response: $response, isError: $isError, errorCode: $errorCode, errorMsg: $errorMsg, statusCode: $statusCode}';
  }
}
