//
//  YHHomeNetWorkServer.swift
//  galaxy
//
//  Created by EDY on 2024/1/5.
//  Copyright © 2024 www.davidhuang.com. All rights reserved.
//

import UIKit
import RxSwift

class YHHomeNetWorkServer {
    static let share = YHHomeNetWorkServer()
    func getRequest(_ url: String) -> Single<[String: Any]> {
        return Single<[String: Any]>.create { single in
            YHNetRequest.getRequest(url: url) { json, code in
                //1. json字符串 转 对象
                guard NetBaseModel.deserialize(dict: json) != nil else {
                    print("error....底层解析出错了...")
                    return single(.failure(YHError.net))
                }
                return single(.success(json))
            } failBlock: { err in
                return single(.failure(YHError.net))
            } as! any Disposable
        }
    }
}

enum YHError: Error {
    case net
    case fail
}
