//
//  SessionInformation.swift
//  Sailassist
//
//  Created by 三浦薫巳 on 2024/02/29.
//

import Foundation
import SwiftUI

class SessionInformation : ObservableObject {
    @Published var status = false
    // シングルトン宣言
    static let OnlyOne = SessionInformation()

    private var serverSession = ServerSession()
    private var Calling : Bool = false      // 通信中

    /**
     * System Information取得
     */
    func RequestInformation(_ completion: @escaping ((Result<Data, APIError>)) -> Void) {
        print(debug: "calld")
        if Calling {
            return
        }
        Calling = true

        // リクエストURLの組み立て
        let url_string : String = HttpRequestType.Information.rawValue
        guard let req_url = URL(string : url_string) else {
            Calling = false
            return
        }

        serverSession.getJson(req_url, completion: completion)
    }
}
