//
//  GetMessage.swift
//  Sailassist
//
//  Created by 三浦薫巳 on 2023/11/14.
//

import Foundation

class GetMessage {
    var sessionGetMessage = SessionGetMessage()

    func start() {
        print(debug: "called")
        sessionGetMessage.RequestGetMessage { response in
            switch response {
            case .success(let resultData):
                let serverSession = ServerSession()
                let resjson = serverSession.fromJSON(resultData: resultData, resltType: ResGetMessages.self)
                if let res = resjson {
                    SharingData.message.mode = res.mode
                    SharingData.message.messages = []
                    if let msg = res.messages {
                        SharingData.message.messages = msg
                    }
                }
            case .failure(let errorCode):
                print(debug: errorCode)
                break
            }
        }
    }
}

