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

import Foundation

class GetInformation {
    var sessionInformation = SessionInformation()

    func start() {
        print(debug: "called")
        sessionInformation.RequestInformation(responseInformation)
    }

    func responseInformation(result: Result<Data, APIError>) {
        print(debug: "called")
        switch result {
        case .success(let resultData):
            let serverSession = ServerSession()
            let resjson = serverSession.fromJSON(resultData: resultData, resltType: [ResInformation].self)
            SharingData.information.content = []
            if let res = resjson {
                SharingData.information.content = res
            }
        case .failure(let errorCode):
            print(debug: errorCode)
            break
        }
    }
}
