//
//  YHFamilyRequest.swift
//  galaxy
//
//  Created by edy on 2024/2/1.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//


class YHFamilyRequest {
    
    var familyInfo:YHFamilyMemberGroupInfo?

        //请求所有家庭成员信息
     func getFamilyInfo(params:[String:Any], callBackBlock:@escaping (_ success: Bool,_ error:YHErrorModel?)->()) {
        
        let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.Order.familyInfoApi
        
        let _ = YHNetRequest.getRequest(url: strUrl, params:params) {[weak self] json, code in
            //1. json字符串 转 对象
            guard let self = self else { return }
            guard let model = NetBaseModel.deserialize(dict: json) else {
                let error : YHErrorModel = YHErrorModel(errorCode:YHErrorCode.dictParseError.rawValue,errorMsg: YHErrorCode.dictParseError.description())
                callBackBlock(false,error)
                return
            }
            printLog("model 是 ==> \(model)")
            let dic = model.data?.peel
            guard let resultModel = YHFamilyMemberGroupInfo.deserialize(dict: dic as? [AnyHashable : Any]) else {

                callBackBlock(false,nil)
                return
            }
            familyInfo = resultModel
            callBackBlock(true,nil)
            
        } failBlock: { err in
            callBackBlock(false,err)
        }
    }
        

}
