import 'package:intl/intl.dart';

class HalykPosSession {
  const HalykPosSession(
      {this.login,
      this.token,
      this.serverTime,
      this.tokenTimeout,
      this.result});

  final String? login;
  final String? token;
  final DateTime? serverTime;
  final int? tokenTimeout;
  final ResultBean? result;

  static HalykPosSession fromJson(Map<String, dynamic> data) => HalykPosSession(
      login: data['login'],
      token: data['token'],
      result: ResultBean.fromMap(data['result']),
      serverTime: data['ServerTime'] != null
          ? new DateFormat("dd.MM.yyyy HH:mm:ss ZZZ").parse(data['ServerTime'])
          : null,
      tokenTimeout: data['TokenTimeout']);
}

/// ServerTime : "25.06.2021 13:18:00 GMT+06:00"
/// ResultCode : "040"
/// ResultStr : "Unknown operator login. Check the correctness of the data or contact support."
/// Response : {"Code":"040","Description":"Unknown operator login. Check the correctness of the data or contact support."}

class ResultBean {
  String? ServerTime;
  String? ResultCode;
  String? ResultStr;
  ResponseBean? Response;

  static ResultBean? fromMap(Map<String, dynamic>? map) {
    if (map == null) return null;
    ResultBean resultBean = ResultBean();
    resultBean.ServerTime = map['ServerTime'];
    resultBean.ResultCode = map['ResultCode'];
    resultBean.ResultStr = map['ResultStr'];
    resultBean.Response = ResponseBean.fromMap(map['Response']);
    return resultBean;
  }

  Map toJson() => {
        "ServerTime": ServerTime,
        "ResultCode": ResultCode,
        "ResultStr": ResultStr,
        "Response": Response,
      };
}

/// Code : "040"
/// Description : "Unknown operator login. Check the correctness of the data or contact support."

class ResponseBean {
  String? Code;
  String? Description;

  static ResponseBean? fromMap(Map<String, dynamic>? map) {
    if (map == null) return null;
    ResponseBean responseBean = ResponseBean();
    responseBean.Code = map['Code'];
    responseBean.Description = map['Description'];
    return responseBean;
  }

  Map toJson() => {
        "Code": Code,
        "Description": Description,
      };
}
