//
//  YHSelectCountryViewModel.swift
//  galaxy
//
//  Created by EDY on 2024/1/31.
//  Copyright © 2024 https://www.galaxy-immi.com. All rights reserved.
//

import UIKit

class YHSelectCountryViewModel: NSObject {
    override init() {
        super.init()
    }
    
    func requestCountry(_ key: String, callBackBlock:@escaping (_ success: [YHCountryMessage?]?, _ error:YHErrorModel?)->()) {
        let strUrl = YHBaseUrlManager.shared.curURL() + YHAllApiName.OrderInformation.countryInformation + "?keyword = \(key)"

        YHNetRequest.getRequest(url: strUrl) { [weak self] json, code in
            guard let self = self else { return }
            let dic = json.data as? [Any]
            guard let resultArray = [YHCountryMessage].deserialize(from: dic) else {
                callBackBlock([],nil)
                return
            }
            callBackBlock(resultArray, nil)
        } failBlock: { err in
            callBackBlock([],err)
        }

    }
}

