import 'package:mwf_app/service/api.dart';
import 'package:mwf_app/service/url.dart';

class ChatMaster {
  String id;
  String typeChat;
  String accountId;
  String chatMasterName;
  String chatMasterId;
  String typeAccount;
  int memberCount;
  String createDate;
  String createId;
  String strCreateDate;
  String strTime;
  String customerId;
  String ca;
  String customerName;
  String customerAddress;

  ChatMaster({
    this.id,
    this.typeChat,
    this.accountId,
    this.chatMasterName,
    this.chatMasterId,
    this.typeAccount,
    this.memberCount,
    this.createDate,
    this.createId,
    this.strCreateDate,
    this.strTime,
    this.ca,
    this.customerName,
    this.customerAddress,
    this.customerId,
  });

  static List<ChatMaster> data = []; // ตัวแปรที่จะเรียกใช้งาน
  static List<ChatMaster> dataGroup = []; // ตัวแปรที่จะเรียกใช้งาน

  static getData() async {
    print(
      AppUrl.ChatMaster_ByAccountList +
          "?AccountId=" +
          AppUrl.userID +
          "&TypeAccount=" +
          AppUrl.typeAccount +
          "&saleInfoId=" +
          AppUrl.userID +
          "&AuthenKey=" +
          AppUrl.AuthenKey,
    );

    final response = await AppApi.apiGetRequest(
      AppUrl.ChatMaster_ByAccountList +
          "?AccountId=" +
          AppUrl.userID +
          "&TypeAccount=" +
          AppUrl.typeAccount +
          "&saleInfoId=" +
          AppUrl.userID +
          "&AuthenKey=" +
          AppUrl.AuthenKey,
    ); // เรียกใช้ api

    return response;
  }

  ChatMaster.fromJson(Map<String, dynamic> json) {
    id = json['Id'];
    typeChat = json['TypeChat'];
    accountId = json['AccountId'];
    chatMasterName = json['ChatMasterName'];
    chatMasterId = json['ChatMasterId'];
    typeAccount = json['TypeAccount'];
    memberCount = json['MemberCount'];
    createDate = json['CreateDate'];
    createId = json['CreateId'];
    strCreateDate = json['strCreateDate'];
    strTime = json['strTime'];
    ca = json['CA'];
    customerId = json['CustomerId'];
    customerName = json['CustomerName'];
    customerAddress = json['CustomerAddress'];
  }
}
